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:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>, java.util.SortedSet<E>

public class Set<E>
extends java.util.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(java.util.Collection<? extends E> c)
          Constructs a new set containing the elements in the specified collection, sorted according to the elements' natural order.
Set(java.util.Comparator<? super E> c)
          Constructs a new, empty set, sorted according to the specified comparator.
Set(java.util.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(java.util.Collection<? extends E> c)
           
 void clear()
           
 java.lang.Object clone()
           
 java.util.Comparator<? super E> comparator()
           
 boolean contains(java.lang.Object o)
           
 Set<E> difference(java.util.Collection<? extends E> c)
          Returns the difference of this Set and the specified Collection.
 boolean equals(java.util.Collection<? extends E> c)
          Checks if this Set and the specified Collection contain the same elements.
 E first()
           
 java.util.SortedSet<E> headSet(E toElement)
           
 Set<E> intersection(java.util.Collection<? extends E> c)
          Returns the intersection of this Set and the specified Collection.
 boolean isEmpty()
           
 java.util.Iterator<E> iterator()
           
 E last()
           
 boolean remove(java.lang.Object o)
           
 int size()
           
 java.util.SortedSet<E> subSet(E fromElement, E toElement)
           
 java.util.SortedSet<E> tailSet(E fromElement)
           
 Set<E> union(java.util.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(java.util.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(java.util.Comparator<? super E> c)
Constructs a new, empty set, sorted according to the specified comparator.


Set

public Set(java.util.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 java.util.Collection<E>
Specified by:
add in interface java.util.Set<E>
Overrides:
add in class java.util.TreeSet<E>

addAll

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

clear

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

clone

public java.lang.Object clone()
Overrides:
clone in class java.util.TreeSet<E>

comparator

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

contains

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

first

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

headSet

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

isEmpty

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

iterator

public java.util.Iterator<E> iterator()
Specified by:
iterator in interface java.lang.Iterable<E>
Specified by:
iterator in interface java.util.Collection<E>
Specified by:
iterator in interface java.util.Set<E>
Overrides:
iterator in class java.util.TreeSet<E>

last

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

remove

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

size

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

subSet

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

tailSet

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

union

public Set<E> union(java.util.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(java.util.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(java.util.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(java.util.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.