Layered interval codes for TCAM-based classification