Package org.apache.pivot.collections
Interface Set<E>
-
- All Superinterfaces:
Collection<E>
,Group<E>
,java.lang.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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
add(E element)
Adds an element to the group.void
clear()
Removes all elements from the collection.int
getCount()
ListenerList<SetListener<E>>
getSetListeners()
boolean
remove(E element)
Removes an element from the group.void
setComparator(java.util.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.Collection
getComparator, isEmpty
-
-
-
-
Method Detail
-
add
boolean add(E element)
Description copied from interface:Group
Adds an element to the group.- Specified by:
add
in interfaceGroup<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 interfaceGroup<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 interfaceCollection<E>
- See Also:
SetListener.setCleared(Set)
-
getCount
int getCount()
- Returns:
- The number of elements in the set.
-
setComparator
void setComparator(java.util.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 interfaceCollection<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 list.
-
-