站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 5.0.0

WeakSet (NetBeans Utilities API) - NetBeans API Javadoc 5.0.0

 

org.openide.util
Class WeakSet

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractSet
          extended byorg.openide.util.WeakSet
All Implemented Interfaces:
Cloneable, Collection, Serializable, Set

public class WeakSet
extends AbstractSet
implements Cloneable, Serializable

Set which holds its members by using of WeakReferences. MT level: unsafe.

Note: as of JDK 6.0 (b51), you can instead use

 Set<T> s = Collections.newSetFromMap(new WeakHashMap<T, Boolean>());
 

See Also:
Serialized Form

Constructor Summary
WeakSet()
          Constructs a new set.
WeakSet(Collection c)
          Constructs a new set containing the elements in the specified collection.
WeakSet(int initialCapacity)
          Constructs a new, empty set;
WeakSet(int initialCapacity, float loadFactor)
          Constructs a new, empty set;
 
Method Summary
 boolean add(Object o)
          Adds the specified element to this set if it is not already present.
 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 o)
          Returns true if this set contains the specified element.
 boolean isEmpty()
          Returns true if this set contains no elements.
 Iterator iterator()
          Returns an iterator over the elements in this set.
 boolean remove(Object o)
          Removes the given element from this set if it is present.
 int size()
           
 Object[] toArray()
           
 Object[] toArray(Object[] array)
           
 String toString()
           
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, containsAll, retainAll
 

Constructor Detail

WeakSet

public WeakSet()
Constructs a new set.


WeakSet

public WeakSet(Collection c)
Constructs a new set containing the elements in the specified collection.

Parameters:
c - a collection to add

WeakSet

public WeakSet(int initialCapacity)
Constructs a new, empty set;

Parameters:
initialCapacity - initial capacity

WeakSet

public WeakSet(int initialCapacity,
               float loadFactor)
Constructs a new, empty set;

Parameters:
initialCapacity - initial capacity
loadFactor - load factor
Method Detail

add

public boolean add(Object o)
Adds the specified element to this set if it is not already present.

Specified by:
add in interface Set
Parameters:
o - an Object to add

clear

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

Specified by:
clear in interface Set

clone

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


contains

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

Specified by:
contains in interface Set
Parameters:
o - an Object to examine

isEmpty

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

Specified by:
isEmpty in interface Set

iterator

public Iterator iterator()
Returns an iterator over the elements in this set.

Specified by:
iterator in interface Set

remove

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

Specified by:
remove in interface Set
Parameters:
o - an Object to remove
Returns:
true if and only if the Object was successfuly removed.

size

public int size()
Specified by:
size in interface Set
Returns:
the number of elements in this set (its cardinality).

toArray

public Object[] toArray(Object[] array)
Specified by:
toArray in interface Set

toArray

public Object[] toArray()
Specified by:
toArray in interface Set

toString

public String toString()

 

Built on May 3 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.