E - elements typepublic class WeakHashSet<E> extends AbstractSet<E>
Set implementation that keeps only WeakReferences to all of its objects.
WeakHashSet is a simple decorator that is backed by WeakHashMap implementation.| Modifier and Type | Field and Description |
|---|---|
protected Set<E> |
keySet
Set of keys. |
protected WeakHashMap<E,Boolean> |
map
WeakHashMap that backs this WeakHashSet. |
| Constructor and Description |
|---|
WeakHashSet()
Constructs new
WeakHashSet with default initial capacity. |
WeakHashSet(int initialCapacity)
Constructs new
WeakHashSet with specified initial capacity. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
boolean |
equals(Object o) |
int |
hashCode() |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
String |
toString() |
addAllclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddAll, spliteratorparallelStream, removeIf, stream@NotNull protected final WeakHashMap<E,Boolean> map
WeakHashMap that backs this WeakHashSet.public WeakHashSet()
WeakHashSet with default initial capacity.public WeakHashSet(int initialCapacity)
WeakHashSet with specified initial capacity.initialCapacity - initial capacitypublic 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(@Nullable Object o)
contains in interface Collection<E>contains in interface Set<E>contains in class AbstractCollection<E>public boolean remove(@Nullable Object o)
remove in interface Collection<E>remove in interface Set<E>remove in class AbstractCollection<E>public boolean add(@Nullable E e)
add in interface Collection<E>add in interface Set<E>add in class AbstractCollection<E>@NotNull public Object[] toArray()
toArray in interface Collection<E>toArray in interface Set<E>toArray in class AbstractCollection<E>@NotNull public <T> T[] toArray(@NotNull T[] a)
toArray in interface Collection<E>toArray in interface Set<E>toArray in class AbstractCollection<E>public boolean containsAll(@NotNull Collection<?> c)
containsAll in interface Collection<E>containsAll in interface Set<E>containsAll in class AbstractCollection<E>public boolean removeAll(@NotNull Collection<?> c)
removeAll in interface Collection<E>removeAll in interface Set<E>removeAll in class AbstractSet<E>public boolean retainAll(@NotNull Collection<?> c)
retainAll in interface Collection<E>retainAll in interface Set<E>retainAll 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(@Nullable Object o)
equals in interface Collection<E>equals in interface Set<E>equals in class AbstractSet<E>@NotNull public String toString()
toString in class AbstractCollection<E>Copyright © 2020. All rights reserved.