Interface ICollection<E>

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default boolean containsIf​(java.util.function.Predicate<? super E> predicate)
      Determines whether the list contains a matching element.
      ICollection<E> copy()
      Returns a copy of this collection with all its elements.
      default int countIf​(java.util.function.Predicate<? super E> predicate)
      Counts how many elements in the list match the predicate.
      ICollection<E> crop()
      Returns an empty copy of this collection.
      ICollection<E> filter​(java.util.function.Predicate<? super E> predicate)
      Create a new collection by applying the specified filter to all elements.
      <R> IList<R> filterMap​(java.util.function.Predicate<E> filter, java.util.function.Function<E,​R> func)
      Create a new list by applying the specified filter first and then the mapping function to all elements selected.
      <R,​C extends java.util.Collection<R>>
      IList<R>
      flatMap​(java.util.function.Function<E,​C> func)
      Create a new list by applying the specified mapping function to all elements.
      default E getFirst()
      Returns the first element stored in the collection.
      default E getFirstOrNull()
      Returns the first element stored in the collection.
      default E getIf​(java.util.function.Predicate<? super E> predicate)
      Returns the first element stored in the collection which matches the predicate.
      default E getSingle()
      Returns the only element stored in the collection.
      default E getSingleOrNull()
      Returns the only element stored in the collection or null if the collection is empty.
      <R> IList<R> map​(java.util.function.Function<E,​R> func)
      Create a new list by applying the specified mapping function to all elements.
      <R> IList<R> mapFilter​(java.util.function.Function<E,​R> func, java.util.function.Predicate<R> filter)
      Create a new list by applying the specified mapping function to all elements and then filtering it.
      • Methods inherited from interface java.util.Collection

        add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
    • Method Detail

      • 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​(java.util.function.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​(java.util.function.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​(java.util.function.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​(java.util.function.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​(java.util.function.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 java.util.Collection<R>> IList<R> flatMap​(java.util.function.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​(java.util.function.Function<E,​R> func,
                               java.util.function.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​(java.util.function.Predicate<E> filter,
                               java.util.function.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