I have several data structures HashMapcontaining hundreds of objects Comparable(say, a type MyClass) and I need to put all the values (not keys) into a single data structure, and then sort it.
Due to the volume and speed of arrival of objects, MyClassthis procedure (performed at least once every millisecond) should be as effective as possible.
The approach would be to use SortedSetsomething like this:
HashMap<String, MyClass>[] allMaps = ...
SortedSet<MyClass> set = new TreeSet<MyClass>();
Collection<MyClass> c;
for (HashMap<String, MyClass> m:allMaps)
{
c = m.values();
set.addAll(c);
}
set.addAll(), TreeSet . List Collections.sort(), Collection List, .. .
, , .
?