E - the type of item in the setpublic class ListenableTreeSet<E> extends java.util.TreeSet<E> implements ListenableCollection<E>
| Constructor and Description |
|---|
ListenableTreeSet(java.util.Collection<? extends E> c) |
ListenableTreeSet(java.util.Comparator<? super E> comparator) |
ListenableTreeSet(java.util.SortedSet<E> s) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e)
Adds the specified element to this set if it is not already present.
|
boolean |
addAll(java.util.Collection<? extends E> c)
Adds all of the elements in the specified collection to this set.
|
void |
addListener(CollectionListener<E> listener)
Add a listener to be notified when the set changes.
|
void |
clear()
Removes all of the elements from this set.
|
protected java.util.List<CollectionListener<E>> |
createListenerList()
Create a list to hold the registered listeners.
|
protected void |
fireChange(CollectionEvent.Type type,
E element,
int index) |
boolean |
remove(java.lang.Object o)
Removes the specified element from this set if it is present.
|
boolean |
removeAll(java.util.Collection<?> c)
Removes from this set all of its elements that are contained in the
specified collection (optional operation).
|
void |
removeListener(CollectionListener<E> listener)
Remove a listener to stop listening when the set changes.
|
boolean |
retainAll(java.util.Collection<?> c) |
ceiling, clone, comparator, contains, descendingIterator, descendingSet, first, floor, headSet, headSet, higher, isEmpty, iterator, last, lower, pollFirst, pollLast, size, subSet, subSet, tailSet, tailSetfinalize, getClass, notify, notifyAll, wait, wait, waitpublic ListenableTreeSet(java.util.SortedSet<E> s)
public ListenableTreeSet(java.util.Comparator<? super E> comparator)
public ListenableTreeSet(java.util.Collection<? extends E> c)
public void addListener(CollectionListener<E> listener)
addListener in interface ListenableCollection<E>listener - public void removeListener(CollectionListener<E> listener)
removeListener in interface ListenableCollection<E>listener - protected void fireChange(CollectionEvent.Type type, E element, int index)
protected java.util.List<CollectionListener<E>> createListenerList()
public boolean add(E e)
e to this set if
the set contains no element e2 such that
(e==null ? e2==null : e.equals(e2)).
If this set already contains the element, the call leaves the set
unchanged and returns false.add in interface java.util.Collection<E>add in interface java.util.Set<E>add in class java.util.TreeSet<E>e - element to be added to this settrue if this set did not already contain the specified
elementjava.lang.ClassCastException - if the specified object cannot be compared
with the elements currently in this setjava.lang.NullPointerException - if the specified element is null
and this set uses natural ordering, or its comparator
does not permit null elementspublic boolean addAll(java.util.Collection<? extends E> c)
addAll in interface java.util.Collection<E>addAll in interface java.util.Set<E>addAll in class java.util.TreeSet<E>c - collection containing elements to be added to this settrue if this set changed as a result of the calljava.lang.ClassCastException - if the elements provided cannot be compared
with the elements currently in the setjava.lang.NullPointerException - if the specified collection is null or
if any element is null and this set uses natural ordering, or
its comparator does not permit null elementspublic void clear()
public boolean remove(java.lang.Object o)
e such that
(o==null ? e==null : o.equals(e)),
if this set contains such an element. Returns true if
this set contained the element (or equivalently, if this set
changed as a result of the call). (This set will not contain the
element once the call returns.)remove in interface java.util.Collection<E>remove in interface java.util.Set<E>remove in class java.util.TreeSet<E>o - object to be removed from this set, if presenttrue if this set contained the specified elementjava.lang.ClassCastException - if the specified object cannot be compared
with the elements currently in this setjava.lang.NullPointerException - if the specified element is null
and this set uses natural ordering, or its comparator
does not permit null elementspublic boolean removeAll(java.util.Collection<?> c)
This implementation determines which is the smaller of this set and the specified collection, by invoking the size method on each. If this set has fewer elements, then the implementation iterates over this set, checking each element returned by the iterator in turn to see if it is contained in the specified collection. If it is so contained, it is removed from this set with the iterator's remove method. If the specified collection has fewer elements, then the implementation iterates over the specified collection, removing from this set each element returned by the iterator, using this set's remove method.
Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method.
removeAll in interface java.util.Collection<E>removeAll in interface java.util.Set<E>removeAll in class java.util.AbstractSet<E>c - collection containing elements to be removed from this setjava.lang.UnsupportedOperationException - if the removeAll operation
is not supported by this setjava.lang.ClassCastException - if the class of an element of this set
is incompatible with the specified collection (optional)java.lang.NullPointerException - if this set contains a null element and the
specified collection does not permit null elements (optional),
or if the specified collection is nullremove(Object),
TreeSet.contains(Object)public boolean retainAll(java.util.Collection<?> c)
This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's not so contained, it's removed from this collection with the iterator's remove method.
Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements not present in the specified collection.
retainAll in interface java.util.Collection<E>retainAll in interface java.util.Set<E>retainAll in class java.util.AbstractCollection<E>java.lang.UnsupportedOperationExceptionjava.lang.ClassCastExceptionjava.lang.NullPointerExceptionremove(Object),
TreeSet.contains(Object)