edu.emory.mathcs.util.collections
Class CollectionUtils

java.lang.Object
  extended byedu.emory.mathcs.util.collections.CollectionUtils

public class CollectionUtils
extends java.lang.Object

Collection utility methods.

Author:
Dawid Kurzyniec

Method Summary
 java.util.Map weakValueMap(java.util.Map t)
          Returns the map wrapped so that it refers to the values via weak references, thus not keeping them from garbage collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

weakValueMap

public java.util.Map weakValueMap(java.util.Map t)
Returns the map wrapped so that it refers to the values via weak references, thus not keeping them from garbage collection. After a value becomes unreferenced and collected, all the corresponding map entries are removed. (The cleanup is not asynchronous but piggybacks on other map operations).

Iteration order of the returned wrapper map, and the overall performance characterictics, are the same as those of the backing map.

It is required that the specified map is empty, and that it is not used directly after this method returns.

Note: the values stored in this map keep strong references to their keys. Therefore, using a WeakHashMap as a backing map will NOT yield a map with both weak keys and weak values.