fi.joensuu.cs.tra
Class Set<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by java.util.TreeSet<E>
              extended by fi.joensuu.cs.tra.Set<E>
All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, Set<E>, SortedSet<E>

public class Set<E>
extends TreeSet<E>

fi.joensuu.cs.tra.Set extends java.util.TreeSet with comparison methods.

See Also:
TreeSet, TreeMap, Serialized Form

Constructor Summary
Set()
          Constructs a new, empty set, sorted according to the elements' natural order.
Set(Collection<? extends E> c)
          Constructs a new set containing the elements in the specified collection, sorted according to the elements' natural order.
Set(Comparator<? super E> c)
          Constructs a new, empty set, sorted according to the specified comparator.
Set(SortedSet<E> s)
          Constructs a new set containing the same elements as the specified sorted set, sorted according to the same ordering.
 
Method Summary
 boolean add(E o)
           
 boolean addAll(Collection<? extends E> c)
           
 void clear()
           
 Object clone()
           
 Comparator<? super E> comparator()
           
 boolean contains(Object o)
           
 Set<E> difference(Collection<? extends E> c)
          Returns the difference of this Set and the specified Collection.
 boolean equals(Collection<? extends E> c)
          Checks if this Set and the specified Collection contain the same elements.
 E first()
           
 SortedSet<E> headSet(E toElement)
           
 Set<E> intersection(Collection<? extends E> c)
          Returns the intersection of this Set and the specified Collection.
 boolean isEmpty()
           
 Iterator<E> iterator()
           
 E last()
           
 boolean remove(Object o)
           
 int size()
           
 SortedSet<E> subSet(E fromElement, E toElement)
           
 SortedSet<E> tailSet(E fromElement)
           
 Set<E> union(Collection<? extends E> c)
          Returns the union of this Set and the specified Collection.
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
 

Constructor Detail

Set

public Set()
Constructs a new, empty set, sorted according to the elements' natural order.


Set

public Set(Collection<? extends E> c)
Constructs a new set containing the elements in the specified collection, sorted according to the elements' natural order.


Set

public Set(Comparator<? super E> c)
Constructs a new, empty set, sorted according to the specified comparator.


Set

public Set(SortedSet<E> s)
Constructs a new set containing the same elements as the specified sorted set, sorted according to the same ordering.

Method Detail

add

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

addAll

public boolean addAll(Collection<? extends E> c)
Specified by:
addAll in interface Collection<E>
Specified by:
addAll in interface Set<E>
Overrides:
addAll in class TreeSet<E>

clear

public void clear()
Specified by:
clear in interface Collection<E>
Specified by:
clear in interface Set<E>
Overrides:
clear in class TreeSet<E>

clone

public Object clone()
Overrides:
clone in class TreeSet<E>

comparator

public Comparator<? super E> comparator()
Specified by:
comparator in interface SortedSet<E>
Overrides:
comparator in class TreeSet<E>

contains

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

first

public E first()
Specified by:
first in interface SortedSet<E>
Overrides:
first in class TreeSet<E>

headSet

public SortedSet<E> headSet(E toElement)
Specified by:
headSet in interface SortedSet<E>
Overrides:
headSet in class TreeSet<E>

isEmpty

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

iterator

public Iterator<E> iterator()
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 TreeSet<E>

last

public E last()
Specified by:
last in interface SortedSet<E>
Overrides:
last in class TreeSet<E>

remove

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

size

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

subSet

public SortedSet<E> subSet(E fromElement,
                           E toElement)
Specified by:
subSet in interface SortedSet<E>
Overrides:
subSet in class TreeSet<E>

tailSet

public SortedSet<E> tailSet(E fromElement)
Specified by:
tailSet in interface SortedSet<E>
Overrides:
tailSet in class TreeSet<E>

union

public Set<E> union(Collection<? extends E> c)
Returns the union of this Set and the specified Collection.

Parameters:
c - the Collection to combine this Set with.
Returns:
a new Set containing the elements of both this Set and the specified Collection.

intersection

public Set<E> intersection(Collection<? extends E> c)
Returns the intersection of this Set and the specified Collection.

Parameters:
c - the Collection to intersect this Set with.
Returns:
a new Set containing the elements present in both this Set and the specified Collection.

difference

public Set<E> difference(Collection<? extends E> c)
Returns the difference of this Set and the specified Collection.

Parameters:
c - the Collection to subtract from this Set.
Returns:
a new Set containing the elements present in this Set but not in the specified Collection.

equals

public boolean equals(Collection<? extends E> c)
Checks if this Set and the specified Collection contain the same elements.

Parameters:
c - the Collection to compare this Set with.
Returns:
true if the specified collection contains the same elements as this Set, false otherwise.