Package org.apache.jackrabbit.util
Class WeakIdentityCollection
- java.lang.Object
-
- org.apache.jackrabbit.util.WeakIdentityCollection
-
- All Implemented Interfaces:
java.lang.Iterable
,java.util.Collection
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 returnnull
values. The same applies to the methodtoArray()
in both its variants.
-
-
Constructor Summary
Constructors Constructor Description WeakIdentityCollection(int initialCapacity)
Creates a new WeakIdentityCollection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(java.lang.Object o)
Adds objecto
to this collection.boolean
addAll(java.util.Collection c)
void
clear()
Releases all references held by this collection.boolean
contains(java.lang.Object o)
Returnstrue
if this collection containso
.boolean
containsAll(java.util.Collection c)
boolean
isEmpty()
Returnstrue
if this collection is empty.java.util.Iterator
iterator()
Returns anIterator
over the elements of this collection.boolean
remove(java.lang.Object o)
Removes the objecto
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 containnull
elements!-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Method Detail
-
size
public int size()
Returns the current size of this collection.- Specified by:
size
in interfacejava.util.Collection
- Returns:
- the current size of this collection.
-
isEmpty
public boolean isEmpty()
Returnstrue
if this collection is empty.- Specified by:
isEmpty
in interfacejava.util.Collection
- Returns:
true
if this collection is empty.
-
clear
public void clear()
Releases all references held by this collection.- Specified by:
clear
in interfacejava.util.Collection
-
add
public boolean add(java.lang.Object o)
Adds objecto
to this collection.- Specified by:
add
in interfacejava.util.Collection
- Parameters:
o
- the object to add.- Returns:
- always
true
as this collection allows duplicates. - Throws:
java.lang.NullPointerException
- ifo
isnull
.
-
contains
public boolean contains(java.lang.Object o)
Returnstrue
if this collection containso
.- Specified by:
contains
in interfacejava.util.Collection
- Parameters:
o
- element whose presence in this collection is to be tested.- Returns:
true
if this collection contains the specified element
-
remove
public boolean remove(java.lang.Object o)
Removes the objecto
from this collection if it is present.- Specified by:
remove
in interfacejava.util.Collection
- Parameters:
o
- the object to remove.- Returns:
true
if this collection changed as a result of the call.
-
addAll
public boolean addAll(java.util.Collection c)
- Specified by:
addAll
in interfacejava.util.Collection
- Throws:
java.lang.UnsupportedOperationException
- always.
-
containsAll
public boolean containsAll(java.util.Collection c)
- Specified by:
containsAll
in interfacejava.util.Collection
- Throws:
java.lang.UnsupportedOperationException
- always.
-
removeAll
public boolean removeAll(java.util.Collection c)
- Specified by:
removeAll
in interfacejava.util.Collection
- Throws:
java.lang.UnsupportedOperationException
- always.
-
retainAll
public boolean retainAll(java.util.Collection c)
- Specified by:
retainAll
in interfacejava.util.Collection
- Throws:
java.lang.UnsupportedOperationException
- always.
-
iterator
public java.util.Iterator iterator()
Returns anIterator
over the elements of this collection. The returned iterator is not fail-fast. That is, it does not throw aConcurrentModificationException
if this collection is modified while iterating over the collection.- Specified by:
iterator
in interfacejava.util.Collection
- Specified by:
iterator
in interfacejava.lang.Iterable
- Returns:
- an
Iterator
over the elements of this collection.
-
toArray
public java.lang.Object[] toArray()
Returns an array containing all of the elements in this collection. The returned array may containnull
elements!- Specified by:
toArray
in interfacejava.util.Collection
- Returns:
- an array containing all of the elements in this collection.
-
toArray
public java.lang.Object[] toArray(java.lang.Object[] a)
The returned array may containnull
elements!- Specified by:
toArray
in interfacejava.util.Collection
-
-