org.apache.jackrabbit.util
Class WeakIdentityCollection

java.lang.Object
  extended byorg.apache.jackrabbit.util.WeakIdentityCollection
All Implemented Interfaces:
Collection

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 Summary
WeakIdentityCollection(int initialCapacity)
          Creates a new WeakIdentityCollection.
 
Method Summary
 boolean add(Object o)
          Adds object o to this collection.
 boolean addAll(Collection c)
           
 void clear()
          Releases all references held by this collection.
 boolean contains(Object o)
          Returns true if this collection contains o.
 boolean containsAll(Collection c)
           
 boolean isEmpty()
          Returns true if this collection is empty.
 Iterator iterator()
          Returns an Iterator over the elements of this collection.
 boolean remove(Object o)
          Removes the object o from 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 null elements!
 
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
 

Constructor Detail

WeakIdentityCollection

public WeakIdentityCollection(int initialCapacity)
Creates a new WeakIdentityCollection.

Parameters:
initialCapacity - the initial capacity.
Method Detail

size

public int size()
Returns the current size of this collection.

Specified by:
size in interface Collection
Returns:
the current size of this collection.

isEmpty

public boolean isEmpty()
Returns true if this collection is empty.

Specified by:
isEmpty in interface Collection
Returns:
true if this collection is empty.

clear

public void clear()
Releases all references held by this collection.

Specified by:
clear in interface Collection

add

public boolean add(Object o)
Adds object o to this collection.

Specified by:
add in interface Collection
Parameters:
o - the object to add.
Returns:
always true as this collection allows duplicates.
Throws:
NullPointerException - if o is null.

contains

public boolean contains(Object o)
Returns true if this collection contains o.

Specified by:
contains in interface 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(Object o)
Removes the object o from this collection if it is present.

Specified by:
remove in interface Collection
Parameters:
o - the object to remove.
Returns:
true if this collection changed as a result of the call.

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface Collection
Throws:
UnsupportedOperationException - always.

containsAll

public boolean containsAll(Collection c)
Specified by:
containsAll in interface Collection
Throws:
UnsupportedOperationException - always.

removeAll

public boolean removeAll(Collection c)
Specified by:
removeAll in interface Collection
Throws:
UnsupportedOperationException - always.

retainAll

public boolean retainAll(Collection c)
Specified by:
retainAll in interface Collection
Throws:
UnsupportedOperationException - always.

iterator

public Iterator iterator()
Returns an 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.

Specified by:
iterator in interface Collection
Returns:
an Iterator over the elements of this collection.

toArray

public Object[] toArray()
Returns an array containing all of the elements in this collection. The returned array may contain null elements!

Specified by:
toArray in interface Collection
Returns:
an array containing all of the elements in this collection.

toArray

public Object[] toArray(Object[] a)
The returned array may contain null elements!

Specified by:
toArray in interface Collection


Copyright © 2004-2006 The Apache Software Foundation. All Rights Reserved.