Jadex 0.96-beta1

jadex.util.collection
Class WeakSet

java.lang.Object
  extended by java.util.AbstractCollection
      extended by java.util.AbstractSet
          extended by jadex.util.collection.WeakSet
All Implemented Interfaces:
Serializable, Iterable, Collection, Set

public class WeakSet
extends AbstractSet
implements Serializable

A weak set for entries that will be automatically removed when no references to them are existing any more.

See Also:
Serialized Form

Constructor Summary
WeakSet()
          Construct a WeakSet based on a HashSet.
 
Method Summary
 boolean add(Object obj)
          Add an element to the set.
 void clear()
          Removes all of the elements from this set.
 Object clone()
          Returns a shallow copy of this WeakSet instance: the elements themselves are not cloned.
 boolean contains(Object obj)
          Returns true if this set contains the specified element.
 boolean isEmpty()
          Returns true if this set contains no elements.
 Iterator iterator()
          Return an iteration over the elements in the set.
 boolean remove(Object obj)
          Removes the given element from this set if it is present.
 int size()
          Return the size of the set.
 Object[] toArray()
          Convert the set to an array.
 Object[] toArray(Object[] result)
          Convert the set to an array.
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, containsAll, retainAll
 

Constructor Detail

WeakSet

public WeakSet()
Construct a WeakSet based on a HashSet.

Method Detail

size

public int size()
Return the size of the set.

Specified by:
size in interface Collection
Specified by:
size in interface Set
Specified by:
size in class AbstractCollection
Returns:
The size of the set.

iterator

public Iterator iterator()
Return an iteration over the elements in the set.

Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface Set
Specified by:
iterator in class AbstractCollection
Returns:
An iteration over the elements in the set.

toArray

public Object[] toArray()
Convert the set to an array.

Specified by:
toArray in interface Collection
Specified by:
toArray in interface Set
Overrides:
toArray in class AbstractCollection

toArray

public Object[] toArray(Object[] result)
Convert the set to an array.

Specified by:
toArray in interface Collection
Specified by:
toArray in interface Set
Overrides:
toArray in class AbstractCollection

add

public boolean add(Object obj)
Add an element to the set.

Specified by:
add in interface Collection
Specified by:
add in interface Set
Overrides:
add in class AbstractCollection
Parameters:
obj - Element to add to the set.
Returns:
True if the element was added.

isEmpty

public boolean isEmpty()
Returns true if this set contains no elements.

Specified by:
isEmpty in interface Collection
Specified by:
isEmpty in interface Set
Overrides:
isEmpty in class AbstractCollection
Returns:
true if this set contains no elements.

contains

public boolean contains(Object obj)
Returns true if this set contains the specified element.

Specified by:
contains in interface Collection
Specified by:
contains in interface Set
Overrides:
contains in class AbstractCollection
Parameters:
obj - Element whose presence in this set is to be tested.
Returns:
true if this set contains the specified element.

remove

public boolean remove(Object obj)
Removes the given element from this set if it is present.

Specified by:
remove in interface Collection
Specified by:
remove in interface Set
Overrides:
remove in class AbstractCollection
Parameters:
obj - Object to be removed from this set, if present.
Returns:
true if the set contained the specified element.

clear

public void clear()
Removes all of the elements from this set.

Specified by:
clear in interface Collection
Specified by:
clear in interface Set
Overrides:
clear in class AbstractCollection

clone

public Object clone()
Returns a shallow copy of this WeakSet instance: the elements themselves are not cloned.

Overrides:
clone in class Object
Returns:
A shallow copy of this set.

Jadex 0.96-beta1

Submit a bug or feature
For further API reference and developer documentation, see the Jadex User Guide and the Jadex Tutorial. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, and working code examples.

Copyright (C) 2002-2007 Lars Braubach, Alexander Pokahr - University of Hamburg. Use is subject to license terms.