org.graffiti.util
Class ConcatCollection<T>

java.lang.Object
  extended by java.util.AbstractCollection<T>
      extended by org.graffiti.util.ConcatCollection<T>
Type Parameters:
T - The type of the elements contained in the collection. Must be a supertype of all of the element types of the underlying collections.
All Implemented Interfaces:
Iterable<T>, Collection<T>

public class ConcatCollection<T>
extends AbstractCollection<T>
implements Collection<T>

A wrapper that encapsulates a series of collections as one collection. All methods directly operate on the underlying collections, such that changes in the underlying collections are reflected immediately. No caching is done. This also means that any operation on the concatenated collection has the same complexity as the sum of the respective complexities of the underlying collections.

The remove(Object) is supported and removes the given object from one of the underlying collections (if contained in any). The AbstractCollection.add(Object) method, however, is not supported. This is because the underlying collections are allowed to be parameterized with a subtype of T.

Version:
$Revision: 5767 $ $Date: 2006-01-13 11:54:43 +0100 (Fr, 13 Jan 2006) $
Author:
Michael Forster

Constructor Summary
ConcatCollection(Collection<? extends Collection<? extends T>> collections)
          Constructs a new collection from the concatenation of the given collections.
ConcatCollection(Collection<? extends T>... collections)
          Constructs a new collection from the concatenation of the given collections.
 
Method Summary
 void clear()
           
 boolean contains(Object o)
           
 boolean isEmpty()
           
 Iterator<T> iterator()
           
 boolean remove(Object o)
           
 int size()
           
 
Methods inherited from class java.util.AbstractCollection
add, addAll, containsAll, removeAll, retainAll, toArray, toArray, 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
add, addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
 

Constructor Detail

ConcatCollection

public ConcatCollection(Collection<? extends T>... collections)
Constructs a new collection from the concatenation of the given collections.

Parameters:
collections - The collections to be concatenated.

ConcatCollection

public ConcatCollection(Collection<? extends Collection<? extends T>> collections)
Constructs a new collection from the concatenation of the given collections.

Parameters:
collections - The collections to be concatenated.
Method Detail

clear

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

contains

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

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<T>
Overrides:
isEmpty in class AbstractCollection<T>

iterator

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

remove

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

size

public int size()
Specified by:
size in interface Collection<T>
Specified by:
size in class AbstractCollection<T>


Generated at 2012-05-30 11:00:36 PM CEST