public class ListOrderedSet extends AbstractSerializableSetDecorator implements Set
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
 from List, such as get(int), remove(int)
 and indexOf(int). An unmodifiable List view of 
 the set can be obtained via asList().
 
 This class cannot implement the List interface directly as
 various interface methods (notably equals/hashCode) are incompatable with a set.
 
This class is Serializable from Commons Collections 3.1.
| Modifier and Type | Field and Description | 
|---|---|
protected List | 
setOrder
Internal list to hold the sequence of objects 
 | 
collection| Modifier | Constructor and Description | 
|---|---|
  | 
ListOrderedSet()
Constructs a new empty  
ListOrderedSet using
 a HashSet and an ArrayList internally. | 
protected  | 
ListOrderedSet(Set set)
Constructor that wraps (not copies). 
 | 
protected  | 
ListOrderedSet(Set set,
              List list)
Constructor that wraps (not copies) the Set and specifies the list to use. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
add(int index,
   Object object)  | 
boolean | 
add(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(List list)
Factory method to create an ordered set using the supplied list to retain order. 
 | 
static ListOrderedSet | 
decorate(Set set)
Factory method to create an ordered set. 
 | 
static ListOrderedSet | 
decorate(Set set,
        List list)
Factory method to create an ordered set specifying the list and set to use. 
 | 
Object | 
get(int index)  | 
int | 
indexOf(Object object)  | 
Iterator | 
iterator()  | 
Object | 
remove(int index)  | 
boolean | 
remove(Object object)  | 
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. 
 | 
getSetcontains, containsAll, equals, getCollection, hashCode, isEmpty, sizeprotected final List setOrder
public ListOrderedSet()
ListOrderedSet using
 a HashSet and an ArrayList internally.protected ListOrderedSet(Set set)
set - the set to decorate, must not be nullIllegalArgumentException - if set is nullprotected ListOrderedSet(Set set, List list)
The set and list must both be correctly initialised to the same elements.
set - the set to decorate, must not be nulllist - the list to decorate, must not be nullIllegalArgumentException - if set or list is nullpublic static ListOrderedSet decorate(Set set, List list)
The list and set must both be empty.
set - the set to decorate, must be empty and not nulllist - the list to decorate, must be empty and not nullIllegalArgumentException - if set or list is nullIllegalArgumentException - if either the set or list is not emptypublic static ListOrderedSet decorate(Set set)
 An ArrayList is used to retain order.
set - the set to decorate, must not be nullIllegalArgumentException - if set is nullpublic static ListOrderedSet decorate(List list)
 A HashSet is used for the set behaviour.
 
NOTE: If the list contains duplicates, the duplicates are removed, altering the specified list.
list - the list to decorate, must not be nullIllegalArgumentException - if list is nullpublic List asList()
public void clear()
clear in interface Collectionclear in interface Setclear in class AbstractCollectionDecoratorpublic Iterator iterator()
iterator in interface Iterableiterator in interface Collectioniterator in interface Setiterator in class AbstractCollectionDecoratorpublic boolean add(Object object)
add in interface Collectionadd in interface Setadd in class AbstractCollectionDecoratorpublic boolean addAll(Collection coll)
addAll in interface CollectionaddAll in interface SetaddAll in class AbstractCollectionDecoratorpublic boolean remove(Object object)
remove in interface Collectionremove in interface Setremove in class AbstractCollectionDecoratorpublic boolean removeAll(Collection coll)
removeAll in interface CollectionremoveAll in interface SetremoveAll in class AbstractCollectionDecoratorpublic boolean retainAll(Collection coll)
retainAll in interface CollectionretainAll in interface SetretainAll in class AbstractCollectionDecoratorpublic Object[] toArray()
toArray in interface CollectiontoArray in interface SettoArray in class AbstractCollectionDecoratorpublic Object[] toArray(Object[] a)
toArray in interface CollectiontoArray in interface SettoArray in class AbstractCollectionDecoratorpublic Object get(int index)
public int indexOf(Object object)
public void add(int index,
       Object object)
public boolean addAll(int index,
             Collection coll)
public Object remove(int index)
public String toString()
toString in class AbstractCollectionDecoratorCopyright © 2001–2015 The Apache Software Foundation. All rights reserved.