org.jboss.cache.util
Class FastCopyHashMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by org.jboss.cache.util.FastCopyHashMap<K,V>
All Implemented Interfaces:
Serializable, Cloneable, Map<K,V>

public class FastCopyHashMap<K,V>
extends AbstractMap<K,V>
implements Map<K,V>, Cloneable, Serializable

A HashMap that is optimized for fast shallow copies. If the copy-ctor is passed another FastCopyHashMap, or clone is called on this map, the shallow copy can be performed using little more than a single array copy. In order to accomplish this, immutable objects must be used internally, so update operations result in slightly more object churn than HashMap. Note: It is very important to use a smaller load factor than you normally would for HashMap, since the implementation is open-addressed with linear probing. With a 50% load-factor a get is expected to return in only 2 probes. However, a 90% load-factor is expected to return in around 50 probes.

Author:
Jason T. Greene
See Also:
Serialized Form

Nested Class Summary
protected static class FastCopyHashMap.SimpleEntry<K,V>
           
 
Constructor Summary
FastCopyHashMap()
           
FastCopyHashMap(int initialCapacity)
           
FastCopyHashMap(int initialCapacity, float loadFactor)
           
FastCopyHashMap(Map<? extends K,? extends V> map)
           
 
Method Summary
 void clear()
           
 Object clone()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set<Map.Entry<K,V>> entrySet()
           
 V get(Object key)
           
 boolean isEmpty()
           
 Set<K> keySet()
           
 void printDebugStats()
           
 V put(K key, V value)
           
 void putAll(Map<? extends K,? extends V> map)
           
 V remove(Object key)
           
 int size()
           
 Collection<V> values()
           
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

FastCopyHashMap

public FastCopyHashMap(int initialCapacity,
                       float loadFactor)

FastCopyHashMap

public FastCopyHashMap(Map<? extends K,? extends V> map)

FastCopyHashMap

public FastCopyHashMap(int initialCapacity)

FastCopyHashMap

public FastCopyHashMap()
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>

get

public V get(Object key)
Specified by:
get in interface Map<K,V>
Overrides:
get 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>

put

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

putAll

public void putAll(Map<? extends K,? extends V> map)
Specified by:
putAll in interface Map<K,V>
Overrides:
putAll 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>

clone

public Object clone()
Overrides:
clone in class AbstractMap<K,V>

printDebugStats

public void printDebugStats()

entrySet

public Set<Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface Map<K,V>
Specified by:
entrySet 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>


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.