Package org.apache.pivot.collections
Interface List<T>
-
- All Superinterfaces:
Collection<T>
,java.lang.Iterable<T>
,Sequence<T>
- All Known Implementing Classes:
ArrayList
,CalendarDateSpinnerData
,Element
,EnumList
,FileList
,FileObjectList
,HistogramSeries
,ImmutableList
,LinkedList
,ListAdapter
,NumericSpinnerData
,ResultList
,SynchronizedList
,TreeBranch
,ValueSeries
public interface List<T> extends Sequence<T>, Collection<T>
Collection interface representing an ordered sequence of items.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
List.ItemIterator<T>
Optional item iterator interface.static class
List.ListListenerList<T>
List listener list.-
Nested classes/interfaces inherited from interface org.apache.pivot.collections.Sequence
Sequence.Tree<T>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
add(T item)
Adds an item to the list.void
clear()
Removes all elements from the collection.int
getLength()
Returns the length of the list.ListenerList<ListListener<T>>
getListListeners()
Returns the list listener list.void
insert(T item, int index)
Inserts an item into the list.Sequence<T>
remove(int index, int count)
Removes one or more items from the sequence.void
setComparator(java.util.Comparator<T> comparator)
Sets the collection's sort order, re-ordering the collection's contents and ensuring that new entries preserve the sort order.T
update(int index, T item)
Updates the item at the given index.-
Methods inherited from interface org.apache.pivot.collections.Collection
getComparator, isEmpty
-
-
-
-
Method Detail
-
add
int add(T item)
Adds an item to the list. If the list is unsorted, the item is appended to the end of the list. Otherwise, it is inserted at the appropriate index.- Specified by:
add
in interfaceSequence<T>
- Parameters:
item
- The item to be added to the sequence.- Returns:
- The index at which the item was added.
- See Also:
ListListener.itemInserted(List, int)
-
insert
void insert(T item, int index)
Inserts an item into the list.- Specified by:
insert
in interfaceSequence<T>
- Parameters:
item
- The item to be added to the list.index
- The index at which the item should be inserted. Must be a value between0
andgetLength()
.- Throws:
java.lang.IllegalArgumentException
- If the list is sorted and the insertion point of the item does not match the given index.- See Also:
ListListener.itemInserted(List, int)
-
update
T update(int index, T item)
Updates the item at the given index.- Specified by:
update
in interfaceSequence<T>
- Parameters:
index
- The index of the item to update.item
- The item that will replace any existing value at the given index.- Returns:
- The item that was previously stored at the given index.
- Throws:
java.lang.IllegalArgumentException
- If the list is sorted and the index of the updated item would be different than its current index.- See Also:
ListListener.itemUpdated(List, int, Object)
-
remove
Sequence<T> remove(int index, int count)
Description copied from interface:Sequence
Removes one or more items from the sequence.- Specified by:
remove
in interfaceSequence<T>
- Parameters:
index
- The starting index to remove.count
- The number of items to remove, beginning withindex
.- Returns:
- A sequence containing the items that were removed.
- See Also:
ListListener.itemsRemoved(List, int, Sequence)
-
clear
void clear()
Description copied from interface:Collection
Removes all elements from the collection.- Specified by:
clear
in interfaceCollection<T>
- See Also:
ListListener.itemsRemoved(List, int, Sequence)
-
getLength
int getLength()
Returns the length of the list.
-
setComparator
void setComparator(java.util.Comparator<T> 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<T>
- Parameters:
comparator
- The comparator used to order elements in the collection, or null if the collection is unsorted.- See Also:
ListListener.comparatorChanged(List, Comparator)
-
getListListeners
ListenerList<ListListener<T>> getListListeners()
Returns the list listener list.- Returns:
- The list of listeners for this list.
-
-