Class FastMap<K,V>

java.lang.Object
org.codehaus.plexus.util.FastMap<K,V>
All Implemented Interfaces:
Serializable, Cloneable, Map<K,V>

public class FastMap<K,V> extends Object implements Map<K,V>, Cloneable, Serializable

This class represents a Map collection with real-time behavior. Unless the map's size exceeds its current capacity, no dynamic memory allocation is ever performed and response time is extremely fast and consistent.

Our benchmark indicates that FastMap.put(key, value) is up to 5x faster than java.util.HashMap.put(key, value). This difference is mostly due to the cost of the Map.Entry allocations that FastMap avoids by recycling its entries (see note below).

FastMap has a predictable iteration order, which is the order in which keys were inserted into the map (similar to java.util.LinkedHashMap collection class).

Applications may change the resizing policy of FastMap by overriding the sizeChanged() method. For example, to improve predictability, automatic resizing can be disabled.

This implementation is not synchronized. Multiple threads accessing or modifying the collection must be synchronized externally.

Note: To avoid dynamic memory allocations, FastMap maintains an internal pool of Map.Entry objects. The size of the pool is determined by the map's capacity. When an entry is removed from the map, it is automatically restored to the pool.

This class is public domain (not copyrighted).

Version:
5.3, October 31 2003
Author:
Jean-Marie Dautelle
See Also: