The invention relates to data packet filtering and finding a rule matching
a data packet in a rule base. A data packet comprises parameter fields
for identifying the data packet, the rule base comprises a plurality of
rules, each rule comprises one or more parameter fields, and the matching
rule is a rule, whose parameter field values correspond to the parameter
field values of said data packet. The matching rule is found by
determining rule sets for the data packet, one rule set comprising the
rules to which one parameter field value of the data packet can match,
and by finding the rule with the smallest label that is present in all
said rule sets of the data packet, said rule with the smallest label
indicating the rule matching the data packet. Additionally, the invention
relates to finding an element with the smallest label that is present in
a plurality of finite subsets containing finite number of elements, said
subsets being subsets of a set containing finite number of sequentially
labelled elements.