org.semanticweb.elk.util.collections
Class ArrayHashMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by org.semanticweb.elk.util.collections.ArrayHashMap<K,V>
Type Parameters:
K - the type of the keys
V - the type of the values
All Implemented Interfaces:
Map<K,V>
Direct Known Subclasses:
AbstractHashMultimap

public class ArrayHashMap<K,V>
extends AbstractMap<K,V>
implements Map<K,V>

hash maps using array and linear probing for resolving hash collision see [1] p.526. Reuses some code from the implementation of HashMap. [1] Donald E. Knuth, The Art of Computer Programming, Volume 3, Sorting and Searching, Second Edition

Author:
Yevgeny Kazakov

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
protected  K[] keys
          The table for the keys; the length MUST always be a power of two.
protected  int size
          The number of key-value entries contained in this map.
protected  V[] values
          The table for the values; the length MUST be equal to the length of keys and MUST always be a power of two.
 
Constructor Summary
ArrayHashMap()
           
ArrayHashMap(int initialCapacity)
           
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set<Map.Entry<K,V>> entrySet()
           
 V get(Object key)
           
 boolean isEmpty()
           
 Set<K> keySet()
           
 V put(K key, V value)
           
 V remove(Object key)
           
 int size()
           
 Collection<V> values()
           
 
Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, putAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode, putAll
 

Field Detail

keys

protected transient volatile K[] keys
The table for the keys; the length MUST always be a power of two.


values

protected transient volatile V[] values
The table for the values; the length MUST be equal to the length of keys and MUST always be a power of two.


size

protected transient int size
The number of key-value entries contained in this map.

Constructor Detail

ArrayHashMap

public ArrayHashMap(int initialCapacity)

ArrayHashMap

public ArrayHashMap()
Method Detail

size

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

isEmpty

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

containsKey

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

containsValue

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

get

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

put

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

remove

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

clear

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

keySet

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

values

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

entrySet

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


Copyright © 2011-2013 Department of Computer Science, University of Oxford. All Rights Reserved.