1. A router, comprising: a communication interface configured to receive a data packet; a ternary content-addressable memory (TCAM) circuit, including: a rule memory that stores a plurality of rules in association with corresponding port ranges, the rule memory having a plurality of unused bits; an assignment circuit configured to encode a plurality of most commonly occurring ranges of the port ranges so as to occupy one or more of the plurality of unused bits, the assignment circuit separating the plurality of unused bits into a first virtual partition designated for a non-overlapping range from among the plurality of most commonly occurring ranges and a second virtual partition designated for an overlapping range from among the plurality of most commonly occurring ranges; a processor configured to determine at least one rule from among the plurality of rules applicable to the data packet based on the encoded plurality of most commonly occurring ranges; and a priority circuit configured to select a final rule from among the at least one rule applicable to the data packet; and a rule execution circuit configured to execute the selected final rule on the data packet.