Interface Flow<T>

  • Type Parameters:
    T - the type of elements in this flow
    All Superinterfaces:
    java.lang.Iterable<T>, java.util.Iterator<T>
    All Known Subinterfaces:
    FlowCompleted<T>

    public interface Flow<T>
    extends java.util.Iterator<T>, java.lang.Iterable<T>
    A fluent interface for processing sequences of elements supporting chained method calls. Combines features of Iterator and Iterable with additional stream-like operations.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  Flow.SplitComparator<T>
      Functional interface for splitting elements into three categories.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Flow<?> EMPTY
      An empty flow singleton instance.
      static java.util.Random RANDOM
      Shared random instance used for operations like shuffle() and random()
    • Method Summary

      All Methods Static Methods Instance Methods Default Methods 
      Modifier and Type Method Description
      default Flow<T> add​(T value)
      Appends an element to the end of this flow.
      default Flow<T> addAll​(Flow<? extends T> values)
      Appends all elements from another flow.
      default Flow<T> addAll​(java.lang.Iterable<? extends T> values)
      Appends all elements from an iterable.
      default Flow<T> addAll​(java.util.Iterator<? extends T> values)
      Appends all elements from an iterator.
      default <E extends T>
      Flow<T>
      addAllEls​(E... values)
      Appends multiple elements to the end of this flow.
      default <R> R allMap​(AFunction<Flow<T>,​R> f)
      Applies a function to the entire flow.
      default boolean allMatch​(APredicate<T> p)
      Returns whether all elements of this flow match the provided predicate.
      default boolean anyMatch​(APredicate<T> p)
      Returns whether any elements of this flow match the provided predicate.
      default boolean anyMatchObj​(T p)
      Returns whether any element of this flow equals the given object.
      default @NotNull Flow<T> apply​(AConsumer<T> c)
      Applies an action to each element while passing through the elements.
      default <E> Flow<E> cast​(@NotNull java.lang.Class<E> type)
      Casts elements to the specified type.
      default int count()
      Counts the number of elements in the flow.
      default void crossSelf​(ABiConsumer<T,​T> consumer)
      Performs an action for each unique pair of elements (excluding self-pairs).
      default void crossSelf​(ABiPredicate<T,​T> p, ABiConsumer<T,​T> consumer)
      Performs an action for each unique pair of elements that satisfy the predicate.
      default Flow<T> distinct()
      Returns a flow with distinct elements.
      default Flow<T> errorIf​(APredicate<T> conditions)
      Throws an exception if any element matches the condition.
      default Flow<T> errorIf​(APredicate<T> conditions, java.lang.Class<? extends java.lang.Throwable> throwCode)
      Throws an exception of the specified type if any element matches the condition.
      default Flow<T> errorIf​(APredicate<T> conditions, java.lang.Runnable throwCode)
      Throws an exception using the provided runnable if any element matches the condition.
      default Flow<T> errorIf​(APredicate<T> conditions, java.util.function.Consumer<T> throwCode)
      Throws an exception using the provided consumer if any element matches the condition.
      default @NotNull Flow<T> filter​(@Nullable APredicate<T> predicate)
      Filters elements based on a predicate.
      default <E> @NotNull Flow<E> filterByType​(java.lang.Class<E> predicate)
      Filters elements by type.
      default @NotNull Flow<T> filterExclude​(T value)
      Filters out elements equal to the specified value.
      default @NotNull Flow<T> filterNot​(@Nullable APredicate<T> predicate)
      Filters elements that don't match the predicate.
      default @NotNull Flow<T> filterNotNull()
      Filters out null elements.
      default @NotNull Flow<T> filterNotType​(java.lang.Class<?> predicate)
      Filters out elements of the specified type.
      default <E> @NotNull Flow<E> flatMap​(@NotNull ABiConsumer<T,​AConsumer<E>> f)
      Maps each element to multiple elements using a consumer-based approach.
      default <E> @NotNull Flow<E> flatMap1​(@NotNull AFunctionO2Iterable<T,​E> f)
      Maps each element to an iterable and flattens the results.
      default <E> @NotNull Flow<E> flatMap2​(@NotNull AFunctionO2Array<T,​E> f)
      Maps each element to an array and flattens the results.
      default <E> @NotNull Flow<E> flatMap3​(@NotNull AFunctionO2Stream<T,​E> f)
      Maps each element to a stream and flattens the results.
      default <E> @NotNull Flow<E> flatMap4​(@NotNull AFunctionO2Iterator<T,​E> f)
      Maps each element to an iterator and flattens the results.
      static <T> Flow<T> flow()
      Creates an empty flow.
      static @NotNull FlowByte flow​(byte @NotNull [] array)
      Creates a byte flow from a byte array.
      static FlowInt flow​(int number)
      Creates an integer flow representing a range.
      static FlowInt flow​(int @NotNull [] array)
      Creates an integer flow from an int array.
      static @NotNull FlowLong flow​(long @NotNull [] array)
      Creates a long flow from a long array.
      static FlowShort flow​(short @NotNull [] array)
      Creates a short flow from a short array.
      static <T> @NotNull Flow<T> flow​(@NotNull Flow<T> stream)
      Creates a flow from another flow (identity function).
      static <T> @NotNull Flow<T> flow​(@NotNull ASupplier<T> supplier)
      Creates a flow from a supplier.
      static @NotNull FlowInt flow​(@NotNull it.unimi.dsi.fastutil.ints.IntIterable iterable)
      Creates an integer flow from an int iterable.
      static @NotNull FlowInt flow​(@NotNull it.unimi.dsi.fastutil.ints.IntList collection)
      Creates an integer flow from an int list.
      static @NotNull FlowLong flow​(@NotNull it.unimi.dsi.fastutil.longs.LongIterable iterable)
      Creates a long flow from a long iterable.
      static @NotNull FlowLong flow​(@NotNull it.unimi.dsi.fastutil.longs.LongIterator iterator)
      Creates a long flow from a long iterator.
      static @NotNull FlowLong flow​(@NotNull it.unimi.dsi.fastutil.longs.LongList collection)
      Creates a long flow from a long list.
      static @NotNull FlowLong flow​(@NotNull it.unimi.dsi.fastutil.longs.LongSet collection)
      Creates a long flow from a long set.
      static <T> @NotNull Flow<T> flow​(@NotNull java.lang.Iterable<T> iterable)
      Creates a flow from an iterable.
      static @NotNull Flow<java.lang.String> flow​(@NotNull java.lang.String... ss)
      Creates a flow from string values.
      static <T> @NotNull Flow<T> flow​(@NotNull java.util.Collection<T> collection)
      Creates a flow from a collection.
      static <T> @NotNull Flow<T> flow​(@NotNull java.util.Iterator<T> iterator)
      Creates a flow from an iterator.
      static <T> @NotNull Flow<T> flow​(@NotNull java.util.List<T> collection)
      Creates a flow from a list.
      static <K,​V>
      @NotNull Flow<java.util.Map.Entry<K,​V>>
      flow​(@NotNull java.util.Map<K,​V> map)
      Creates a flow from a map's entry set.
      static <T> @NotNull Flow<T> flow​(@NotNull java.util.Set<T> collection)
      Creates a flow from a set.
      static <T> @NotNull Flow<T> flow​(@NotNull T[] array)
      Creates a flow from an array.
      static <T> Flow<T> flowArray​(@NotNull T... ss)
      Creates a flow from array values.
      default void foreach​(AConsumer<T> c)
      Performs an action for each element in the flow.
      default T getFirst()
      Returns the first element or throws if empty.
      default T getFirst​(APredicate<T> p)
      Returns the first matching element or throws if none match.
      default T getFirstOrNull()
      Returns the first element or null if empty.
      default T getFirstOrNull​(APredicate<T> p)
      Returns the first matching element or null if none match.
      default @NotNull Flow<T> ifEmpty​(ARunnable task)
      Executes an action if the flow is empty.
      default @NotNull Flow<T> ifEmpty​(java.lang.Exception error)
      Throws the specified exception if the flow is empty.
      default Flow<T> ifError​(AFunction<java.lang.Throwable,​T> f)
      Handles errors by applying a fallback function.
      default @NotNull Flow<T> ignoreError​(java.lang.Class<? extends java.lang.Exception> ee)
      Ignores exceptions of the specified type.
      default boolean isEmpty()
      Returns whether the flow is empty.
      default boolean isNotEmpty()
      Returns whether the flow contains any elements.
      default @NotNull java.util.Iterator<T> iterator()
      Returns an iterator over elements of type T.
      default java.lang.String join()
      Joins elements into a string without delimiters.
      default void join​(AString sb, java.lang.String delimer)
      Joins elements into an AString with the specified delimiter.
      default java.lang.String join​(AFunction<T,​java.lang.Object> preparer, java.lang.String delimer)
      Joins elements into a string with the specified delimiter and element preparer.
      default java.lang.String join​(java.lang.String delimer)
      Joins elements into a string with the specified delimiter.
      default void join​(java.lang.StringBuilder sb)
      Joins elements into a StringBuilder.
      default java.lang.String join​(java.lang.String delim, java.lang.String prefix, java.lang.String postfix)
      Joins elements into a string with delimiters and surrounding strings.
      default java.lang.String joinD()
      Joins elements into a string with comma delimiters.
      default void joinD​(AString sb)
      Joins elements into an AString with comma delimiters.
      default void joinD​(java.lang.StringBuilder sb)
      Joins elements into a StringBuilder with comma delimiters.
      default java.lang.String joinN()
      Joins elements into a string with newline delimiters.
      default Flow<T> limit​(int i)
      Limits the flow to a maximum number of elements.
      default <E> @NotNull Flow<E> map​(@NotNull AFunction<T,​E> f)
      Maps elements using the provided function.
      default @NotNull FlowBoolean mapToBoolean​(@NotNull AFunctionO2Bool<T> f)
      Maps elements to boolean values.
      default @NotNull FlowInt mapToInt​(@NotNull AFunctionO2I<T> f)
      Maps elements to integer values.
      default @NotNull FlowLong mapToLong​(@NotNull AFunctionO2L<T> f)
      Maps elements to long values.
      default @NotNull FlowShort mapToShort​(@NotNull AFunctionO2S<T> f)  
      default Flow<java.lang.String> mapToString()
      Maps elements to their string representations.
      default @NotNull Flow<java.lang.Class<? extends T>> mapToType()
      Maps non-null elements to their runtime class.
      default <E> Flow<E> mapToType​(java.lang.Class<E> t)
      Casts elements to the specified type.
      default java.util.Optional<T> max​(AComparator<T> comparator)
      Returns the maximum element according to the provided comparator.
      default java.util.Optional<T> max​(AFunction<T,​java.lang.Comparable> comparable)
      Returns the maximum element according to the provided comparable function.
      default java.util.Optional<T> min​(AComparator<T> comparator)
      Returns the minimum element according to the provided comparator.
      default java.util.Optional<T> min​(AFunction<T,​java.lang.Comparable> comparable)
      Returns the minimum element according to the provided comparable function.
      default boolean noneMatch​(APredicate<T> p)
      Returns whether no elements of this flow match the provided predicate.
      default boolean noneMatchObj​(java.lang.Object p)
      Returns whether no elements of this flow are equal to the given object.
      default Flow<T> onDone​(java.lang.Runnable t)
      Executes an action when the flow is exhausted.
      default T random()
      Returns a random element from the flow.
      default <E extends java.util.Collection<T>>
      E
      removeFromCollection​(E collection)
      Removes elements from a collection.
      default Flow<T> reverse()
      Reverses the order of elements in the flow.
      default void run()
      Consumes all elements in the flow.
      default @NotNull Flow<T> setTo​(AConsumer<java.util.Set<T>> c)
      Collects elements into a set and applies an action to it.
      default @NotNull Flow<T> shuffle()
      Randomly shuffles the elements in the flow.
      default Flow<T> skip​(int count)
      Skips the first N elements of the flow.
      default Flow<T> skipLast​(int count)
      Skips the last N elements of the flow.
      default @NotNull Flow<T> sort​(@NotNull AComparator<T> comparator)
      Sorts elements according to the provided comparator.
      default @NotNull Flow<T> sort​(@NotNull java.util.Comparator<T> comparator)
      Sorts elements according to the provided comparator.
      default void split​(java.util.Collection<T> ifTrue, java.util.Collection<T> ifFalse, java.util.Collection<T> ifCenter, Flow.SplitComparator<T> p)
      Splits elements into three collections based on comparator results.
      default void to​(AConsumer<T> consumer)
      Performs an action for each element.
      default <T2> void to​(T2 arg, ABiConsumer<T2,​T> consumer)
      Performs an action for each element with an additional argument.
      default @NotNull java.lang.Object[] toArray()
      Collects elements into an object array.
      default @NotNull T[] toArray​(@NotNull java.lang.Class<? super T> arrayType)
      Collects elements into an array of the specified type.
      default <K> @NotNull java.util.Map<K,​T> toCMapExtractKey​(AFunction<T,​K> keyFactory)
      Collects elements into a concurrent map using a key extraction function.
      default <E extends java.util.Collection<T>>
      E
      toCollection​(E collection)
      Collects elements into a collection.
      default @NotNull it.unimi.dsi.fastutil.objects.ObjectImmutableList<T> toImmutableList()
      Collects elements into an immutable list.
      default @NotNull java.lang.Iterable<T> toIterable()
      Converts the flow to an iterable.
      default @NotNull java.util.List<T> toList()
      Collects elements into a list.
      default <K,​V>
      @NotNull java.util.Map<K,​V>
      toMap​(AFunction<T,​K> keyFactory, AFunction<T,​V> valFactory)
      Collects elements into a map using key and value extraction functions.
      default <K,​V>
      @NotNull java.util.Map<K,​V>
      toMap​(java.util.Map<K,​V> map, AFunction<T,​K> keyFactory, AFunction<T,​V> valFactory)
      Collects elements into a map using key and value extraction functions.
      default <K> @NotNull java.util.Map<K,​T> toMapExtractKey​(AFunction<T,​K> keyFactory)
      Collects elements into a map using a key extraction function.
      default <K> @NotNull java.util.Map<K,​T> toMapExtractKey​(java.util.Map<K,​T> map, AFunction<T,​K> keyFactory)
      Collects elements into a map using a key extraction function.
      default <V> @NotNull it.unimi.dsi.fastutil.ints.Int2ObjectMap<V> toMapI2O​(AFunctionO2I<T> keyFactory, AFunction<T,​V> valFactory)
      Collects elements into an int-to-object map.
      default <V> @NotNull it.unimi.dsi.fastutil.longs.Long2ObjectMap<V> toMapL2O​(AFunctionO2L<T> keyFactory, AFunction<T,​V> valFactory)
      Collects elements into a long-to-object map.
      default <K> @NotNull it.unimi.dsi.fastutil.objects.Object2IntMap<K> toMapO2I​(AFunction<T,​K> keyFactory, AFunctionO2I<T> valFactory)
      Collects elements into an object-to-int map.
      default @NotNull java.util.Set<T> toSet()
      Collects elements into a set.
      default @NotNull java.util.function.Supplier<T> toSupplier()
      Converts the flow to a supplier.
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
      • Methods inherited from interface java.util.Iterator

        forEachRemaining, hasNext, next, remove
    • Field Detail

      • RANDOM

        static final java.util.Random RANDOM
        Shared random instance used for operations like shuffle() and random()
      • EMPTY

        static final Flow<?> EMPTY
        An empty flow singleton instance.
    • Method Detail

      • iterator

        @NotNull
        default @NotNull java.util.Iterator<T> iterator()
        Returns an iterator over elements of type T.
        Specified by:
        iterator in interface java.lang.Iterable<T>
        Returns:
        an Iterator
      • anyMatch

        default boolean anyMatch​(APredicate<T> p)
        Returns whether any elements of this flow match the provided predicate.
        Parameters:
        p - the predicate to apply to elements
        Returns:
        true if any elements match the predicate, false otherwise
      • noneMatch

        default boolean noneMatch​(APredicate<T> p)
        Returns whether no elements of this flow match the provided predicate.
        Parameters:
        p - the predicate to apply to elements
        Returns:
        true if no elements match the predicate, false otherwise
      • add

        default Flow<T> add​(T value)
        Appends an element to the end of this flow.
        Parameters:
        value - the element to append
        Returns:
        a new flow containing all elements of this flow plus the appended element
      • noneMatchObj

        default boolean noneMatchObj​(java.lang.Object p)
        Returns whether no elements of this flow are equal to the given object.
        Parameters:
        p - the object to compare against
        Returns:
        true if no elements equal the object, false otherwise
      • anyMatchObj

        default boolean anyMatchObj​(T p)
        Returns whether any element of this flow equals the given object.
        Parameters:
        p - the object to compare against
        Returns:
        true if any element equals the object, false otherwise
      • min

        default java.util.Optional<T> min​(AFunction<T,​java.lang.Comparable> comparable)
        Returns the minimum element according to the provided comparable function.
        Parameters:
        comparable - function that extracts the comparable key
        Returns:
        Optional containing the minimum element, or empty if flow is empty
      • allMatch

        default boolean allMatch​(APredicate<T> p)
        Returns whether all elements of this flow match the provided predicate.
        Parameters:
        p - the predicate to apply to elements
        Returns:
        true if all elements match the predicate or flow is empty, false otherwise
      • mapToString

        default Flow<java.lang.String> mapToString()
        Maps elements to their string representations.
        Returns:
        a new flow of string elements
      • toArray

        @NotNull
        default @NotNull T[] toArray​(@NotNull
                                     @NotNull java.lang.Class<? super T> arrayType)
        Collects elements into an array of the specified type.
        Parameters:
        arrayType - the component type of the array
        Returns:
        an array containing all elements of this flow
      • sort

        @NotNull
        default @NotNull Flow<T> sort​(@NotNull
                                      @NotNull java.util.Comparator<T> comparator)
        Sorts elements according to the provided comparator.
        Parameters:
        comparator - the comparator to determine element order
        Returns:
        a new sorted flow
      • flatMap1

        @NotNull
        default <E> @NotNull Flow<E> flatMap1​(@NotNull
                                              @NotNull AFunctionO2Iterable<T,​E> f)
        Maps each element to an iterable and flattens the results.
        Type Parameters:
        E - the type of elements in the resulting flow
        Parameters:
        f - function that maps elements to iterables
        Returns:
        a new flow of flattened elements
      • mapToType

        @NotNull
        default @NotNull Flow<java.lang.Class<? extends T>> mapToType()
        Maps non-null elements to their runtime class.
        Returns:
        a new flow of class objects
      • mapToType

        default <E> Flow<E> mapToType​(java.lang.Class<E> t)
        Casts elements to the specified type.
        Type Parameters:
        E - the target type
        Parameters:
        t - the target type class object
        Returns:
        a flow of casted elements
      • map

        @NotNull
        default <E> @NotNull Flow<E> map​(@NotNull
                                         @NotNull AFunction<T,​E> f)
        Maps elements using the provided function.
        Type Parameters:
        E - the type of elements in the resulting flow
        Parameters:
        f - the mapping function
        Returns:
        a new flow of mapped elements
      • onDone

        default Flow<T> onDone​(java.lang.Runnable t)
        Executes an action when the flow is exhausted.
        Parameters:
        t - the action to execute
        Returns:
        a new flow with the done handler
      • random

        default T random()
        Returns a random element from the flow.
        Returns:
        a random element or null if flow is empty
      • mapToLong

        @NotNull
        default @NotNull FlowLong mapToLong​(@NotNull
                                            @NotNull AFunctionO2L<T> f)
        Maps elements to long values.
        Parameters:
        f - the mapping function
        Returns:
        a new flow of long values
      • split

        default void split​(java.util.Collection<T> ifTrue,
                           java.util.Collection<T> ifFalse,
                           java.util.Collection<T> ifCenter,
                           Flow.SplitComparator<T> p)
        Splits elements into three collections based on comparator results.
        Parameters:
        ifTrue - collection for elements with positive comparison
        ifFalse - collection for elements with negative comparison
        ifCenter - collection for elements with zero comparison
        p - the splitting comparator
      • mapToBoolean

        @NotNull
        default @NotNull FlowBoolean mapToBoolean​(@NotNull
                                                  @NotNull AFunctionO2Bool<T> f)
        Maps elements to boolean values.
        Parameters:
        f - the mapping function
        Returns:
        a new flow of boolean values
      • mapToInt

        @NotNull
        default @NotNull FlowInt mapToInt​(@NotNull
                                          @NotNull AFunctionO2I<T> f)
        Maps elements to integer values.
        Parameters:
        f - the mapping function
        Returns:
        a new flow of integer values
      • apply

        @NotNull
        default @NotNull Flow<T> apply​(AConsumer<T> c)
        Applies an action to each element while passing through the elements.
        Parameters:
        c - the action to apply
        Returns:
        a new flow with the applied action
      • filterByType

        @NotNull
        default <E> @NotNull Flow<E> filterByType​(java.lang.Class<E> predicate)
        Filters elements by type.
        Type Parameters:
        E - the target type
        Parameters:
        predicate - the type to filter by
        Returns:
        a new flow containing only elements of the specified type
      • filterNotType

        @NotNull
        default @NotNull Flow<T> filterNotType​(java.lang.Class<?> predicate)
        Filters out elements of the specified type.
        Parameters:
        predicate - the type to exclude
        Returns:
        a new flow without elements of the specified type
      • addAllEls

        default <E extends TFlow<T> addAllEls​(E... values)
        Appends multiple elements to the end of this flow.
        Type Parameters:
        E - the type of elements to append
        Parameters:
        values - the elements to append
        Returns:
        a new flow with appended elements
      • addAll

        default Flow<T> addAll​(Flow<? extends T> values)
        Appends all elements from another flow.
        Parameters:
        values - the flow to append
        Returns:
        a new flow combining elements from both flows
      • addAll

        default Flow<T> addAll​(java.util.Iterator<? extends T> values)
        Appends all elements from an iterator.
        Parameters:
        values - the iterator to append
        Returns:
        a new flow combining elements from both sources
      • addAll

        default Flow<T> addAll​(java.lang.Iterable<? extends T> values)
        Appends all elements from an iterable.
        Parameters:
        values - the iterable to append
        Returns:
        a new flow combining elements from both sources
      • flatMap2

        @NotNull
        default <E> @NotNull Flow<E> flatMap2​(@NotNull
                                              @NotNull AFunctionO2Array<T,​E> f)
        Maps each element to an array and flattens the results.
        Type Parameters:
        E - the type of elements in the resulting flow
        Parameters:
        f - function that maps elements to arrays
        Returns:
        a new flow of flattened elements
      • flatMap3

        @NotNull
        default <E> @NotNull Flow<E> flatMap3​(@NotNull
                                              @NotNull AFunctionO2Stream<T,​E> f)
        Maps each element to a stream and flattens the results.
        Type Parameters:
        E - the type of elements in the resulting flow
        Parameters:
        f - function that maps elements to streams
        Returns:
        a new flow of flattened elements
      • sort

        @NotNull
        default @NotNull Flow<T> sort​(@NotNull
                                      @NotNull AComparator<T> comparator)
        Sorts elements according to the provided comparator.
        Parameters:
        comparator - the comparator to determine element order
        Returns:
        a new sorted flow
      • run

        default void run()
        Consumes all elements in the flow.
      • foreach

        default void foreach​(AConsumer<T> c)
        Performs an action for each element in the flow.
        Parameters:
        c - the action to perform
      • ifError

        default Flow<T> ifError​(AFunction<java.lang.Throwable,​T> f)
        Handles errors by applying a fallback function.
        Parameters:
        f - the error handling function
        Returns:
        a new flow with error handling
      • flatMap4

        @NotNull
        default <E> @NotNull Flow<E> flatMap4​(@NotNull
                                              @NotNull AFunctionO2Iterator<T,​E> f)
        Maps each element to an iterator and flattens the results.
        Type Parameters:
        E - the type of elements in the resulting flow
        Parameters:
        f - function that maps elements to iterators
        Returns:
        a new flow of flattened elements
      • reverse

        default Flow<T> reverse()
        Reverses the order of elements in the flow.
        Returns:
        a new flow with elements in reverse order
      • flatMap

        @NotNull
        default <E> @NotNull Flow<E> flatMap​(@NotNull
                                             @NotNull ABiConsumer<T,​AConsumer<E>> f)
        Maps each element to multiple elements using a consumer-based approach.
        Type Parameters:
        E - the type of elements in the resulting flow
        Parameters:
        f - the flat mapping function
        Returns:
        a new flow of flattened elements
      • setTo

        @NotNull
        default @NotNull Flow<T> setTo​(AConsumer<java.util.Set<T>> c)
        Collects elements into a set and applies an action to it.
        Parameters:
        c - the action to apply to the set
        Returns:
        the original flow
      • toArray

        @NotNull
        default @NotNull java.lang.Object[] toArray()
        Collects elements into an object array.
        Returns:
        an array containing all elements
      • toCollection

        default <E extends java.util.Collection<T>> E toCollection​(@NotNull
                                                                   E collection)
        Collects elements into a collection.
        Type Parameters:
        E - the collection type
        Parameters:
        collection - the target collection
        Returns:
        the populated collection
      • removeFromCollection

        default <E extends java.util.Collection<T>> E removeFromCollection​(@NotNull
                                                                           E collection)
        Removes elements from a collection.
        Type Parameters:
        E - the collection type
        Parameters:
        collection - the collection to remove from
        Returns:
        the modified collection
      • filter

        @NotNull
        default @NotNull Flow<T> filter​(@Nullable
                                        @Nullable APredicate<T> predicate)
        Filters elements based on a predicate.
        Parameters:
        predicate - the filtering predicate
        Returns:
        a new flow containing only matching elements
      • limit

        default Flow<T> limit​(int i)
        Limits the flow to a maximum number of elements.
        Parameters:
        i - the maximum number of elements
        Returns:
        a new truncated flow
      • filterNotNull

        @NotNull
        default @NotNull Flow<T> filterNotNull()
        Filters out null elements.
        Returns:
        a new flow without null elements
      • filterExclude

        @NotNull
        default @NotNull Flow<T> filterExclude​(T value)
        Filters out elements equal to the specified value.
        Parameters:
        value - the value to exclude
        Returns:
        a new flow without matching elements
      • filterNot

        @NotNull
        default @NotNull Flow<T> filterNot​(@Nullable
                                           @Nullable APredicate<T> predicate)
        Filters elements that don't match the predicate.
        Parameters:
        predicate - the filtering predicate
        Returns:
        a new flow containing only non-matching elements
      • ifEmpty

        @NotNull
        default @NotNull Flow<T> ifEmpty​(ARunnable task)
        Executes an action if the flow is empty.
        Parameters:
        task - the action to execute
        Returns:
        a new flow with the empty handler
      • joinD

        default void joinD​(java.lang.StringBuilder sb)
        Joins elements into a StringBuilder with comma delimiters.
        Parameters:
        sb - the StringBuilder to append to
      • joinD

        default void joinD​(AString sb)
        Joins elements into an AString with comma delimiters.
        Parameters:
        sb - the AString to append to
      • cast

        default <E> Flow<E> cast​(@NotNull
                                 @NotNull java.lang.Class<E> type)
        Casts elements to the specified type.
        Type Parameters:
        E - the target type
        Parameters:
        type - the target type class
        Returns:
        a flow of casted elements
      • errorIf

        default Flow<T> errorIf​(APredicate<T> conditions)
        Throws an exception if any element matches the condition.
        Parameters:
        conditions - the condition predicate
        Returns:
        a flow with error checking
      • ifEmpty

        @NotNull
        default @NotNull Flow<T> ifEmpty​(java.lang.Exception error)
        Throws the specified exception if the flow is empty.
        Parameters:
        error - the exception to throw
        Returns:
        a flow with empty checking
      • shuffle

        @NotNull
        default @NotNull Flow<T> shuffle()
        Randomly shuffles the elements in the flow.
        Returns:
        a new flow with shuffled elements
      • ignoreError

        @NotNull
        default @NotNull Flow<T> ignoreError​(java.lang.Class<? extends java.lang.Exception> ee)
        Ignores exceptions of the specified type.
        Parameters:
        ee - the exception type to ignore
        Returns:
        a flow with exception handling
      • toList

        @NotNull
        default @NotNull java.util.List<T> toList()
        Collects elements into a list.
        Returns:
        a new list containing all elements
      • toIterable

        @NotNull
        default @NotNull java.lang.Iterable<T> toIterable()
        Converts the flow to an iterable.
        Returns:
        an iterable view of the flow
      • toImmutableList

        @NotNull
        default @NotNull it.unimi.dsi.fastutil.objects.ObjectImmutableList<T> toImmutableList()
        Collects elements into an immutable list.
        Returns:
        an immutable list containing all elements
      • toSet

        @NotNull
        default @NotNull java.util.Set<T> toSet()
        Collects elements into a set.
        Returns:
        a new set containing all elements
      • isNotEmpty

        default boolean isNotEmpty()
        Returns whether the flow contains any elements.
        Returns:
        true if flow has elements, false otherwise
      • max

        default java.util.Optional<T> max​(AFunction<T,​java.lang.Comparable> comparable)
        Returns the maximum element according to the provided comparable function.
        Parameters:
        comparable - function that extracts the comparable key
        Returns:
        Optional containing the maximum element, or empty if flow is empty
      • to

        default <T2> void to​(T2 arg,
                             ABiConsumer<T2,​T> consumer)
        Performs an action for each element with an additional argument.
        Type Parameters:
        T2 - the type of the additional argument
        Parameters:
        arg - the additional argument
        consumer - the action to perform
      • to

        default void to​(AConsumer<T> consumer)
        Performs an action for each element.
        Parameters:
        consumer - the action to perform
      • toSupplier

        @NotNull
        default @NotNull java.util.function.Supplier<T> toSupplier()
        Converts the flow to a supplier.
        Returns:
        a supplier that provides elements sequentially
      • toMapExtractKey

        @NotNull
        default <K> @NotNull java.util.Map<K,​T> toMapExtractKey​(AFunction<T,​K> keyFactory)
        Collects elements into a map using a key extraction function.
        Type Parameters:
        K - the key type
        Parameters:
        keyFactory - function to extract map keys from elements
        Returns:
        a new map with elements as values
      • toCMapExtractKey

        @NotNull
        default <K> @NotNull java.util.Map<K,​T> toCMapExtractKey​(AFunction<T,​K> keyFactory)
        Collects elements into a concurrent map using a key extraction function.
        Type Parameters:
        K - the key type
        Parameters:
        keyFactory - function to extract map keys from elements
        Returns:
        a new concurrent map with elements as values
      • toMapExtractKey

        @NotNull
        default <K> @NotNull java.util.Map<K,​T> toMapExtractKey​(java.util.Map<K,​T> map,
                                                                      AFunction<T,​K> keyFactory)
        Collects elements into a map using a key extraction function.
        Type Parameters:
        K - the key type
        Parameters:
        map - the target map
        keyFactory - function to extract map keys from elements
        Returns:
        the populated map
      • toMap

        @NotNull
        default <K,​V> @NotNull java.util.Map<K,​V> toMap​(AFunction<T,​K> keyFactory,
                                                                    AFunction<T,​V> valFactory)
        Collects elements into a map using key and value extraction functions.
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        keyFactory - function to extract map keys from elements
        valFactory - function to extract map values from elements
        Returns:
        a new map with extracted keys and values
      • toMap

        @NotNull
        default <K,​V> @NotNull java.util.Map<K,​V> toMap​(java.util.Map<K,​V> map,
                                                                    AFunction<T,​K> keyFactory,
                                                                    AFunction<T,​V> valFactory)
        Collects elements into a map using key and value extraction functions.
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        map - the target map
        keyFactory - function to extract map keys from elements
        valFactory - function to extract map values from elements
        Returns:
        the populated map
      • toMapI2O

        @NotNull
        default <V> @NotNull it.unimi.dsi.fastutil.ints.Int2ObjectMap<V> toMapI2O​(AFunctionO2I<T> keyFactory,
                                                                                  AFunction<T,​V> valFactory)
        Collects elements into an int-to-object map.
        Type Parameters:
        V - the value type
        Parameters:
        keyFactory - function to extract integer keys from elements
        valFactory - function to extract values from elements
        Returns:
        a new int-to-object map
      • toMapO2I

        @NotNull
        default <K> @NotNull it.unimi.dsi.fastutil.objects.Object2IntMap<K> toMapO2I​(AFunction<T,​K> keyFactory,
                                                                                     AFunctionO2I<T> valFactory)
        Collects elements into an object-to-int map.
        Type Parameters:
        K - the key type
        Parameters:
        keyFactory - function to extract keys from elements
        valFactory - function to extract integer values from elements
        Returns:
        a new object-to-int map
      • toMapL2O

        @NotNull
        default <V> @NotNull it.unimi.dsi.fastutil.longs.Long2ObjectMap<V> toMapL2O​(AFunctionO2L<T> keyFactory,
                                                                                    AFunction<T,​V> valFactory)
        Collects elements into a long-to-object map.
        Type Parameters:
        V - the value type
        Parameters:
        keyFactory - function to extract long keys from elements
        valFactory - function to extract values from elements
        Returns:
        a new long-to-object map
      • joinD

        default java.lang.String joinD()
        Joins elements into a string with comma delimiters.
        Returns:
        the joined string
      • join

        default java.lang.String join​(java.lang.String delimer)
        Joins elements into a string with the specified delimiter.
        Parameters:
        delimer - the delimiter string
        Returns:
        the joined string
      • joinN

        default java.lang.String joinN()
        Joins elements into a string with newline delimiters.
        Returns:
        the joined string
      • join

        default void join​(AString sb,
                          java.lang.String delimer)
        Joins elements into an AString with the specified delimiter.
        Parameters:
        sb - the AString to append to
        delimer - the delimiter string
      • errorIf

        default Flow<T> errorIf​(APredicate<T> conditions,
                                java.lang.Runnable throwCode)
        Throws an exception using the provided runnable if any element matches the condition.
        Parameters:
        conditions - the condition predicate
        throwCode - the exception throwing runnable
        Returns:
        a flow with error checking
      • errorIf

        default Flow<T> errorIf​(APredicate<T> conditions,
                                java.util.function.Consumer<T> throwCode)
        Throws an exception using the provided consumer if any element matches the condition.
        Parameters:
        conditions - the condition predicate
        throwCode - the exception throwing consumer
        Returns:
        a flow with error checking
      • errorIf

        default Flow<T> errorIf​(APredicate<T> conditions,
                                java.lang.Class<? extends java.lang.Throwable> throwCode)
        Throws an exception of the specified type if any element matches the condition.
        Parameters:
        conditions - the condition predicate
        throwCode - the exception class to throw
        Returns:
        a flow with error checking
      • distinct

        default Flow<T> distinct()
        Returns a flow with distinct elements.
        Returns:
        a new flow with duplicates removed
      • join

        default java.lang.String join​(AFunction<T,​java.lang.Object> preparer,
                                      java.lang.String delimer)
        Joins elements into a string with the specified delimiter and element preparer.
        Parameters:
        preparer - function to prepare elements for joining
        delimer - the delimiter string
        Returns:
        the joined string
      • getFirstOrNull

        default T getFirstOrNull()
        Returns the first element or null if empty.
        Returns:
        the first element or null
      • getFirst

        default T getFirst()
        Returns the first element or throws if empty.
        Returns:
        the first element
        Throws:
        java.util.NoSuchElementException - if flow is empty
      • getFirst

        default T getFirst​(APredicate<T> p)
        Returns the first matching element or throws if none match.
        Parameters:
        p - the filtering predicate
        Returns:
        the first matching element
        Throws:
        java.util.NoSuchElementException - if no elements match
      • getFirstOrNull

        default T getFirstOrNull​(APredicate<T> p)
        Returns the first matching element or null if none match.
        Parameters:
        p - the filtering predicate
        Returns:
        the first matching element or null
      • join

        default java.lang.String join()
        Joins elements into a string without delimiters.
        Returns:
        the joined string
      • join

        default java.lang.String join​(java.lang.String delim,
                                      java.lang.String prefix,
                                      java.lang.String postfix)
        Joins elements into a string with delimiters and surrounding strings.
        Parameters:
        delim - the delimiter string
        prefix - the prefix string
        postfix - the postfix string
        Returns:
        the joined string
      • crossSelf

        default void crossSelf​(ABiConsumer<T,​T> consumer)
        Performs an action for each unique pair of elements (excluding self-pairs).
        Parameters:
        consumer - the action to perform for each pair
      • crossSelf

        default void crossSelf​(ABiPredicate<T,​T> p,
                               ABiConsumer<T,​T> consumer)
        Performs an action for each unique pair of elements that satisfy the predicate.
        Parameters:
        p - the pair predicate
        consumer - the action to perform for matching pairs
      • min

        default java.util.Optional<T> min​(AComparator<T> comparator)
        Returns the minimum element according to the provided comparator.
        Parameters:
        comparator - the comparator to determine order
        Returns:
        Optional containing the minimum element, or empty if flow is empty
      • max

        default java.util.Optional<T> max​(AComparator<T> comparator)
        Returns the maximum element according to the provided comparator.
        Parameters:
        comparator - the comparator to determine order
        Returns:
        Optional containing the maximum element, or empty if flow is empty
      • isEmpty

        default boolean isEmpty()
        Returns whether the flow is empty.
        Returns:
        true if flow has no elements, false otherwise
      • skipLast

        default Flow<T> skipLast​(int count)
        Skips the last N elements of the flow.
        Parameters:
        count - the number of elements to skip
        Returns:
        a new flow without the last N elements
      • skip

        default Flow<T> skip​(int count)
        Skips the first N elements of the flow.
        Parameters:
        count - the number of elements to skip
        Returns:
        a new flow without the first N elements
      • count

        default int count()
        Counts the number of elements in the flow.
        Returns:
        the element count
      • allMap

        default <R> R allMap​(AFunction<Flow<T>,​R> f)
        Applies a function to the entire flow.
        Type Parameters:
        R - the result type
        Parameters:
        f - the function to apply
        Returns:
        the function result
      • join

        default void join​(java.lang.StringBuilder sb)
        Joins elements into a StringBuilder.
        Parameters:
        sb - the StringBuilder to append to
      • flow

        @NotNull
        static <T> @NotNull Flow<T> flow​(@NotNull
                                         @NotNull Flow<T> stream)
        Creates a flow from another flow (identity function).
        Type Parameters:
        T - the element type
        Parameters:
        stream - the source flow
        Returns:
        the same flow
      • flow

        @NotNull
        static @NotNull Flow<java.lang.String> flow​(@NotNull
                                                    @NotNull java.lang.String... ss)
        Creates a flow from string values.
        Parameters:
        ss - the string values
        Returns:
        a new string flow
      • flowArray

        @SafeVarargs
        static <T> Flow<T> flowArray​(@NotNull
                                     @NotNull T... ss)
        Creates a flow from array values.
        Type Parameters:
        T - the element type
        Parameters:
        ss - the array values
        Returns:
        a new flow
      • flow

        @NotNull
        static <T> @NotNull Flow<T> flow​(@NotNull
                                         @NotNull T[] array)
        Creates a flow from an array.
        Type Parameters:
        T - the element type
        Parameters:
        array - the source array
        Returns:
        a new flow
      • flow

        @NotNull
        static @NotNull FlowLong flow​(long @NotNull [] array)
        Creates a long flow from a long array.
        Parameters:
        array - the source array
        Returns:
        a new long flow
      • flow

        static FlowInt flow​(int number)
        Creates an integer flow representing a range.
        Parameters:
        number - the range end (exclusive)
        Returns:
        a new integer flow
      • flow

        static FlowInt flow​(int @NotNull [] array)
        Creates an integer flow from an int array.
        Parameters:
        array - the source array
        Returns:
        a new integer flow
      • flow

        static FlowShort flow​(short @NotNull [] array)
        Creates a short flow from a short array.
        Parameters:
        array - the source array
        Returns:
        a new short flow
      • flow

        @NotNull
        static @NotNull FlowByte flow​(byte @NotNull [] array)
        Creates a byte flow from a byte array.
        Parameters:
        array - the source array
        Returns:
        a new byte flow
      • flow

        @NotNull
        static <T> @NotNull Flow<T> flow​(@NotNull
                                         @NotNull java.lang.Iterable<T> iterable)
        Creates a flow from an iterable.
        Type Parameters:
        T - the element type
        Parameters:
        iterable - the source iterable
        Returns:
        a new flow
      • flow

        @NotNull
        static @NotNull FlowLong flow​(@NotNull
                                      @NotNull it.unimi.dsi.fastutil.longs.LongIterable iterable)
        Creates a long flow from a long iterable.
        Parameters:
        iterable - the source iterable
        Returns:
        a new long flow
      • flow

        @NotNull
        static @NotNull FlowInt flow​(@NotNull
                                     @NotNull it.unimi.dsi.fastutil.ints.IntIterable iterable)
        Creates an integer flow from an int iterable.
        Parameters:
        iterable - the source iterable
        Returns:
        a new integer flow
      • flow

        @NotNull
        static @NotNull FlowLong flow​(@NotNull
                                      @NotNull it.unimi.dsi.fastutil.longs.LongSet collection)
        Creates a long flow from a long set.
        Parameters:
        collection - the source set
        Returns:
        a new long flow
      • flow

        @NotNull
        static <T> @NotNull Flow<T> flow​(@NotNull
                                         @NotNull java.util.Set<T> collection)
        Creates a flow from a set.
        Type Parameters:
        T - the element type
        Parameters:
        collection - the source set
        Returns:
        a new flow
      • flow

        @NotNull
        static @NotNull FlowLong flow​(@NotNull
                                      @NotNull it.unimi.dsi.fastutil.longs.LongList collection)
        Creates a long flow from a long list.
        Parameters:
        collection - the source list
        Returns:
        a new long flow
      • flow

        @NotNull
        static @NotNull FlowInt flow​(@NotNull
                                     @NotNull it.unimi.dsi.fastutil.ints.IntList collection)
        Creates an integer flow from an int list.
        Parameters:
        collection - the source list
        Returns:
        a new integer flow
      • flow

        @NotNull
        static <T> @NotNull Flow<T> flow​(@NotNull
                                         @NotNull java.util.List<T> collection)
        Creates a flow from a list.
        Type Parameters:
        T - the element type
        Parameters:
        collection - the source list
        Returns:
        a new flow
      • flow

        @NotNull
        static <T> @NotNull Flow<T> flow​(@NotNull
                                         @NotNull java.util.Collection<T> collection)
        Creates a flow from a collection.
        Type Parameters:
        T - the element type
        Parameters:
        collection - the source collection
        Returns:
        a new flow
      • flow

        @NotNull
        static <T> @NotNull Flow<T> flow​(@NotNull
                                         @NotNull ASupplier<T> supplier)
        Creates a flow from a supplier.
        Type Parameters:
        T - the element type
        Parameters:
        supplier - the element supplier
        Returns:
        a new flow
      • flow

        @NotNull
        static @NotNull FlowLong flow​(@NotNull
                                      @NotNull it.unimi.dsi.fastutil.longs.LongIterator iterator)
        Creates a long flow from a long iterator.
        Parameters:
        iterator - the source iterator
        Returns:
        a new long flow
      • flow

        @NotNull
        static <T> @NotNull Flow<T> flow​(@NotNull
                                         @NotNull java.util.Iterator<T> iterator)
        Creates a flow from an iterator.
        Type Parameters:
        T - the element type
        Parameters:
        iterator - the source iterator
        Returns:
        a new flow
      • flow

        @NotNull
        static <K,​V> @NotNull Flow<java.util.Map.Entry<K,​V>> flow​(@NotNull
                                                                              @NotNull java.util.Map<K,​V> map)
        Creates a flow from a map's entry set.
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        map - the source map
        Returns:
        a new flow of map entries
      • flow

        static <T> Flow<T> flow()
        Creates an empty flow.
        Type Parameters:
        T - the element type
        Returns:
        an empty flow