Xj3D VRML/X3D Code API

org.web3d.util
Class WeakValueHashMap

java.lang.Object
  extended byorg.web3d.util.WeakValueHashMap
All Implemented Interfaces:
java.util.Map

public class WeakValueHashMap
extends java.lang.Object
implements java.util.Map

An extension of HashMap which stored weak references to the values in the hash map.

Like it says in the documentation for WeakHashMap, this class breaks several immutability assumptions that are assumed for HashMap, since values will be disappearing at random.

Version:
$Revision: 1.2 $
Author:
Brad Vender

Nested Class Summary
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
WeakValueHashMap()
          Construct a new map of default size
WeakValueHashMap(int size)
          Construct a new map with specified starting size
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set entrySet()
           
 boolean equals(java.lang.Object o)
           
protected  void flushEmptyReferences()
          Check for and remove references from the map which have become cleared.
 java.lang.Object get(java.lang.Object key)
           
 int hashCode()
           
 boolean isEmpty()
           
 java.util.Set keySet()
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 void putAll(java.util.Map t)
           
 java.lang.Object remove(java.lang.Object key)
           
 int size()
           
 java.util.Collection values()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WeakValueHashMap

public WeakValueHashMap()
Construct a new map of default size


WeakValueHashMap

public WeakValueHashMap(int size)
Construct a new map with specified starting size

Parameters:
size -
Method Detail

clear

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

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map
See Also:
Map.containsKey(java.lang.Object)

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map
See Also:
Map.containsValue(java.lang.Object)

entrySet

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

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Map
See Also:
Object.equals(java.lang.Object)

flushEmptyReferences

protected void flushEmptyReferences()
Check for and remove references from the map which have become cleared.


get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface java.util.Map
See Also:
Weak references which have become clear are removed from the internal hash map before performing this request.

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map
See Also:
Object.hashCode()

isEmpty

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

keySet

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

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Specified by:
put in interface java.util.Map
See Also:
This method performs the necessary steps to check for cleared weak references, wrap incoming data in weak references, and unwrap the old value.

putAll

public void putAll(java.util.Map t)
Specified by:
putAll in interface java.util.Map
See Also:
Not supported

remove

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

size

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

values

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

Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium