Interface List<T>

    • 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.
    • 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 java.lang.Iterable

        forEach, iterator, spliterator
    • 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 interface Sequence<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 interface Sequence<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 between 0 and getLength().
        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 interface Sequence<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 interface Sequence<T>
        Parameters:
        index - The starting index to remove.
        count - The number of items to remove, beginning with index.
        Returns:
        A sequence containing the items that were removed.
        See Also:
        ListListener.itemsRemoved(List, int, Sequence)
      • getLength

        int getLength()
        Returns the length of the list.
        Specified by:
        getLength in interface Sequence<T>
        Returns:
        The number of items in the list, or -1 if the list's length is not known. In this case, the iterator must be used to retrieve the contents 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 interface Collection<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.