Interface EditableSequence<T>

Type Parameters:
T - type of element in the EditableSequence
All Superinterfaces:
Assortment<T>, Countable, Enumerable<T>, Iterable<T>, Sequence<T>
All Known Subinterfaces:
Array<T>, ResizableSequence<T>

public interface EditableSequence<T> extends Sequence<T>
Defines the contract for and editable Sequence. Editable Sequences are Sequences with fixed length that allow for replacement of the element at each index, nut not adding new elements A classic example is Array.
  • Method Details

    • toUnmodifiable

      default Sequence<T> toUnmodifiable()
      Returns an unmodifiable view of this EditableSequence
      Returns:
      an unmodifiable view of this EditableSequence
    • setAt

      default Maybe<T> setAt(int index, T element)
      Replaces the element at the given index, with the given element
      Parameters:
      index - the index to replace
      element - the new element
      Returns:
      the value previous present at the index
    • setAt

      Maybe<T> setAt(Int index, T element)
      Replaces the element at the given index, with the given element
      Parameters:
      index - the index to replace
      element - the new element
      Returns:
      the value previous present at the index
    • setFirst

      default Maybe<T> setFirst(T element)
      Replaces the element at index 0, with the given element
      Parameters:
      element - the new element
      Returns:
      the value previous present at the index
    • setLast

      default Maybe<T> setLast(T element)
      Replaces the element at the last index, with the given element
      Parameters:
      element - the new element
      Returns:
      the value previous present at the index
    • subSequence

      EditableSequence<T> subSequence(int fromIndex, int toIndex)
      Creates a view of this Sequence between the given indexes
      Specified by:
      subSequence in interface Sequence<T>
      Parameters:
      fromIndex - the start index
      toIndex - the end index
      Returns:
      the resulting sub subSequence
    • reversed

      EditableSequence<T> reversed()
      Creates a Sequence view that is the reverse of this one.
      Specified by:
      reversed in interface Sequence<T>
      Returns:
      the resulting reverse subSequence
    • toSequence

      default EditableSequence<T> toSequence()
      Returns a Sequence with the elements in this Enumerable. The Enumerable must be finite or an exception will be thrown
      Specified by:
      toSequence in interface Enumerable<T>
      Specified by:
      toSequence in interface Sequence<T>
      Returns:
      the result of toSequence