Class SetAdapter<E>
- java.lang.Object
-
- org.apache.pivot.collections.adapter.SetAdapter<E>
-
- Type Parameters:
E
- Type of element in the set.
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<E>
,Collection<E>
,Group<E>
,Set<E>
public class SetAdapter<E> extends java.lang.Object implements Set<E>, java.io.Serializable
Implementation of theSet
interface that is backed by an instance ofSet
.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SetAdapter(java.util.Set<E> set)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(E element)
Adds an element to the group.void
clear()
Removes all elements from the collection.boolean
contains(E element)
Tests the existence of an element in the group.java.util.Comparator<E>
getComparator()
Returns the collection's sort order.int
getCount()
java.util.Set<E>
getSet()
ListenerList<SetListener<E>>
getSetListeners()
boolean
isEmpty()
Tests the emptiness of the collection.java.util.Iterator<E>
iterator()
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.java.lang.String
toString()
-
-
-
Constructor Detail
-
SetAdapter
public SetAdapter(java.util.Set<E> set)
-
-
Method Detail
-
getSet
public java.util.Set<E> getSet()
-
add
public boolean add(E element)
Description copied from interface:Group
Adds an element to the group.
-
remove
public boolean remove(E element)
Description copied from interface:Group
Removes an element from the group.
-
clear
public void clear()
Description copied from interface:Collection
Removes all elements from the collection.- Specified by:
clear
in interfaceCollection<E>
- Specified by:
clear
in interfaceSet<E>
- See Also:
SetListener.setCleared(Set)
-
contains
public boolean contains(E element)
Description copied from interface:Group
Tests the existence of an element in the group.
-
isEmpty
public boolean isEmpty()
Description copied from interface:Collection
Tests the emptiness of the collection.- Specified by:
isEmpty
in interfaceCollection<E>
- Returns:
true
if the collection contains no elements;false
, otherwise.
-
getCount
public int getCount()
-
getComparator
public java.util.Comparator<E> getComparator()
Description copied from interface:Collection
Returns the collection's sort order.- Specified by:
getComparator
in interfaceCollection<E>
- Returns:
- The comparator used to order elements in the collection, or
null
if the sort order is undefined. - See Also:
Collection.setComparator(Comparator)
-
setComparator
public 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>
- Specified by:
setComparator
in interfaceSet<E>
- Parameters:
comparator
- The comparator used to order elements in the collection, or null if the collection is unsorted.- See Also:
SetListener.setCleared(Set)
-
iterator
public java.util.Iterator<E> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<E>
-
getSetListeners
public ListenerList<SetListener<E>> getSetListeners()
- Specified by:
getSetListeners
in interfaceSet<E>
- Returns:
- The set listener list.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-