ewe.util
Class WeakSet

java.lang.Object
  extended byewe.util.WeakSet

public class WeakSet
extends Object

A weak set is an unordered collection of weak references to objects. Any object within this set is elligable for garbage collection if it is not pointed to by at least one non-weak reference.


Constructor Summary
WeakSet()
           
 
Method Summary
 void add(Object what)
          This adds a reference to the set.
 void clear()
          This removes all references in the set.
 boolean contains(Object who)
          Checks if an Object is contained in the Weak Set.
 int count()
          This counts the number of live references.
 Iterator entries()
          Get an Iterator to go through all the entries.
 Object find(ObjectFinder f)
          This finds an object in the reference list using the ObjectFinder.
 Object[] getRefs()
          This returns an array containing the references.
 boolean isEmpty()
          If this returns true - it indicates that there are definitely no entries.
 void remove(Object what)
          This removes a reference from the set if it is in it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Constructor Detail

WeakSet

public WeakSet()
Method Detail

add

public void add(Object what)
This adds a reference to the set. Adding null will be ignored and adding an object which is already in the set will be ignored.


remove

public void remove(Object what)
This removes a reference from the set if it is in it.


clear

public void clear()
This removes all references in the set.


getRefs

public Object[] getRefs()
This returns an array containing the references. NOTE THAT THERE MAY BE NULL REFERENCES IN THE ARRAY as between the time the number of items is determined and the array is allocated some items may have been removed.


find

public Object find(ObjectFinder f)
This finds an object in the reference list using the ObjectFinder. This has the advantage of not creating an array everytime you are looking for an object.


contains

public boolean contains(Object who)
Checks if an Object is contained in the Weak Set.

Returns:
true if the Object is in the set.

count

public int count()
This counts the number of live references. However this number may be reduced unpredictably.


isEmpty

public boolean isEmpty()
If this returns true - it indicates that there are definitely no entries. If it is false, it indicates that there MAY be some entries. This is a very fast method that does not check any live references.


entries

public Iterator entries()
Get an Iterator to go through all the entries. The iterator will not return a null reference when next() is called (unless hasNext() returns false).