org.apache.pivot.collections
Interface Set<E>

All Superinterfaces:
Collection<E>, Group<E>, Iterable<E>
All Known Implementing Classes:
EnumSet, HashSet, ImmutableSet, SetAdapter, SynchronizedSet

public interface Set<E>
extends Group<E>, Collection<E>

Collection interface representing a group of unique elements.


Nested Class Summary
static class Set.SetListenerList<E>
          Set listener list.
 
Method Summary
 boolean add(E element)
          Adds an element to the group.
 void clear()
          Removes all elements from the collection.
 int getCount()
          Returns the number of elements in the set.
 ListenerList<SetListener<E>> getSetListeners()
          Returns the set listener collection.
 boolean remove(E element)
          Removes an element from the group.
 void setComparator(Comparator<E> comparator)
          Sets the collection's sort order, re-ordering the collection's contents and ensuring that new entries preserve the sort order.
 
Methods inherited from interface org.apache.pivot.collections.Group
contains
 
Methods inherited from interface org.apache.pivot.collections.Collection
getComparator, isEmpty
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

add

boolean add(E element)
Description copied from interface: Group
Adds an element to the group.

Specified by:
add in interface Group<E>
Parameters:
element - The element to add to the group.
Returns:
true if the element was added to the group; false, otherwise.
See Also:
SetListener.elementAdded(Set, Object)

remove

boolean remove(E element)
Description copied from interface: Group
Removes an element from the group.

Specified by:
remove in interface Group<E>
Parameters:
element - The element to remove from the set.
Returns:
true if the element was removed from the group; false, otherwise.
See Also:
SetListener.elementRemoved(Set, Object)

clear

void clear()
Description copied from interface: Collection
Removes all elements from the collection.

Specified by:
clear in interface Collection<E>
See Also:
SetListener.setCleared(Set)

getCount

int getCount()
Returns the number of elements in the set.


setComparator

void setComparator(Comparator<E> comparator)
Description copied from interface: Collection
Sets the collection's sort order, re-ordering the collection's contents and ensuring that new entries preserve the sort order.

Calling this method more than once with the same comparator will re-sort the collection.

Specified by:
setComparator in interface Collection<E>
Parameters:
comparator - The comparator used to order elements in the collection, or null if the collection is unsorted.
See Also:
SetListener.setCleared(Set)

getSetListeners

ListenerList<SetListener<E>> getSetListeners()
Returns the set listener collection.