java.lang.Object | ||||
↳ | org.apache.commons.collections.collection.AbstractCollectionDecorator | |||
↳ | org.apache.commons.collections.set.AbstractSetDecorator | |||
↳ | org.apache.commons.collections.set.AbstractSerializableSetDecorator | |||
↳ | org.apache.commons.collections.set.ListOrderedSet |
Decorates another 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.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
setOrder | Internal list to hold the sequence of objects |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.commons.collections.collection.AbstractCollectionDecorator
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new empty
ListOrderedSet using
a HashSet and an ArrayList internally. |
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructor that wraps (not copies).
| |||||||||||
Constructor that wraps (not copies) the Set and specifies the list to use.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets an unmodifiable view of the order of the Set.
| |||||||||||
Factory method to create an ordered set.
| |||||||||||
Factory method to create an ordered set specifying the list and set to use.
| |||||||||||
Factory method to create an ordered set using the supplied list to retain order.
| |||||||||||
Uses the underlying List's toString so that order is achieved.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.commons.collections.set.AbstractSetDecorator
| |||||||||||
From class
org.apache.commons.collections.collection.AbstractCollectionDecorator
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Iterable
| |||||||||||
From interface
java.util.Collection
| |||||||||||
From interface
java.util.Set
|
Constructs a new empty ListOrderedSet
using
a HashSet
and an ArrayList
internally.
Constructor that wraps (not copies).
set | the set to decorate, must not be null |
---|
IllegalArgumentException | if set is null |
---|
Constructor that wraps (not copies) the Set and specifies the list to use.
The set and list must both be correctly initialised to the same elements.
set | the set to decorate, must not be null |
---|---|
list | the list to decorate, must not be null |
IllegalArgumentException | if set or list is null |
---|
Gets an unmodifiable view of the order of the Set.
Factory method to create an ordered set.
An ArrayList
is used to retain order.
set | the set to decorate, must not be null |
---|
IllegalArgumentException | if set is null |
---|
Factory method to create an ordered set specifying the list and set to use.
The list and set must both be empty.
set | the set to decorate, must be empty and not null |
---|---|
list | the list to decorate, must be empty and not null |
IllegalArgumentException | if set or list is null |
---|---|
IllegalArgumentException | if either the set or list is not empty |
Factory method to create an ordered set using the supplied list to retain order.
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 null |
---|
IllegalArgumentException | if list is null |
---|
Uses the underlying List's toString so that order is achieved. This means that the decorated Set's toString is not used, so any custom toStrings will be ignored.