Interface ICollection<E>

Type Parameters:
E - type of elements stored in the list
All Superinterfaces:
Collection<E>, Iterable<E>
All Known Implementing Classes:
BigList, BigList.Block, BigList.ReadOnlyBigList, BooleanObjBigList, BooleanObjBigList.ImmutableBooleanObjBigList, BooleanObjGapList, BooleanObjGapList.ImmutableBooleanObjGapList, ByteObjBigList, ByteObjBigList.ImmutableByteObjBigList, ByteObjGapList, ByteObjGapList.ImmutableByteObjGapList, CharObjBigList, CharObjBigList.ImmutableCharObjBigList, CharObjGapList, CharObjGapList.ImmutableCharObjGapList, DoubleObjBigList, DoubleObjBigList.ImmutableDoubleObjBigList, DoubleObjGapList, DoubleObjGapList.ImmutableDoubleObjGapList, FloatObjBigList, FloatObjBigList.ImmutableFloatObjBigList, FloatObjGapList, FloatObjGapList.ImmutableFloatObjGapList, GapList, GapList.ReadOnlyList, IList, IntObjBigList, IntObjBigList.ImmutableIntObjBigList, IntObjGapList, IntObjGapList.ImmutableIntObjGapList, Key1Collection, Key1List, Key1List.ReadOnlyKey1List, Key1Set, Key2Collection, Key2List, Key2List.ReadOnlyKey2List, Key2Set, KeyCollection, KeyCollectionImpl, KeyCollectionImpl.KeyMapList, KeyList, KeyList.ImmutableKeyList, KeyListImpl, KeySet, LongObjBigList, LongObjBigList.ImmutableLongObjBigList, LongObjGapList, LongObjGapList.ImmutableLongObjGapList, ShortObjBigList, ShortObjBigList.ImmutableShortObjBigList, ShortObjGapList, ShortObjGapList.ImmutableShortObjGapList

public interface ICollection<E> extends Collection<E>
IList is an abstract class which offers all interfaces offered by both ArrayList and LinkedList. It also offers additional methods which are then available in all implementations of GapList and BigList.
See Also:
  • Method Details

    • getFirst

      default E getFirst()
      Returns the first element stored in the collection. If the collection is empty, a NoSuchElementException is thrown.
      Returns:
      first element stored in the collection
    • getFirstOrNull

      default E getFirstOrNull()
      Returns the first element stored in the collection. If the collection is empty, null is returned.
      Returns:
      first element stored in the collection or null if empty
    • getSingle

      default E getSingle()
      Returns the only element stored in the collection. If the collection size is not 1, a NoSuchElementException is thrown.
      Returns:
      only element stored in the collection
    • getSingleOrNull

      default E getSingleOrNull()
      Returns the only element stored in the collection or null if the collection is empty. If the collection's size is greater than 1, a NoSuchElementException is thrown.
      Returns:
      only element stored in the collection or null if empty
    • getIf

      default E getIf(Predicate<? super E> predicate)
      Returns the first element stored in the collection which matches the predicate. If the collection is empty of no element matches, null is returned.
      Returns:
      first element matching the predicate or null if not founds
    • containsIf

      default boolean containsIf(Predicate<? super E> predicate)
      Determines whether the list contains a matching element.
      Parameters:
      predicate - predicate used to search element
      Returns:
      true if the list contains a matching element, false otherwise
    • countIf

      default int countIf(Predicate<? super E> predicate)
      Counts how many elements in the list match the predicate.
      Parameters:
      predicate - a predicate which returns true for elements to be counted
      Returns:
      count how many elements in the list match the predicate
    • filter

      ICollection<E> filter(Predicate<? super E> predicate)
      Create a new collection by applying the specified filter to all elements. The returned collection has the same type as the original one.
      Parameters:
      predicate - filter predicate
      Returns:
      created list
    • map

      <R> IList<R> map(Function<E,R> func)
      Create a new list by applying the specified mapping function to all elements. The returned list is of type IList, typically GapList unless the original type is BigList.
      Parameters:
      func - mapping function
      Returns:
      created list
    • flatMap

      <R, C extends Collection<R>> IList<R> flatMap(Function<E,C> func)
      Create a new list by applying the specified mapping function to all elements. The returned list is of type IList, typically GapList unless the original type is BigList.
      Parameters:
      func - mapping function
      Returns:
      created list
    • mapFilter

      <R> IList<R> mapFilter(Function<E,R> func, Predicate<R> filter)
      Create a new list by applying the specified mapping function to all elements and then filtering it. The returned list is of type IList, typically GapList unless the original type is BigList.
      Parameters:
      func - mapping function
      filter - filter predicate
      Returns:
      created list
    • filterMap

      <R> IList<R> filterMap(Predicate<E> filter, Function<E,R> func)
      Create a new list by applying the specified filter first and then the mapping function to all elements selected. The returned list is of type IList, typically GapList unless the original type is BigList.
      Parameters:
      filter - filter predicate
      func - mapping function
      Returns:
      created list
    • copy

      ICollection<E> copy()
      Returns a copy of this collection with all its elements.
      Returns:
      a copy of this collection
    • crop

      ICollection<E> crop()
      Returns an empty copy of this collection.
      Returns:
      an empty copy of this collection