This class implements an ordered Hashtable, which maps keys to values. Any non-null object can be used as a key or as a value.

I originally wrote this back in 2004 because in the MIDP API there is no support for the Java Collection API which provides a rich set of collection classes, thus SimpleOrderedHashtable.java implements, as the name implies, a simple ordered Hashtable that uses a Vector and a Hashtable in its implementation. You can use this SimpleOrderedHashtable as a container of objects that exposes both hashed and chronologically ordered sequential access capabilities.

This ordered Hashtable is called simple because internally it uses the Legacy collection classes, a Vector to maintain the element’s order and a Hashtable to provide hashing capabilities. Because Hashtable and Vector grow differently, the implementation of SimpleOrderedHashtable is not the most efficient one, but may be good-enough for your needs.

As with typical Hashtables, to successfully store and retrieve objects from a Hashtable, the objects used as keys must implement the hashCode method and the equals method.

There are many instances where you would like to use an ordered com.cenriqueortiz.utilities.Hashtable, for example, to keep your user interface elements ordered, or to keep ordered items from a database or backend while providing fast access to name/value pairs via Hashtable keys, or to store and access any value you want to access using a key.

SimpleOrderedHashtable.java


If you are using SimpleOrderedHashtable, feel free to leave a comment…


Copyright (c) 2004-2012 C. Enrique Ortiz
Usage & redistributions of source code must retain attribution notice.
Created on November, 2004.
Updated on December 21, 2004.
Updated on April 2012.


ceo