collections - Matching objects with specified properties using Java -


i have 1,000,000 objects. need match them 4 different properties within specified range .

  1. length (10meters - 20meters)
  2. breadth (12meters - 18meters)
  3. height (3meters - 6meters)
  4. color (red)

a simple loop isnt efficient way go it. type of collections should looking implement? how should i've approached problem.

a navigableset might work you. need define different comparator each of properties. basically, start set sorted 1 property , subset fits range. place subset navigableset sorted comparator second property... repeat.

but don't think of beats o(n) time :p since sort o(nlogn). @ least interesting.


Comments