Interface Sequence<T>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  Sequence.Tree<T>
      Collection of static utility methods providing path access to nested sequence data.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      int add​(T item)
      Adds an item to the sequence.
      default void addAll​(Collection<T> c)
      Add all the elements of the given collection to this sequence using the add(T) method of this interface.
      default void addAll​(T[] array)
      Add all the elements of the given array to this sequence using the add(T) method of this interface.
      T get​(int index)
      Retrieves the item at the given index.
      int getLength()
      Returns the length of the sequence.
      int indexOf​(T item)
      Returns the index of an item in the sequence.
      void insert​(T item, int index)
      Inserts an item into the sequence at a specific index.
      Sequence<T> remove​(int index, int count)
      Removes one or more items from the sequence.
      int remove​(T item)
      Removes the first occurrence of the given item from the sequence.
      T update​(int index, T item)
      Updates the item at the given index.
    • Method Detail

      • add

        int add​(T item)
        Adds an item to the sequence.
        Parameters:
        item - The item to be added to the sequence.
        Returns:
        The index at which the item was added, or -1 if the item was not added to the sequence.
      • insert

        void insert​(T item,
                    int index)
        Inserts an item into the sequence at a specific index.
        Parameters:
        item - The item to be added to the sequence.
        index - The index at which the item should be inserted. Must be a value between 0 and getLength().
      • update

        T update​(int index,
                 T item)
        Updates the item at the given index.
        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.
      • remove

        int remove​(T item)
        Removes the first occurrence of the given item from the sequence.
        Parameters:
        item - The item to remove.
        Returns:
        The index of the item that was removed, or -1 if the item could not be found.
        See Also:
        remove(int, int)
      • remove

        Sequence<T> remove​(int index,
                           int count)
        Removes one or more items from the sequence.
        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.
      • get

        T get​(int index)
        Retrieves the item at the given index.
        Parameters:
        index - The index of the item to retrieve.
        Returns:
        The item at this index in the sequence.
      • indexOf

        int indexOf​(T item)
        Returns the index of an item in the sequence.
        Parameters:
        item - The item to locate.
        Returns:
        The index of first occurrence of the item if it exists in the sequence; -1, otherwise.
      • getLength

        int getLength()
        Returns the length of the sequence.
        Returns:
        The number of items in the sequence.
      • addAll

        default void addAll​(Collection<T> c)
        Add all the elements of the given collection to this sequence using the add(T) method of this interface.
        Parameters:
        c - The other collection to add to this sequence.
      • addAll

        default void addAll​(T[] array)
        Add all the elements of the given array to this sequence using the add(T) method of this interface.
        Parameters:
        array - The array to add to this sequence.