Package org.apache.jackrabbit.util
Class WeakIdentityCollection
- java.lang.Object
-
- org.apache.jackrabbit.util.WeakIdentityCollection
-
- All Implemented Interfaces:
Iterable,Collection
public class WeakIdentityCollection extends Object implements Collection
WeakIdentityCollectionimplements 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
Iteratorreturned by this collection might returnnullvalues. 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 booleanadd(Object o)Adds objectoto this collection.booleanaddAll(Collection c)voidclear()Releases all references held by this collection.booleancontains(Object o)Returnstrueif this collection containso.booleancontainsAll(Collection c)booleanisEmpty()Returnstrueif this collection is empty.Iteratoriterator()Returns anIteratorover the elements of this collection.booleanremove(Object o)Removes the objectofrom this collection if it is present.booleanremoveAll(Collection c)booleanretainAll(Collection c)intsize()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 containnullelements!-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
Method Detail
-
size
public int size()
Returns the current size of this collection.- Specified by:
sizein interfaceCollection- Returns:
- the current size of this collection.
-
isEmpty
public boolean isEmpty()
Returnstrueif this collection is empty.- Specified by:
isEmptyin interfaceCollection- Returns:
trueif this collection is empty.
-
clear
public void clear()
Releases all references held by this collection.- Specified by:
clearin interfaceCollection
-
add
public boolean add(Object o)
Adds objectoto this collection.- Specified by:
addin interfaceCollection- Parameters:
o- the object to add.- Returns:
- always
trueas this collection allows duplicates. - Throws:
NullPointerException- ifoisnull.
-
contains
public boolean contains(Object o)
Returnstrueif this collection containso.- Specified by:
containsin interfaceCollection- Parameters:
o- element whose presence in this collection is to be tested.- Returns:
trueif this collection contains the specified element
-
remove
public boolean remove(Object o)
Removes the objectofrom this collection if it is present.- Specified by:
removein interfaceCollection- Parameters:
o- the object to remove.- Returns:
trueif this collection changed as a result of the call.
-
addAll
public boolean addAll(Collection c)
- Specified by:
addAllin interfaceCollection- Throws:
UnsupportedOperationException- always.
-
containsAll
public boolean containsAll(Collection c)
- Specified by:
containsAllin interfaceCollection- Throws:
UnsupportedOperationException- always.
-
removeAll
public boolean removeAll(Collection c)
- Specified by:
removeAllin interfaceCollection- Throws:
UnsupportedOperationException- always.
-
retainAll
public boolean retainAll(Collection c)
- Specified by:
retainAllin interfaceCollection- Throws:
UnsupportedOperationException- always.
-
iterator
public Iterator iterator()
Returns anIteratorover the elements of this collection. The returned iterator is not fail-fast. That is, it does not throw aConcurrentModificationExceptionif this collection is modified while iterating over the collection.- Specified by:
iteratorin interfaceCollection- Specified by:
iteratorin interfaceIterable- Returns:
- an
Iteratorover the elements of this collection.
-
toArray
public Object[] toArray()
Returns an array containing all of the elements in this collection. The returned array may containnullelements!- Specified by:
toArrayin interfaceCollection- Returns:
- an array containing all of the elements in this collection.
-
toArray
public Object[] toArray(Object[] a)
The returned array may containnullelements!- Specified by:
toArrayin interfaceCollection
-
-