public class WeakIdentityCollection
extends java.lang.Object
implements java.util.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(java.lang.Object o)
Adds object
o to this collection. |
boolean |
addAll(java.util.Collection c) |
void |
clear()
Releases all references held by this collection.
|
boolean |
contains(java.lang.Object o)
Returns
true if this collection contains o . |
boolean |
containsAll(java.util.Collection c) |
boolean |
isEmpty()
Returns
true if this collection is empty. |
java.util.Iterator |
iterator()
Returns an
Iterator over the elements of this
collection. |
boolean |
remove(java.lang.Object o)
Removes the object
o from this collection if it is present. |
boolean |
removeAll(java.util.Collection c) |
boolean |
retainAll(java.util.Collection c) |
int |
size()
Returns the current size of this collection.
|
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this collection.
|
java.lang.Object[] |
toArray(java.lang.Object[] a)
The returned array may contain
null elements!
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public WeakIdentityCollection(int initialCapacity)
initialCapacity
- the initial capacity.public int size()
size
in interface java.util.Collection
public boolean isEmpty()
true
if this collection is empty.isEmpty
in interface java.util.Collection
true
if this collection is empty.public void clear()
clear
in interface java.util.Collection
public boolean add(java.lang.Object o)
o
to this collection.add
in interface java.util.Collection
o
- the object to add.true
as this collection allows duplicates.java.lang.NullPointerException
- if o
is null
.public boolean contains(java.lang.Object o)
true
if this collection contains o
.contains
in interface java.util.Collection
o
- element whose presence in this collection is to be tested.true
if this collection contains the specified
elementpublic boolean remove(java.lang.Object o)
o
from this collection if it is present.remove
in interface java.util.Collection
o
- the object to remove.true
if this collection changed as a result of the
call.public boolean addAll(java.util.Collection c)
addAll
in interface java.util.Collection
java.lang.UnsupportedOperationException
- always.public boolean containsAll(java.util.Collection c)
containsAll
in interface java.util.Collection
java.lang.UnsupportedOperationException
- always.public boolean removeAll(java.util.Collection c)
removeAll
in interface java.util.Collection
java.lang.UnsupportedOperationException
- always.public boolean retainAll(java.util.Collection c)
retainAll
in interface java.util.Collection
java.lang.UnsupportedOperationException
- always.public java.util.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 java.lang.Iterable
iterator
in interface java.util.Collection
Iterator
over the elements of this
collection.public java.lang.Object[] toArray()
null
elements!toArray
in interface java.util.Collection
public java.lang.Object[] toArray(java.lang.Object[] a)
null
elements!
toArray
in interface java.util.Collection
Copyright © 2010 - 2020 Adobe. All Rights Reserved