public class WeakIdentityCollection extends Object implements Collection
WeakIdentityCollection implements a Collection with weak values.
 Equality of elements is tested using the == operator.
 
 This collection does not hide the fact that the garbage collector will remove
 a mapping at some point in time. Thus, the Iterator returned
 by this collection might return null values. The same applies
 to the method toArray() in both its variants.
| Constructor and Description | 
|---|
| WeakIdentityCollection(int initialCapacity)Creates a new WeakIdentityCollection. | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | add(Object o)Adds object  oto this collection. | 
| boolean | addAll(Collection c) | 
| void | clear()Releases all references held by this collection. | 
| boolean | contains(Object o)Returns  trueif this collection containso. | 
| boolean | containsAll(Collection c) | 
| boolean | isEmpty()Returns  trueif this collection is empty. | 
| Iterator | iterator()Returns an  Iteratorover the elements of this
 collection. | 
| boolean | remove(Object o)Removes the object  ofrom this collection if it is present. | 
| boolean | removeAll(Collection c) | 
| boolean | retainAll(Collection c) | 
| int | size()Returns the current size of this collection. | 
| Object[] | toArray()Returns an array containing all of the elements in this collection. | 
| Object[] | toArray(Object[] a)The returned array may contain  nullelements! | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitequals, hashCode, parallelStream, removeIf, spliterator, streampublic WeakIdentityCollection(int initialCapacity)
initialCapacity - the initial capacity.public int size()
size in interface Collectionpublic boolean isEmpty()
true if this collection is empty.isEmpty in interface Collectiontrue if this collection is empty.public void clear()
clear in interface Collectionpublic boolean add(Object o)
o to this collection.add in interface Collectiono - the object to add.true as this collection allows duplicates.NullPointerException - if o is null.public boolean contains(Object o)
true if this collection contains o.contains in interface Collectiono - element whose presence in this collection is to be tested.true if this collection contains the specified
         elementpublic boolean remove(Object o)
o from this collection if it is present.remove in interface Collectiono - the object to remove.true if this collection changed as a result of the
         call.public boolean addAll(Collection c)
addAll in interface CollectionUnsupportedOperationException - always.public boolean containsAll(Collection c)
containsAll in interface CollectionUnsupportedOperationException - always.public boolean removeAll(Collection c)
removeAll in interface CollectionUnsupportedOperationException - always.public boolean retainAll(Collection c)
retainAll in interface CollectionUnsupportedOperationException - always.public Iterator iterator()
Iterator over the elements of this
 collection. The returned iterator is not fail-fast. That is, it does
 not throw a ConcurrentModificationException if this
 collection is modified while iterating over the collection.iterator in interface Iterableiterator in interface CollectionIterator over the elements of this
         collection.public Object[] toArray()
null elements!toArray in interface Collectionpublic Object[] toArray(Object[] a)
null elements!
 toArray in interface CollectionCopyright © 2004–2022 The Apache Software Foundation. All rights reserved.