java.lang.Object | +--org.apache.commons.collections.collection.AbstractCollectionDecorator | +--org.apache.commons.collections.set.AbstractSetDecorator | +--org.apache.commons.collections.set.ListOrderedSetAll Implemented Interfaces:
List | Internal list to hold the sequence of objects |
ListOrderedSet(Set set) Constructor that wraps (not copies). |
ListOrderedSet(Set set, List list) Constructor that wraps (not copies) the Set and specifies the list to use. |
boolean | add(Object object) |
void | add(int index, Object object) |
boolean | addAll(Collection coll) |
boolean | addAll(int index, Collection coll) |
List | asList() Gets an unmodifiable view of the order of the Set. |
void | clear() |
static ListOrderedSet | decorate(Set set) Factory method to create an ordered set. |
static ListOrderedSet | decorate(List list) Factory method to create an ordered set using the supplied list to retain order. |
Object | get(int index) |
int | indexOf(Object object) |
Iterator | iterator() |
boolean | remove(Object object) |
Object | remove(int index) |
boolean | removeAll(Collection coll) |
boolean | retainAll(Collection coll) |
Object[] | toArray() |
Object[] | toArray(Object[] a) |
String | toString() Uses the underlying List's toString so that order is achieved. |
protected final List setOrder
protected ListOrderedSet(Set set, List list)
- if set or list is nullprotected ListOrderedSet(Set set)
- if set is nullpublic void add(int index, Object object)
public boolean add(Object object)
public boolean addAll(Collection coll)
public boolean addAll(int index, Collection coll)
public List asList()
public void clear()
public static ListOrderedSet decorate(List list)
HashSet
is used for the set behaviour.
- if set is nullpublic static ListOrderedSet decorate(Set set)
ArrayList
is used to retain order.
- if set is nullpublic Object get(int index)
public int indexOf(Object object)
public Iterator iterator()
public Object remove(int index)
public boolean remove(Object object)
public boolean removeAll(Collection coll)
public boolean retainAll(Collection coll)
public Object[] toArray()
public Object[] toArray(Object[] a)
public String toString()
Set
to ensure that the order of addition is retained and used by the iterator. If an object is added to the set for a second time, it will remain in the original position in the iteration. The order can be observed from the set via the iterator or toArray methods. The ListOrderedSet also has various useful direct methods. These include many fromList
, such asget(int)
,remove(int)
andindexOf(int)
. An unmodifiableList
view of the set can be obtained viaasList()
. This class cannot implement theList
interface directly as various interface methods (notably equals/hashCode) are incompatable with a set.