commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lavandowska <>
Subject RE: [Collections] Insertion Ordered Map
Date Sun, 04 Nov 2001 16:27:58 GMT

I got some time to test OrderedHashMap, and found it was maintaining
"reverse insertion order" or FILO.  FIFO was *my* desired behaviour,
but FILO could be desirable in other situations.  Perhaps this
condition would merit a different naming scheme than "Ordered" (Ordered
according to what?).

Getting it to FIFO involved this change:

private void insertEntry(Entry entry) { = sentinel;
  	entry.prev = sentinel.prev; = entry;
  	sentinel.prev = entry;

I've attached a little tester class that proves that for large Maps,
OrderedHashMap is faster (at 1400 keys it is twice as fast).  While it
doesn't provide proper support for the keySet, entrySet & values
methods, FIFOMap was faster for small Maps (tested on an order of 10:
140 keys vs 1400 keys).  I doubt its worth the investigation to get
FIFOMap to support these methods properly, but I might do it anyway for
my own education.


Do You Yahoo!?
Find a job, post your resume.
View raw message