Interface IList<V>

All Superinterfaces:
ICollection<IList<V>,V>, Iterable<V>
All Known Implementing Classes:
IList.Mixin, LinearList, List

public interface IList<V> extends ICollection<IList<V>,V>, Iterable<V>
  • Method Details

    • update

      default IList<V> update(long idx, Function<V,V> updateFn)
    • isLinear

      default boolean isLinear()
      Specified by:
      isLinear in interface ICollection<IList<V>,V>
      Returns:
      true, if the list is linear
    • addLast

      IList<V> addLast(V value)
      Returns:
      a new list, with value appended
    • addFirst

      IList<V> addFirst(V value)
      Returns:
      a new list, with value prepended
    • removeLast

      IList<V> removeLast()
      Returns:
      a new list with the last value removed, or the same list if already empty
    • removeFirst

      IList<V> removeFirst()
      Returns:
      a new list with the first value removed, or the same value if already empty
    • set

      IList<V> set(long idx, V value)
      Returns:
      a new list, with the element at idx overwritten with value. If idx is equal to ICollection.size(), the value is appended.
      Throws:
      IndexOutOfBoundsException - when idx is not within [0, size]
    • stream

      default Stream<V> stream()
      Returns:
      a Stream, representing the elements in the list
    • spliterator

      default Spliterator<V> spliterator()
      Specified by:
      spliterator in interface Iterable<V>
    • iterator

      default Iterator<V> iterator(long startIndex)
      Specified by:
      iterator in interface ICollection<IList<V>,V>
    • toArray

      default Object[] toArray()
      Returns:
      the elements of the list, in an array
    • toArray

      default V[] toArray(IntFunction<V[]> allocator)
      Parameters:
      allocator - a function which creates an array of the specified size
      Returns:
      the elements of the list, in a typed array
    • toList

      default List<V> toList()
      Returns:
      the collection, represented as a normal Java list, which will throw an UnsupportedOperationException for any write
    • split

      default IList<IList<V>> split(int parts)
      Description copied from interface: ICollection
      Splits the collection into roughly even pieces, for parallel processing. Depending on the size and contents of the collection, this function may not return exactly parts subsets.
      Specified by:
      split in interface ICollection<IList<V>,V>
      Parameters:
      parts - the target number of pieces
      Returns:
      a list containing subsets of the collection.
    • slice

      default IList<V> slice(long start, long end)
      Parameters:
      start - the inclusive start of the range
      end - the exclusive end of the range
      Returns:
      a sub-range of the list within [start, end), which is linear if this is linear
    • concat

      default IList<V> concat(IList<V> l)
      Parameters:
      l - another list
      Returns:
      a new collection representing the concatenation of the two lists, which is linear if this is linear
    • first

      default V first()
      Returns:
      the first element
      Throws:
      IndexOutOfBoundsException - if the collection is empty
    • last

      default V last()
      Returns:
      the last element
      Throws:
      IndexOutOfBoundsException - if the collection is empty
    • forked

      default IList<V> forked()
      Description copied from interface: ICollection
      This returns a data structure which is forked, which is equivalent to Clojure's persistent data structures, also sometimes called functional or immutable. This is called "forked" because it means that multiple functions can make divergent changes to the data structure without affecting each other.

      If only a single function or scope uses the data structure, it can be left as a linear data structure, which can have significant performance benefits.

      If the data structure is already forked, it will simply return itself.

      Specified by:
      forked in interface ICollection<IList<V>,V>
      Returns:
      a forked form of the data structure
    • linear

      IList<V> linear()
      Description copied from interface: ICollection
      This returns a data structure which is linear, or temporarily mutable. The term "linear", as used here, does not completely align with the formal definition of linear types as used in type theory. It is meant to describe the linear dataflow of the method calls, and as a converse to "forked" data structures.

      If ICollection.forked() is called on a linear collection, all references to that linear collection should be discarded.

      If the data structure is already linear, it will simply return itself.

      Specified by:
      linear in interface ICollection<IList<V>,V>
      Returns:
      a linear form of this data structure
    • equals

      default boolean equals(Object o, BiPredicate<V,V> equals)