org.jruby.util
Class WeakIdentityHashMap

java.lang.Object
  extended by org.jruby.util.GenericMap
      extended by org.jruby.util.WeakIdentityHashMap
All Implemented Interfaces:
java.util.Map

public class WeakIdentityHashMap
extends GenericMap
implements java.util.Map

Class WeakIdentityHashMap is a hash map that hashes objects based on System.identityHashMap, and holds weakly onto the key. This fails if values make reference to the keys!

Since:
1.0
Version:
2.0
Author:
Kresten Krab Thorup

Field Summary
 
Fields inherited from class org.jruby.util.GenericMap
size
 
Constructor Summary
WeakIdentityHashMap()
          the default and only constructor
WeakIdentityHashMap(int size)
           
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object key)
          return the element with the given key
protected  java.util.Iterator entryIterator()
           
 java.lang.Object get(java.lang.Object key)
          return the element with the given key
 boolean isEmpty()
           
protected  boolean keyEquals(java.lang.Object key1, java.lang.Object key2)
           
protected  int keyHash(java.lang.Object key)
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 java.lang.Object remove(int hash, java.lang.Object key)
           
 java.lang.Object remove(java.lang.Object key)
           
 int size()
           
protected  void valueRemoved(java.lang.Object value)
           
 
Methods inherited from class org.jruby.util.GenericMap
containsValue, entrySet, equals, hashCode, keyIterator, keySet, putAll, valueEquals, valueHash, valueIterator, values
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsValue, entrySet, equals, hashCode, keySet, putAll, values
 

Constructor Detail

WeakIdentityHashMap

public WeakIdentityHashMap()
the default and only constructor


WeakIdentityHashMap

public WeakIdentityHashMap(int size)
Method Detail

clear

public void clear()
Specified by:
clear in interface java.util.Map

get

public java.lang.Object get(java.lang.Object key)
return the element with the given key

Specified by:
get in interface java.util.Map

containsKey

public boolean containsKey(java.lang.Object key)
return the element with the given key

Specified by:
containsKey in interface java.util.Map
Overrides:
containsKey in class GenericMap

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Specified by:
put in interface java.util.Map

remove

public java.lang.Object remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map

remove

public java.lang.Object remove(int hash,
                               java.lang.Object key)

valueRemoved

protected void valueRemoved(java.lang.Object value)

entryIterator

protected java.util.Iterator entryIterator()
Specified by:
entryIterator in class GenericMap

keyHash

protected final int keyHash(java.lang.Object key)
Overrides:
keyHash in class GenericMap

keyEquals

protected final boolean keyEquals(java.lang.Object key1,
                                  java.lang.Object key2)
Overrides:
keyEquals in class GenericMap

size

public int size()
Specified by:
size in interface java.util.Map
Overrides:
size in class GenericMap

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map
Overrides:
isEmpty in class GenericMap


Copyright © 2002-2007 JRuby Team. All Rights Reserved.