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

WeakSet (Utilities API) - NetBeans API Javadoc (Current Development Version)

org.openide.util 7.9.0 1

org.openide.util
Class WeakSet<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by org.openide.util.WeakSet<E>
All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, Set<E>

public class WeakSet<E>
extends AbstractSet<E>
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<? extends E> 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(E 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<E> 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()
           
<T> T[]
toArray(T[] 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<? extends E> 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(E o)
Adds the specified element to this set if it is not already present.

Specified by:
add in interface Collection<E>
Specified by:
add in interface Set<E>
Overrides:
add in class AbstractCollection<E>
Parameters:
o - an Object to add

clear

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

Specified by:
clear in interface Collection<E>
Specified by:
clear in interface Set<E>
Overrides:
clear in class AbstractCollection<E>

clone

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

Overrides:
clone in class Object

contains

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

Specified by:
contains in interface Collection<E>
Specified by:
contains in interface Set<E>
Overrides:
contains in class AbstractCollection<E>
Parameters:
o - an Object to examine

isEmpty

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

Specified by:
isEmpty in interface Collection<E>
Specified by:
isEmpty in interface Set<E>
Overrides:
isEmpty in class AbstractCollection<E>

iterator

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

Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface Set<E>
Specified by:
iterator in class AbstractCollection<E>

remove

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

Specified by:
remove in interface Collection<E>
Specified by:
remove in interface Set<E>
Overrides:
remove in class AbstractCollection<E>
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 Collection<E>
Specified by:
size in interface Set<E>
Specified by:
size in class AbstractCollection<E>
Returns:
the number of elements in this set (its cardinality).

toArray

public <T> T[] toArray(T[] array)
Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface Set<E>
Overrides:
toArray in class AbstractCollection<E>

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface Set<E>
Overrides:
toArray in class AbstractCollection<E>

toString

public String toString()
Overrides:
toString in class AbstractCollection<E>

org.openide.util 7.9.0 1

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