|
org.openide.util 8.19.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractSet<E>
org.openide.util.WeakSet<E>
E - the type of elements maintained by this setpublic class WeakSet<E>
This class provides storage functionality with Weak-referenced entries and new method putIfAbsent. Set implementation is backed by a hash table. It also provides method resize for changing capacity of internal hash table (can be used for reducing memory occupied by empty set which previously had big number of objects, but they were GCed) Access to set is not thread safe.
putIfAbsent(Object),
resize(int),
Serialized Form| Constructor Summary | |
|---|---|
WeakSet()
Constructs a new, empty WeakSet with the default initial capacity (16) and load factor (0.75). |
|
WeakSet(Collection<? extends E> s)
Constructs a new WeakSet with the same mappings as the specified map. |
|
WeakSet(int initialCapacity)
Constructs a new, empty WeakSet with the given initial capacity and the default load factor (0.75). |
|
WeakSet(int initialCapacity,
float loadFactor)
Constructs a new, empty WeakSet with the given initial capacity and the given load factor. |
|
| Method Summary | ||
|---|---|---|
boolean |
add(E e)
|
|
void |
clear()
|
|
Object |
clone()
|
|
boolean |
contains(Object o)
|
|
boolean |
containsAll(Collection<?> c)
|
|
boolean |
equals(Object o)
|
|
int |
hashCode()
|
|
boolean |
isEmpty()
|
|
Iterator<E> |
iterator()
|
|
E |
putIfAbsent(E e)
Put object in this set if equal one is not yet in set. |
|
boolean |
remove(Object o)
|
|
boolean |
removeAll(Collection<?> c)
|
|
void |
resize(int newCapacity)
compact set if it is empty by setting new capacity |
|
boolean |
retainAll(Collection<?> c)
|
|
int |
size()
|
|
Object[] |
toArray()
|
|
|
toArray(T[] a)
|
|
String |
toString()
|
|
| Methods inherited from class java.util.AbstractCollection |
|---|
addAll |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Set |
|---|
addAll |
| Constructor Detail |
|---|
public WeakSet(int initialCapacity,
float loadFactor)
initialCapacity - The initial capacity of the WeakSetloadFactor - The load factor of the WeakSet
IllegalArgumentException - if the initial capacity is negative,
or if the load factor is nonpositive.public WeakSet(int initialCapacity)
initialCapacity - The initial capacity of the WeakSet
IllegalArgumentException - if the initial capacity is negativepublic WeakSet()
public WeakSet(Collection<? extends E> s)
s - the map whose mappings are to be placed in this map
NullPointerException - if the specified map is null| Method Detail |
|---|
public void clear()
clear in interface Collection<E>clear in interface Set<E>clear in class AbstractCollection<E>public int size()
size in interface Collection<E>size in interface Set<E>size in class AbstractCollection<E>public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in interface Set<E>isEmpty in class AbstractCollection<E>public boolean contains(Object o)
contains in interface Collection<E>contains in interface Set<E>contains in class AbstractCollection<E>public boolean remove(Object o)
remove in interface Collection<E>remove in interface Set<E>remove in class AbstractCollection<E>public void resize(int newCapacity)
newCapacity - new capacitypublic boolean add(E e)
add in interface Collection<E>add in interface Set<E>add in class AbstractCollection<E>putIfAbsent(E)public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in interface Set<E>iterator in class AbstractCollection<E>public Object[] toArray()
toArray in interface Collection<E>toArray in interface Set<E>toArray in class AbstractCollection<E>public <T> T[] toArray(T[] a)
toArray in interface Collection<E>toArray in interface Set<E>toArray in class AbstractCollection<E>public String toString()
toString in class AbstractCollection<E>public int hashCode()
hashCode in interface Collection<E>hashCode in interface Set<E>hashCode in class AbstractSet<E>public boolean equals(Object o)
equals in interface Collection<E>equals in interface Set<E>equals in class AbstractSet<E>public boolean containsAll(Collection<?> c)
containsAll in interface Collection<E>containsAll in interface Set<E>containsAll in class AbstractCollection<E>public boolean removeAll(Collection<?> c)
removeAll in interface Collection<E>removeAll in interface Set<E>removeAll in class AbstractSet<E>public boolean retainAll(Collection<?> c)
retainAll in interface Collection<E>retainAll in interface Set<E>retainAll in class AbstractCollection<E>public E putIfAbsent(E e)
WeakSet<MyClass> set = new WeakSet<MyClass>();
...
MyClass sharedValue = set.putIfAbsent(new MyClass("abc));
e - object to put in set.
public Object clone()
clone in class Object
|
org.openide.util 8.19.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||