Save This Page
Home » hibernate-search-src-20081106 » org.hibernate » search » util » [javadoc | source]
org.hibernate.search.util
public class: WeakIdentityHashMap [javadoc | source]
java.lang.Object
   org.hibernate.search.util.WeakIdentityHashMap

All Implemented Interfaces:
    Map

A hashtable-based Map implementation with weak keys and using reference-equality in place of object-equality when comparing keys (and values). In an WeakIdentityHashMap, two keys k1 and k2 are considered equal if and only if (k1==k2). An entry in a WeakIdentityHashMap will automatically be removed when its key is no longer in ordinary use. More precisely, the presence of a mapping for a given key will not prevent the key from being discarded by the garbage collector, that is, made finalizable, finalized, and then reclaimed. When a key has been discarded its entry is effectively removed from the map.

Based on java.util.WeakHashMap

Based on org.jboss.common.collection.WeakIdentityHashMap

Nested Class Summary:
static class  WeakIdentityHashMap.SimpleEntry   
Field Summary
transient volatile  Set keySet    Each of these fields are initialized to contain an instance of the appropriate view the first time this view is requested. The views are stateless, so there's no reason to create more than one of each. 
transient volatile  Collection values     
Constructor:
 public WeakIdentityHashMap() 
 public WeakIdentityHashMap(int initialCapacity) 
 public WeakIdentityHashMap(Map t) 
    Constructs a new WeakIdentityHashMap with the same mappings as the specified Map. The WeakIdentityHashMap is created with default load factor, which is 0.75 and an initial capacity sufficient to hold the mappings in the specified Map.
    Parameters:
    t - the map whose mappings are to be placed in this map.
    Throws:
    NullPointerException - if the specified map is null.
 public WeakIdentityHashMap(int initialCapacity,
    float loadFactor) 
Method from org.hibernate.search.util.WeakIdentityHashMap Summary:
clear,   containsKey,   containsValue,   entrySet,   get,   getEntry,   hash,   indexFor,   isEmpty,   keySet,   put,   putAll,   remove,   removeMapping,   removeValue,   resize,   size,   values
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.hibernate.search.util.WeakIdentityHashMap Detail:
 public  void clear() 
    Removes all mappings from this map.
 public boolean containsKey(Object key) 
    Returns true if this map contains a mapping for the specified key.
 public boolean containsValue(Object value) 
    Returns true if this map maps one or more keys to the specified value.
 public Set entrySet() 
    Returns a collection view of the mappings contained in this map. Each element in the returned collection is a Map.Entry. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.
 public V get(Object key) 
    Returns the value to which the specified key is mapped in this weak hash map, or null if the map contains no mapping for this key. A return value of null does not necessarily indicate that the map contains no mapping for the key; it is also possible that the map explicitly maps the key to null. The containsKey method may be used to distinguish these two cases.
 WeakIdentityHashMap.Entry getEntry(Object key) 
    Returns the entry associated with the specified key in the HashMap. Returns null if the HashMap contains no mapping for this key.
 int hash(Object x) 
    Return a hash code for non-null Object x.
 static int indexFor(int h,
    int length) 
    Return index for hash code h.
 public boolean isEmpty() 
    Returns true if this map contains no key-value mappings. This result is a snapshot, and may not reflect unprocessed entries that will be removed before next attempted access because they are no longer referenced.
 public Set keySet() 
    Returns a set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. The set supports element removal, which removes the corresponding mapping from this map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.
 public V put(K key,
    V value) 
    Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced.
 public  void putAll(Map t) 
    Copies all of the mappings from the specified map to this map These mappings will replace any mappings that this map had for any of the keys currently in the specified map.

 public V remove(Object key) 
    Removes the mapping for this key from this map if present.
 WeakIdentityHashMap.Entry removeMapping(Object o) 
    Special version of remove needed by Entry set
 public boolean removeValue(Object value) 
    Remove elements having the according value. Intended to avoid concurrent access exceptions It is expected that nobody add a key being removed by value
  void resize(int newCapacity) 
    Rehashes the contents of this map into a new HashMap instance with a larger capacity. This method is called automatically when the number of keys in this map exceeds its capacity and load factor.

    Note that this method is a no-op if it's called with newCapacity == 2*MAXIMUM_CAPACITY (which is Integer.MIN_VALUE).

 public int size() 
    Returns the number of key-value mappings in this map. This result is a snapshot, and may not reflect unprocessed entries that will be removed before next attempted access because they are no longer referenced.
 public Collection values() 
    Returns a collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. The collection supports element removal, which removes the corresponding mapping from this map, via the Iterator.remove, Collection.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.