Package org.apache.jackrabbit.util
Class WeakIdentityCollection
java.lang.Object
org.apache.jackrabbit.util.WeakIdentityCollection
- All Implemented Interfaces:
Iterable,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 Summary
ConstructorsConstructorDescriptionWeakIdentityCollection(int initialCapacity) Creates a new WeakIdentityCollection. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds objectoto this collection.booleanaddAll(Collection c) voidclear()Releases all references held by this collection.booleanReturnstrueif this collection containso.booleanbooleanisEmpty()Returnstrueif this collection is empty.iterator()Returns anIteratorover the elements of this collection.booleanRemoves the objectofrom this collection if it is present.booleanbooleanintsize()Returns the current size of this collection.Object[]toArray()Returns an array containing all of the elements in this collection.Object[]The returned array may containnullelements!Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Constructor Details
-
WeakIdentityCollection
public WeakIdentityCollection(int initialCapacity) Creates a new WeakIdentityCollection.- Parameters:
initialCapacity- the initial capacity.
-
-
Method Details
-
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
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
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
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
- Specified by:
addAllin interfaceCollection- Throws:
UnsupportedOperationException- always.
-
containsAll
- Specified by:
containsAllin interfaceCollection- Throws:
UnsupportedOperationException- always.
-
removeAll
- Specified by:
removeAllin interfaceCollection- Throws:
UnsupportedOperationException- always.
-
retainAll
- Specified by:
retainAllin interfaceCollection- Throws:
UnsupportedOperationException- always.
-
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
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
The returned array may containnullelements!- Specified by:
toArrayin interfaceCollection
-