Regain 2.1.0-STABLE API

net.sf.regain.util
Class ChainedHashMap<K,V>

java.lang.Object
  extended by net.sf.regain.util.ChainedHashMap<K,V>
Type Parameters:
K - Key
V - Value
All Implemented Interfaces:
Iterable<Map.Entry<K,V>>, Map<K,V>

public class ChainedHashMap<K,V>
extends Object
implements Map<K,V>, Iterable<Map.Entry<K,V>>

Hashtable that can contain several entries per key. (Helper Class) Contract:

  • It is possible to put several identical key-value pairs (i.e. where key and value is equal)
  • entrySet is not supported. Instead, it can be iterated over all entries.


    Nested Class Summary
     
    Nested classes/interfaces inherited from interface java.util.Map
    Map.Entry<K,V>
     
    Field Summary
    private static int DEFAULT_HASHTABLE_SIZE
               
    private static int DEFAULT_LIST_SIZE
               
    (package private)  HashMap<K,List<V>> hashtable
               
    private  int listSize
               
    (package private)  int size
               
     
    Constructor Summary
    ChainedHashMap()
               
    ChainedHashMap(int hashtableSize)
               
    ChainedHashMap(int hashtableSize, int chainSize)
               
    ChainedHashMap(Map<? extends K,? extends V> map)
               
     
    Method Summary
     void clear()
               
     boolean containsKey(Object key)
               
     boolean containsValue(Object value)
               
     Set<Map.Entry<K,V>> entrySet()
               
     V get(Object key)
               
     Iterable<V> getIterable(Object key)
              Get all objects linked by this key as an Iterable usable an foreach loop.
     List<V> getList(Object key)
               
     boolean isEmpty()
               
     Iterator<Map.Entry<K,V>> iterator()
              Iterate over all elements in the table.
     Set<K> keySet()
               
     V put(K key, V value)
               
     void putAll(Map<? extends K,? extends V> map)
               
     boolean remove(K key, V value)
               
     V remove(Object key)
               
     int size()
               
     String toString()
               
     Collection<V> values()
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
     
    Methods inherited from interface java.util.Map
    equals, hashCode
     

    Field Detail

    DEFAULT_HASHTABLE_SIZE

    private static final int DEFAULT_HASHTABLE_SIZE
    See Also:
    Constant Field Values

    DEFAULT_LIST_SIZE

    private static final int DEFAULT_LIST_SIZE
    See Also:
    Constant Field Values

    listSize

    private int listSize

    hashtable

    HashMap<K,List<V>> hashtable

    size

    int size
    Constructor Detail

    ChainedHashMap

    public ChainedHashMap()

    ChainedHashMap

    public ChainedHashMap(int hashtableSize)

    ChainedHashMap

    public ChainedHashMap(int hashtableSize,
                          int chainSize)

    ChainedHashMap

    public ChainedHashMap(Map<? extends K,? extends V> map)
    Method Detail

    size

    public int size()
    Specified by:
    size in interface Map<K,V>

    isEmpty

    public boolean isEmpty()
    Specified by:
    isEmpty in interface Map<K,V>

    containsKey

    public boolean containsKey(Object key)
    Specified by:
    containsKey in interface Map<K,V>

    containsValue

    public boolean containsValue(Object value)
    Specified by:
    containsValue in interface Map<K,V>

    get

    public V get(Object key)
    Specified by:
    get in interface Map<K,V>

    getIterable

    public Iterable<V> getIterable(Object key)
    Get all objects linked by this key as an Iterable usable an foreach loop.

    Parameters:
    key -
    Returns:
    Iterable
    Throws:
    NullPointerException - (if key null)

    getList

    public List<V> getList(Object key)

    iterator

    public Iterator<Map.Entry<K,V>> iterator()
    Iterate over all elements in the table. Note that this currently copies them into a collection, so concurrent modification will not be taken into account (there will be no ConcurrentModificationException, either).

    Specified by:
    iterator in interface Iterable<Map.Entry<K,V>>

    put

    public V put(K key,
                 V value)
    Specified by:
    put in interface Map<K,V>

    remove

    public V remove(Object key)
    Specified by:
    remove in interface Map<K,V>

    remove

    public boolean remove(K key,
                          V value)

    putAll

    public void putAll(Map<? extends K,? extends V> map)
    Specified by:
    putAll in interface Map<K,V>

    clear

    public void clear()
    Specified by:
    clear in interface Map<K,V>

    keySet

    public Set<K> keySet()
    Specified by:
    keySet in interface Map<K,V>

    values

    public Collection<V> values()
    Specified by:
    values in interface Map<K,V>

    entrySet

    public Set<Map.Entry<K,V>> entrySet()
    Specified by:
    entrySet in interface Map<K,V>

    toString

    public String toString()
    Overrides:
    toString in class Object

    Regain 2.1.0-STABLE API

    Regain 2.1.0-STABLE, Copyright (C) 2004-2010 Til Schneider, www.murfman.de, Thomas Tesche, www.clustersystems.info