Java List<MyClass> to TreeMap<Long, MyClass> -
is there way, how convert list<myclass>
treemap<long, myclass>
reasonable performance? have found method maps.uniqueindex()
in google collections, homecoming map
.
list can destroyed during process of conversion, need treemap. utilize treemap because need fast search , indexation long.
thanks in advance
there no simpler method iteration.
map<long, myclass> tree = new hashmap<long, myclass>(); (myclass cl: classlist){ tree.put(cl.getid(), cl); }
just seelenvirtuose mentioned: if want search performance: hashmap, if want elements sorted utilize treemap. in search performance goes hashmap.
java list treemap
No comments:
Post a Comment