ContactCenters
V. 0.9.9.

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

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

public class MergedSet<E>
extends MergedCollection<E>
implements Set<E>

Represents a set providing a view of two sets. This extends the merged collection for implementing the Set interface.


Constructor Summary
MergedSet(Set<? extends E> set1, Set<? extends E> set2)
          Constructs a set merging sets set1 and set2.
 
Method Summary
 boolean equals(Object o)
           
 Set<? extends E> getFirstCollection()
          Returns a reference to the first set of this merged set.
 Set<? extends E> getSecondCollection()
          Returns a reference to the second set of this merged set.
 int hashCode()
           
 Iterator<E> iterator()
          Constructs and returns an iterator for the merged set.
 int size()
           
 
Methods inherited from class umontreal.iro.lecuyer.collections.MergedCollection
contains, isEmpty
 
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, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

MergedSet

public MergedSet(Set<? extends E> set1,
                 Set<? extends E> set2)
Constructs a set merging sets set1 and set2.

Parameters:
set1 - the first set.
set2 - the second set.
Throws:
NullPointerException - if set1 or set2 are null.
Method Detail

getFirstCollection

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

Overrides:
getFirstCollection in class MergedCollection<E>
Returns:
the first set.

getSecondCollection

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

Overrides:
getSecondCollection in class MergedCollection<E>
Returns:
the second set.

equals

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

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection<E>
Specified by:
hashCode in interface Set<E>
Overrides:
hashCode in class Object

iterator

public Iterator<E> iterator()
Constructs and returns an iterator for the merged set. The returned iterator enumerates all the elements in the first set, then it enumerates the elements of the second set not present in the first set.

Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface Set<E>
Overrides:
iterator in class MergedCollection<E>

size

public int size()
Specified by:
size in interface Collection<E>
Specified by:
size in interface Set<E>
Overrides:
size in class MergedCollection<E>

ContactCenters
V. 0.9.9.

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