ContactCenters
V. 0.9.9.

umontreal.iro.lecuyer.collections
Class MergedCollection<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by umontreal.iro.lecuyer.collections.MergedCollection<E>
Type Parameters:
E - the type of the elements in the merged collection.
All Implemented Interfaces:
Iterable<E>, Collection<E>
Direct Known Subclasses:
MergedList, MergedSet

public class MergedCollection<E>
extends AbstractCollection<E>

Represents a collection providing a view of two collections merged together. The merged collection contains the elements of collections col1 and col2, and its iterator traverses both collections. A merged collection is immutable, but any change to the inner collections is reflected on the merged collection.


Constructor Summary
MergedCollection(Collection<? extends E> col1, Collection<? extends E> col2)
          Constructs a collection merging collections col1 and col2.
 
Method Summary
 boolean contains(Object o)
           
 Collection<? extends E> getFirstCollection()
          Returns a reference to the first collection of this merged collection.
 Collection<? extends E> getSecondCollection()
          Returns a reference to the second collection of this merged collection.
 boolean isEmpty()
           
 Iterator<E> iterator()
           
 int size()
           
 
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, containsAll, remove, 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
equals, hashCode
 

Constructor Detail

MergedCollection

public MergedCollection(Collection<? extends E> col1,
                        Collection<? extends E> col2)
Constructs a collection merging collections col1 and col2.

Parameters:
col1 - the first collection.
col2 - the second collection.
Throws:
NullPointerException - if col1 or col2 are null.
Method Detail

getFirstCollection

public Collection<? extends E> getFirstCollection()
Returns a reference to the first collection of this merged collection.

Returns:
the first collection.

getSecondCollection

public Collection<? extends E> getSecondCollection()
Returns a reference to the second collection of this merged collection.

Returns:
the second collection.

contains

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

isEmpty

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

iterator

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

size

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

ContactCenters
V. 0.9.9.

To submit a bug or ask questions, send an e-mail to Richard Simard.