java.lang.Object
|
+--org.apache.commons.collections.collection.AbstractCollectionDecorator
|
+--org.apache.commons.collections.list.AbstractListDecorator
|
+--org.apache.commons.collections.list.SetUniqueList
Set | Internal Set to maintain uniqueness. |
SetUniqueList(List list, Set set) Constructor that wraps (not copies) the List and specifies the set to use. |
boolean | add(Object object) Adds an element to the list if it is not already present. |
void | add(int index, Object object) Adds an element to a specific index in the list if it is not already present. |
boolean | addAll(Collection coll) Adds an element to the end of the list if it is not already present. |
boolean | addAll(int index, Collection coll) Adds a collection of objects to the end of the list avoiding duplicates. |
Set | asSet() Gets an unmodifiable view as a Set. |
void | clear() |
boolean | contains(Object object) |
boolean | containsAll(Collection coll) |
static SetUniqueList | decorate(List list) Factory method to create a SetList using the supplied list to retain order. |
Iterator | iterator() |
ListIterator | |
ListIterator | listIterator(int index) |
boolean | remove(Object object) |
Object | remove(int index) |
boolean | removeAll(Collection coll) |
boolean | retainAll(Collection coll) |
Object | set(int index, Object object) Sets the value at the specified index avoiding duplicates. |
List | subList(int fromIndex, int toIndex) |
protected final Set set
protected SetUniqueList(List list, Set set)
- if set or list is nullpublic void add(int index, Object object)
List interface makes the assumption that the element is
always inserted. This may not happen with this implementation.
public boolean add(Object object)
List interface requires that this method returns
true always. However this class may return false
because of the Set behaviour.
public boolean addAll(Collection coll)
List interface makes the assumption that the element is
always inserted. This may not happen with this implementation.
public boolean addAll(int index, Collection coll)
List interface makes the assumption that the elements
are always inserted. This may not happen with this implementation.
public Set asSet()
public void clear()
public boolean contains(Object object)
public boolean containsAll(Collection coll)
public static SetUniqueList decorate(List list)
HashSet is used for the set behaviour.
- if list is nullpublic Iterator iterator()
public ListIterator listIterator()
public ListIterator listIterator(int index)
public Object remove(int index)
public boolean remove(Object object)
public boolean removeAll(Collection coll)
public boolean retainAll(Collection coll)
public Object set(int index, Object object)
public List subList(int fromIndex, int toIndex)
Listto ensure that no duplicates are present much like aSet. TheListinterface makes certain assumptions/requirements. This implementation breaks these in certain ways, but this is merely the result of rejecting duplicates. Each violation is explained in the method, but it should not affect you. The org.apache.commons.collections.set.ListOrderedSet ListOrderedSet class provides an alternative approach, by wrapping an existing Set and retaining insertion order in the iterator.