edu.rice.cs.plt.collect
Class DelegatingCollection<T>

java.lang.Object
  extended by java.util.AbstractCollection<T>
      extended by edu.rice.cs.plt.collect.DelegatingCollection<T>
All Implemented Interfaces:
SizedIterable<T>, Composite, java.io.Serializable, java.lang.Iterable<T>, java.util.Collection<T>
Direct Known Subclasses:
DelegatingList, DelegatingSet

public class DelegatingCollection<T>
extends java.util.AbstractCollection<T>
implements SizedIterable<T>, Composite, java.io.Serializable

A collection that delegates all operations to a wrapped collection. Subclasses can be defined that override a few of the methods, while maintaining the default delegation behavior in most cases. Since instances of this class must not be equal to some collections (such as Sets and Lists -- allowing the equivalence would violate symmetry), the equals() and hashCode() methods are not implemented, and inherit the Object defaults. Subclasses can also invoke the overridden methods in AbstractCollection to use the default implementations there by invoking, for example, abstractCollectionAddAll(java.util.Collection) (see AbstractCollection for details on the default implementations).

See Also:
Serialized Form

Field Summary
protected  java.util.Collection<T> _delegate
           
 
Constructor Summary
DelegatingCollection(java.util.Collection<T> delegate)
           
 
Method Summary
protected  boolean abstractCollectionAddAll(java.util.Collection<? extends T> c)
           
protected  void abstractCollectionClear()
           
protected  boolean abstractCollectionContains(java.lang.Object o)
           
protected  boolean abstractCollectionContainsAll(java.util.Collection<?> c)
           
protected  boolean abstractCollectionIsEmpty()
           
protected  boolean abstractCollectionRemove(T o)
           
protected  boolean abstractCollectionRemoveAll(java.util.Collection<?> c)
           
protected  boolean abstractCollectionRetainAll(java.util.Collection<?> c)
           
protected  java.lang.Object[] abstractCollectionToArray()
           
protected
<S> S[]
abstractCollectionToArray(S[] a)
           
 boolean add(T o)
           
 boolean addAll(java.util.Collection<? extends T> c)
           
 void clear()
           
 int compositeHeight()
          Get the maximum path length from this node to a leaf.
 int compositeSize()
          Get the number of nodes in the tree rooted at this node.
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection<?> c)
           
 boolean hasFixedSize()
          true if this iterable is known to have a fixed size.
 boolean isEmpty()
          Whether the iterable does not contain any elements.
 boolean isInfinite()
          true if the iterable is known to have infinite size.
 boolean isStatic()
          true if this iterable is unchanging.
 java.util.Iterator<T> iterator()
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection<?> c)
           
 boolean retainAll(java.util.Collection<?> c)
           
 int size()
          Compute the number of elements in the iterable.
 int size(int bound)
          Compute the number of elements in the iterable, up to the given bound.
 java.lang.Object[] toArray()
           
<S> S[]
toArray(S[] a)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Field Detail

_delegate

protected java.util.Collection<T> _delegate
Constructor Detail

DelegatingCollection

public DelegatingCollection(java.util.Collection<T> delegate)
Method Detail

compositeHeight

public int compositeHeight()
Description copied from interface: Composite
Get the maximum path length from this node to a leaf.

Specified by:
compositeHeight in interface Composite

compositeSize

public int compositeSize()
Description copied from interface: Composite
Get the number of nodes in the tree rooted at this node. Always 1 or greater.

Specified by:
compositeSize in interface Composite

isEmpty

public boolean isEmpty()
Description copied from interface: SizedIterable
Whether the iterable does not contain any elements.

Specified by:
isEmpty in interface SizedIterable<T>
Specified by:
isEmpty in interface java.util.Collection<T>
Overrides:
isEmpty in class java.util.AbstractCollection<T>

size

public int size()
Description copied from interface: SizedIterable
Compute the number of elements in the iterable. If the size is infinite or too large to be represented as an int, Integer.MAX_VALUE should be returned. Otherwise, next() may be safely invoked on the iterator exactly this number of times.

