org.jruby.util
Class WeakIdentityHashMap

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

public class WeakIdentityHashMap
extends java.lang.Object
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
protected  int 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
 boolean containsValue(java.lang.Object value)
          return the element with the given key
protected  java.util.Iterator entryIterator()
           
 java.util.Set entrySet()
           
 boolean equals(java.lang.Object other)
           
 java.lang.Object get(java.lang.Object key)
          return the element with the given key
 int hashCode()
           
 boolean isEmpty()
           
protected  boolean keyEquals(java.lang.Object key1, java.lang.Object key2)
           
protected  int keyHash(java.lang.Object key)
           
protected  java.util.Iterator keyIterator()
           
 java.util.Set keySet()
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 void putAll(java.util.Map other)
           
 java.lang.Object remove(int hash, java.lang.Object key)
           
 java.lang.Object remove(java.lang.Object key)
           
 int size()
           
protected  boolean valueEquals(java.lang.Object value1, java.lang.Object value2)
           
protected  int valueHash(java.lang.Object value)
           
protected  java.util.Iterator valueIterator()
           
protected  void valueRemoved(java.lang.Object value)
           
 java.util.Collection 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
 

Field Detail

size

protected int size
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

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

keyHash

protected final int keyHash(java.lang.Object key)

keyEquals

protected final boolean keyEquals(java.lang.Object key1,
                                  java.lang.Object key2)

size

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

isEmpty

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

valueHash

protected int valueHash(java.lang.Object value)

valueEquals

protected boolean valueEquals(java.lang.Object value1,
                              java.lang.Object value2)

putAll

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

keyIterator

protected java.util.Iterator keyIterator()

valueIterator

protected java.util.Iterator valueIterator()

values

public java.util.Collection values()
Specified by:
values in interface java.util.Map

keySet

public java.util.Set keySet()
Specified by:
keySet in interface java.util.Map

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Specified by:
equals in interface java.util.Map
Overrides:
equals in class java.lang.Object

entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map

containsValue

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

Specified by:
containsValue in interface java.util.Map


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