Class Filtered<X>

  • Type Parameters:
    X - Type of item
    All Implemented Interfaces:
    Iterable<X>

    public final class Filtered<X>
    extends IterableEnvelope<X>
    Filtered iterable.

    You can use it in order to create a declarative/lazy version of a filtered collection/iterable. For example, this code will create a list of two strings "hello" and "world":

     Iterable<String> list = new Filtered<>(
       new ArrayOf<>(
         "hey", "hello", "world"
       ),
       input -> input.length() > 4
     );
     

    There is no thread-safety guarantee.

    Since:
    0.1
    See Also:
    Filtered
    • Constructor Detail

      • Filtered

        @SafeVarargs
        public Filtered​(Func<? super X,​Boolean> fnc,
                        X... src)
        Ctor.
        Parameters:
        fnc - Predicate
        src - Source iterable
        Since:
        0.21
      • Filtered

        public Filtered​(Func<? super X,​Boolean> fnc,
                        Iterable<? extends X> src)
        Ctor.
        Parameters:
        fnc - Predicate
        src - Source iterable
      • Filtered

        public Filtered​(Iterable<? extends X> src,
                        Func<? super X,​Scalar<Boolean>> fnc)
        Ctor.
        Parameters:
        src - Source iterable
        fnc - Predicate