Maximising efficiency of a data structure ordered by a person name using Java Collections -


i need have data structure mapped name of person, implies duplicate keys have stored. have log(n) times (at most) insertions, deletions , searches.

ideally, have hashtable mapped unique identifier, generated upon insertion. doing so, have insertions in constant time. auxiliary ordered balanced tree each entry being reference entry in hashtable, able search/delete name in logarithmic time, , print entries in linear time, ordered name.

is there way in java reusing available collections? or @ least solution similar complexity...

in this question, suggested map solve problem. understanding, no map can deal repeated keys properly.

if understand question right, want multimap. there few implementations in guava , commons-lang, or roll own using e.g. hashmap (or treemap if suspect .hashcode() implementation slow or poor, i'd benchmark first) , list or set implementation value types.

note if want iterate on values based on name order, you're best off using tree-based multimap: if name key, order want without needing else.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -