edu.neu.ccs.quick
Class QuickTreeSet

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractSet
          extended byjava.util.TreeSet
              extended byedu.neu.ccs.quick.QuickTreeSet
All Implemented Interfaces:
Cloneable, Collection, Serializable, Set, SortedSet

public class QuickTreeSet
extends TreeSet

QuickTreeSet extends TreeSet by adding two constructors and three methods addItems, setItems, and removeItems that handle an array of Object at once.

All constructors of the original TreeSet class are provided as well.

No changes are made to the internal data structure.

The only inherited methods that are overridden are those that will throw an exception on null arguments. In this class, such methods will handle null in a sensible fashion.

Since:
2.3
Version:
2.3
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.TreeSet
 
Constructor Summary
QuickTreeSet()
          A constructor that delegates to class TreeSet.
QuickTreeSet(Collection c)
          A constructor that delegates to class TreeSet.
QuickTreeSet(Comparator c)
          A constructor that delegates to class TreeSet.
QuickTreeSet(Comparator c, Object[] items)
          Constructor that sets the Comparator and then adds the given array of items one-by-one to the tree set.
QuickTreeSet(Object[] items)
          Constructor that adds the given array of items one-by-one to the tree set.
QuickTreeSet(SortedSet s)
          A constructor that delegates to class TreeSet.
 
Method Summary
 boolean add(Object element)
          Adds the element to the set if it is not present.
 void addItems(Object[] items)
          Method that adds the given array of items one-by-one to the tree set.
 boolean contains(Object element)
          Returns true if the set contains the element.
 SortedSet headSet(Object element)
          Returns a view of the portion of this set whose elements are strictly less than the element.
 boolean remove(Object element)
          Removes the element from the set if it is present.
 void removeItems(Object[] items)
          Method that removes the given array of items one-by-one from the tree set.
 void setItems(Object[] items)
          Method that first clears this tree set of any existing items and then adds the given array of items one-by-one to the tree set.
 SortedSet subSet(Object lower, Object upper)
          Returns a view of the portion of this set whose elements are greater than or equal to the element lower and strictly less than the element upper.
 SortedSet tailSet(Object element)
          Returns a view of the portion of this set whose elements are greater than or equal to the element.
 
Methods inherited from class java.util.TreeSet
addAll, clear, clone, comparator, first, isEmpty, iterator, last, size
 
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

QuickTreeSet

public QuickTreeSet()
A constructor that delegates to class TreeSet.


QuickTreeSet

public QuickTreeSet(Collection c)
A constructor that delegates to class TreeSet.


QuickTreeSet

public QuickTreeSet(Comparator c)
A constructor that delegates to class TreeSet.


QuickTreeSet

public QuickTreeSet(SortedSet s)
A constructor that delegates to class TreeSet.


QuickTreeSet

public QuickTreeSet(Object[] items)

Constructor that adds the given array of items one-by-one to the tree set.

Parameters:
items - the array of items to add to this tree set
See Also:
addItems(Object[]), QuickTreeSet(Comparator, Object[])

QuickTreeSet

public QuickTreeSet(Comparator c,
                    Object[] items)

Constructor that sets the Comparator and then adds the given array of items one-by-one to the tree set.

Parameters:
c - the comparator
items - the array of items to add to this tree set
See Also:
addItems(Object[]), QuickTreeSet(Object[])
Method Detail

add

public boolean add(Object element)

Adds the element to the set if it is not present.

If the element is null, then simply returns false.

Parameters:
element - the element to be added to the set
Returns:
true if the element is non-null and the set did not already contain the element
See Also:
TreeSet.add(Object)

remove

public boolean remove(Object element)

Removes the element from the set if it is present.

If the element is null, then simply returns false.

Parameters:
element - the element to be removed from the set
Returns:
true if the element is non-null and the set contained the element
See Also:
TreeSet.remove(Object)

contains

public boolean contains(Object element)

Returns true if the set contains the element.

If the element is null, then simply returns false.

Parameters:
element - the element to test for membership in the set
Returns:
true if the element is non-null and is in the set
See Also:
TreeSet.contains(Object)

headSet

public SortedSet headSet(Object element)

Returns a view of the portion of this set whose elements are strictly less than the element. The returned sorted set is backed by this set, so changes in the returned sorted set are reflected in this set, and vice-versa.

The sorted set returned by this method will throw an IllegalArgumentException if the user attempts to insert an element greater than or equal to the given element.

If element is null, then simply returns null.

Parameters:
element - strict upper bound for the elements in the returned set
Returns:
the subset of elements strictly less than the given element
See Also:
TreeSet.headSet(Object)

tailSet

public SortedSet tailSet(Object element)

Returns a view of the portion of this set whose elements are greater than or equal to the element. The returned sorted set is backed by this set, so changes in the returned sorted set are reflected in this set, and vice-versa.

The sorted set returned by this method will throw an IllegalArgumentException if the user attempts to insert an element less than the given element.

If element is null, then simply returns null.

Parameters:
element - lower bound for the elements in the returned set
Returns:
the subset of elements greater than or equal to the given element
See Also:
TreeSet.tailSet(Object)

subSet

public SortedSet subSet(Object lower,
                        Object upper)

Returns a view of the portion of this set whose elements are greater than or equal to the element lower and strictly less than the element upper. The returned sorted set is backed by this set, so changes in the returned sorted set are reflected in this set, and vice-versa.

The sorted set returned by this method will throw an IllegalArgumentException if the user attempts to insert an element less than lower or greater than or equal to upper.

If either lower or upper is null, then simply returns null.

Parameters:
lower - the lower bound for the elements in the returned set
upper - the strict upper bound for the elements in the returned set
Returns:
the subset of elements greater than or equal to lower and less than upper
See Also:
TreeSet.subSet(Object, Object)

addItems

public void addItems(Object[] items)

Method that adds the given array of items one-by-one to the tree set.

If items is null, then does nothing.

Ignores individual null items.

Parameters:
items - the array of items to add to this tree set
See Also:
QuickTreeSet(Object[]), QuickTreeSet(Comparator, Object[]), setItems(Object[]), removeItems(Object[])

setItems

public void setItems(Object[] items)

Method that first clears this tree set of any existing items and then adds the given array of items one-by-one to the tree set.

If items is null, then this method is equivalent to the inherited method clear.

Ignores individual null items.

Parameters:
items - the array of items to add to this tree set after clearance
See Also:
addItems(Object[]), removeItems(Object[])

removeItems

public void removeItems(Object[] items)

Method that removes the given array of items one-by-one from the tree set.

If items is null, then does nothing.

Ignores individual null items.

Parameters:
items - the array of items to remove from this tree set
See Also:
addItems(Object[]), setItems(Object[])