displayablecollections
Class DisplayableTreeSet<E>

java.lang.Object
  extended by java.util.Observable
      extended by displayablecollections.DisplayableTreeSet<E>
All Implemented Interfaces:
DisplayableCollection<E>, DisplayableSet<E>, DisplayableSortedSet<E>, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>, java.util.SortedSet<E>

public class DisplayableTreeSet<E>
extends java.util.Observable
implements DisplayableSortedSet<E>, java.lang.Cloneable, java.io.Serializable

A DisplayableTreeSet encapsulates a TreeSet and allows it to be displayed by a JList

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface displayablecollections.DisplayableCollection
DisplayableCollection.CollectionChangedNotification<E>
 
Constructor Summary
DisplayableTreeSet()
          Constructs a new empty set
DisplayableTreeSet(java.util.Collection<? extends E> c)
          Constructs a new set containing the elements in the specified collection, sorted according to the element's natural order
DisplayableTreeSet(java.util.Comparator<? super E> c)
          Constructs a new empty set according to the specified comparator
DisplayableTreeSet(java.util.SortedSet<E> s)
          Constructs a new set containing the same elements as the specified set, sorted according to the same ordering
 
Method Summary
 boolean add(E o)
           
 boolean addAll(java.util.Collection<? extends E> c)
           
 void clear()
           
 java.util.Comparator<? super E> comparator()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection<?> c)
           
 boolean equals(java.lang.Object o)
           
 E first()
           
 int hashCode()
           
 java.util.SortedSet<E> headSet(E toElement)
          Returns a view of the portion of this sorted set whose elements are strictly less than toElement.
 boolean isEmpty()
           
 java.util.Iterator<E> iterator()
           
 E last()
           
 javax.swing.ListModel listModel()
          Create a list model for displaying this collection in a JList.
 javax.swing.ListModel orderedListModel()
          Create a list model for displaying this collection in a JList.
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection<?> c)
           
 boolean retainAll(java.util.Collection<?> c)
           
 int size()
           
 java.util.SortedSet<E> subSet(E fromElement, E toElement)
          Returns a view of the portion of this sorted set whose elements range from fromElement, inclusive, to toElement, exclusive.
 java.util.SortedSet<E> tailSet(E fromElement)
          Returns a view of the portion of this sorted set whose elements are greater than or equal to fromElement.
 java.lang.Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface displayablecollections.DisplayableCollection
addObserver, deleteObservers, listModel
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

DisplayableTreeSet

public DisplayableTreeSet()
Constructs a new empty set


DisplayableTreeSet

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

Parameters:
c - the collection whose elements are to be placed in the set

DisplayableTreeSet

public DisplayableTreeSet(java.util.Comparator<? super E> c)
Constructs a new empty set according to the specified comparator

Parameters:
c - the comparator

DisplayableTreeSet

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

Parameters:
s - the set whose elements are to be placed in the set
Method Detail

orderedListModel

public javax.swing.ListModel orderedListModel()
Description copied from interface: DisplayableSortedSet
Create a list model for displaying this collection in a JList. The result of calling toString() is what will actually be displayed for each. The display will show the elements in the same order as they appear in in the set.

Specified by:
orderedListModel in interface DisplayableSortedSet<E>

comparator

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

first

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

headSet

public java.util.SortedSet<E> headSet(E toElement)
Description copied from interface: DisplayableSortedSet
Returns a view of the portion of this sorted set whose elements are strictly less than toElement. The returned sorted set is backed by this sorted set, so changes in the returned sorted set are reflected in this sorted set, and vice-versa. The returned set supports all optional set operations that this sorted set supports.

The sorted set returned by this method implements the DisplayableSortedSet interface to support enabling this set to notify its observers of changes made through the headSet; but the headSet itself cannot have observers of its own. Attempting to add an observer to the headSet will result in an UnsupportedOperation exception.

Specified by:
headSet in interface DisplayableSortedSet<E>
Specified by:
headSet in interface java.util.SortedSet<E>
Parameters:
toElement - - high endpoint (exclusive) of the headSet.
Returns:
a view of the specified initial range of this sorted set.

last

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

subSet

public java.util.SortedSet<E> subSet(E fromElement,
                                     E toElement)
Description copied from interface: DisplayableSortedSet
Returns a view of the portion of this sorted set whose elements range from fromElement, inclusive, to toElement, exclusive. (If fromElement and toElement are equal, the returned sorted set is empty.) The returned sorted set is backed by this sorted set, so changes in the returned sorted set are reflected in this sorted set, and vice-versa. The returned set supports all optional set operations that this sorted set supports.

The sorted set returned by this method implements the DisplayableSortedSet interface to support enabling this set to notify its observers of changes made through the subSet; but the subSeet itself cannot have observers of its own. Attempting to add an observer to the subSet will result in an UnsupportedOperation exception.

Specified by:
subSet in interface DisplayableSortedSet<E>
Specified by:
subSet in interface java.util.SortedSet<E>
Parameters:
fromElement - - low endpoint (inclusive) of the subSet.
toElement - - high endpoint (exclusive) of the subSeet.
Returns:
a view of the specified initial range of this sorted set.

tailSet

public java.util.SortedSet<E> tailSet(E fromElement)
Description copied from interface: DisplayableSortedSet
Returns a view of the portion of this sorted set whose elements are greater than or equal to fromElement. The returned sorted set is backed by this sorted set, so changes in the returned sorted set are reflected in this sorted set, and vice-versa. The returned set supports all optional set operations that this sorted set supports.

The sorted set returned by this method implements the DisplayableSortedSet interface to support enabling this set to notify its observers of changes made through the tailSet; but the tailSet itself cannot have observers of its own. Attempting to add an observer to the tailSet will result in an UnsupportedOperation exception.

Specified by:
tailSet in interface DisplayableSortedSet<E>
Specified by:
tailSet in interface java.util.SortedSet<E>
Parameters:
fromElement - - low endpoint (inclusive) of the tailSet.
Returns:
a view of the specified initial range of this sorted set.

listModel

public javax.swing.ListModel listModel()
Description copied from interface: DisplayableCollection
Create a list model for displaying this collection in a JList. The result of calling toString() is what will actually be displayed for each element. There will be no necessary connection between the order of display and any order in the collection, since this method can be invoked on any collection implementing this interface. (For collections having an inherent order, orderedListModel can be used instead.)

Specified by:
listModel in interface DisplayableCollection<E>
See Also:
orderedListModel() in DisplayableList and DisplayableSortedSet

add

public boolean add(E o)
Specified by:
add in interface java.util.Collection<E>

addAll

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

clear

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

contains

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

containsAll

public boolean containsAll(java.util.Collection<?> c)
Specified by:
containsAll in interface java.util.Collection<E>

equals

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

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection<E>
Overrides:
hashCode in class java.lang.Object

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<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>

remove

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

removeAll

public boolean removeAll(java.util.Collection<?> c)
Specified by:
removeAll in interface java.util.Collection<E>

retainAll

public boolean retainAll(java.util.Collection<?> c)
Specified by:
retainAll in interface java.util.Collection<E>

size

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

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<E>

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface java.util.Collection<E>