A method and apparatus for locating in a list of pre-defined codes, a
longest code matching a given code. The method and apparatus involve
producing a search mask encoding at least one portion of said given code
and comparing the search mask to a search key having a Prefix Node Bit
Array (PNBA) in which a bit is set active in at least one of a plurality
of bit positions corresponding to possible bit combinations of bits in a
bit string having a length equal to or less than the longest predefined
code in the plurality of pre-defined codes and arranged by the lengths of
possible bit combinations and by numeric values of the bit combinations,
to identify a common active bit position in the search key and the search
mask corresponding to one of the pre-defined codes having a length
greater than all others of said pre-defined codes which correspond to
common active bit positions.