jpaul.DataStructs
Class MapFacts

java.lang.Object
  extended by jpaul.DataStructs.MapFacts

public abstract class MapFacts
extends java.lang.Object

MapFacts contains several common map factories. For each kind of map factory, we have a corresponding static method. Note: some old map factories that used to exist as separate classes are now static inner classes of this class. They are provided mostly to simplify porting old code (programmers only have to change a few import statements).

Version:
$Id: MapFacts.java,v 1.6 2006/03/14 02:29:31 salcianu Exp $
Author:
Alexandru Salcianu - salcianu@alum.mit.edu

Nested Class Summary
static class MapFacts.HashMapFactory<K,V>
          Deprecated. As of jpaul 2.2, use hash() instead.
static class MapFacts.TreeMapFactory<K,V>
          Deprecated. As of jpaul 2.2, use tree(Comparator) instead.
 
Constructor Summary
MapFacts()
           
 
Method Summary
static
<K,V> MapFactory<K,V>
cow(MapFactory<K,V> underMapFact)
          Copy-on-write maps.
static
<K,V> MapFactory<K,V>
hash()
          Returns a map factory that generates LinkedHashMaps.
static
<K,V> MapFactory<K,V>
noCompTree()
          Returns a map factory that generates NoCompTreeMap.
static
<K,V> MapFactory<K,V>
tree(java.util.Comparator<K> comp)
          Returns a map factory that generates TreeMaps.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapFacts

public MapFacts()
Method Detail

hash

public static <K,V> MapFactory<K,V> hash()
Returns a map factory that generates LinkedHashMaps. LinkedHashMaps are great for applications that use a few large maps. They also offer predictable iteration order (identical to the insertion order). A LinkedHashMaps is only slightly slower than a HashMap (iteration is actually faster: linear in the actual size, independent of the capacity). Therefore, in the interest of simplicity, instead of a factory for HashMaps and a factory for LinkedHashMaps, jpaul offers only the latter.


tree

public static <K,V> MapFactory<K,V> tree(java.util.Comparator<K> comp)
Returns a map factory that generates TreeMaps. TreeMaps are great for applications that use many small maps.

Parameters:
comp - Comparator used internally by the generated TreeMaps.

cow

public static <K,V> MapFactory<K,V> cow(MapFactory<K,V> underMapFact)
Copy-on-write maps. UNIMPLEMENTED YET.


noCompTree

public static <K,V> MapFactory<K,V> noCompTree()
Returns a map factory that generates NoCompTreeMap. NoCompTreeMap is a binary tree-backed map that does not require a user-defined Comparator between keys.



Copyright 2005 Alexandru Salcianu - salcianu@alum.mit.edu