Specified by:
size in interface SizedIterable<T>
Specified by:
size in interface java.util.Collection<T>
Specified by:
size in class java.util.AbstractCollection<T>

size

public int size(int bound)
Description copied from interface: SizedIterable
Compute the number of elements in the iterable, up to the given bound. If the size is infinite or greater than bound, bound is returned.

Specified by:
size in interface SizedIterable<T>
Parameters:
bound - Maximum result. Assumed to be nonnegative.

isInfinite

public boolean isInfinite()
Description copied from interface: SizedIterable
true if the iterable is known to have infinite size. If true, an iterator over the iterable in its current state will never return false from hasNext().

Specified by:
isInfinite in interface SizedIterable<T>

hasFixedSize

public boolean hasFixedSize()
Description copied from interface: SizedIterable
true if this iterable is known to have a fixed size. This is the case if the iterable is immutable, or if changes can only replace values, not remove or add them. An infinite iterable may be fixed if it is guaranteed to never become finite.

Specified by:
hasFixedSize in interface SizedIterable<T>

isStatic

public boolean isStatic()
Description copied from interface: SizedIterable
true if this iterable is unchanging. This implies that hasFixedSize() is true, and that iterator() will always return the same (either == or equal() and immutable) elements in the same order. ("Immutable" here means that equals() invocations are consistent over time -- if two objects are equal, they will never become inequal, and vice versa.)

Specified by:
isStatic in interface SizedIterable<T>

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection<T>
Overrides:
contains in class java.util.AbstractCollection<T>

containsAll

public boolean containsAll(java.util.Collection<?> c)
Specified by:
containsAll in interface java.util.Collection<T>
Overrides:
containsAll in class java.util.AbstractCollection<T>

iterator

public java.util.Iterator<T> iterator()
Specified by:
iterator in interface java.lang.Iterable<T>
Specified by:
iterator in interface java.util.Collection<T>
Specified by:
iterator in class java.util.AbstractCollection<T>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<T>
Overrides:
toArray in class java.util.AbstractCollection<T>

toArray

public <S> S[] toArray(S[] a)
Specified by:
toArray in interface java.util.Collection<T>
Overrides:
toArray in class java.util.AbstractCollection<T>

add

public boolean add(T o)
Specified by:
add in interface java.util.Collection<T>
Overrides:
add in class java.util.AbstractCollection<T>

addAll

public boolean addAll(java.util.Collection<? extends T> c)
Specified by:
addAll in interface java.util.Collection<T>
Overrides:
addAll in class java.util.AbstractCollection<T>

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection<T>
Overrides:
remove in class java.util.AbstractCollection<T>

retainAll

public boolean retainAll(java.util.Collection<?> c)
Specified by:
retainAll in interface java.util.Collection<T>
Overrides:
retainAll in class java.util.AbstractCollection<T>

removeAll

public boolean removeAll(java.util.Collection<?> c)
Specified by:
removeAll in interface java.util.Collection<T>
Overrides:
removeAll in class java.util.AbstractCollection<T>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<T>
Overrides:
clear in class java.util.AbstractCollection<T>

toString

public java.lang.String toString()
Overrides:
toString in class java.util.AbstractCollection<T>

abstractCollectionIsEmpty

protected boolean abstractCollectionIsEmpty()

abstractCollectionContains

protected boolean abstractCollectionContains(java.lang.Object o)

abstractCollectionToArray

protected java.lang.Object[] abstractCollectionToArray()

abstractCollectionToArray

protected <S> S[] abstractCollectionToArray(S[] a)

abstractCollectionRemove

protected boolean abstractCollectionRemove(T o)

abstractCollectionContainsAll

protected boolean abstractCollectionContainsAll(java.util.Collection<?> c)

abstractCollectionAddAll

protected boolean abstractCollectionAddAll(java.util.Collection<? extends T> c)

abstractCollectionRetainAll

protected boolean abstractCollectionRetainAll(java.util.Collection<?> c)

abstractCollectionRemoveAll

protected boolean abstractCollectionRemoveAll(java.util.Collection<?> c)

abstractCollectionClear

protected void abstractCollectionClear()