com.std.util
Class ObservableTreeSet<U>

java.lang.Object
extended by java.util.AbstractCollection<E>
extended by java.util.AbstractSet<E>
extended by java.util.TreeSet<U>
extended by com.std.util.ObservableTreeSet<U>
Type Parameters:
U -
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<U>, java.util.Collection<U>, java.util.NavigableSet<U>, java.util.Set<U>, java.util.SortedSet<U>

public class ObservableTreeSet<U>
extends java.util.TreeSet<U>

a TreeSet that sends out events when an element is added or removed

Author:
xxx
See Also:
Serialized Form

Nested Class Summary
 class ObservableTreeSet.IteratorObserver
          observes an ObservableIterator
 
Field Summary
(package private) static long serialVersionUID
           
 
Constructor Summary
ObservableTreeSet()
          Construct a new TreeSet whose backing TreeMap using the "natural" ordering of keys.
ObservableTreeSet(java.util.Collection<? extends U> c)
          Construct a new TreeSet whose backing TreeMap uses the "natural" ordering of the keys and which contains all of the elements in the supplied Collection.
ObservableTreeSet(java.util.Comparator<? super U> comparator)
          Construct a new TreeSet whose backing TreeMap uses the supplied Comparator.
ObservableTreeSet(java.util.SortedSet<? extends U> s)
          Construct a new TreeSet, using the same key ordering as the supplied SortedSet and containing all of the elements in the supplied SortedSet.
 
Method Summary
 boolean add(U e)
           
 boolean addAll(java.util.Collection<? extends U> c)
           
 java.util.Iterator<U> iterator()
           
 ObservableEvent onChanged()
           
 boolean remove(java.lang.Object o)
           
 
Methods inherited from class java.util.TreeSet
ceiling, clear, clone, comparator, contains, descendingIterator, descendingSet, first, floor, headSet, headSet, higher, isEmpty, last, lower, pollFirst, pollLast, size, subSet, subSet, tailSet, tailSet
 
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
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

ObservableTreeSet

public ObservableTreeSet()
Construct a new TreeSet whose backing TreeMap using the "natural" ordering of keys. Elements that are not mutually comparable will cause ClassCastExceptions down the road.

See Also:
Comparable

ObservableTreeSet

public ObservableTreeSet(java.util.Collection<? extends U> c)
Construct a new TreeSet whose backing TreeMap uses the "natural" ordering of the keys and which contains all of the elements in the supplied Collection. This runs in n*log(n) time.

Parameters:
c - the new Set will be initialized with all of the elements in this Collection
Throws:
java.lang.ClassCastException - if the elements of the collection are not comparable
java.lang.NullPointerException - if the collection is null
See Also:
Comparable

ObservableTreeSet

public ObservableTreeSet(java.util.Comparator<? super U> comparator)
Construct a new TreeSet whose backing TreeMap uses the supplied Comparator. Elements that are not mutually comparable will cause ClassCastExceptions down the road.

Parameters:
comparator - the Comparator this Set will use

ObservableTreeSet

public ObservableTreeSet(java.util.SortedSet<? extends U> s)
Construct a new TreeSet, using the same key ordering as the supplied SortedSet and containing all of the elements in the supplied SortedSet. This constructor runs in linear time.

Parameters:
s - the new TreeSet will use this SortedSet's comparator and will initialize itself with all its elements
Throws:
java.lang.NullPointerException - if sortedSet is null
Method Detail

add

public boolean add(U e)
Specified by:
add in interface java.util.Collection<U>
Specified by:
add in interface java.util.Set<U>
Overrides:
add in class java.util.TreeSet<U>

addAll

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

iterator

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

onChanged

public ObservableEvent onChanged()
Returns:
the observable event that will send out notifications when any element has been added or removed

remove

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