Interface SetIterable<T>

    • Method Detail

      • union

        SetIterable<T> union​(SetIterable<? extends T> set)
        Returns the set of all objects that are a member of this or set or both. The union of [1, 2, 3] and [2, 3, 4] is the set [1, 2, 3, 4]. If equal elements appear in both sets, then the output will contain the copy from this.
      • unionInto

        <R extends Set<T>> R unionInto​(SetIterable<? extends T> set,
                                       R targetSet)
        Same as union(SetIterable) but adds all the objects to targetSet and returns it.
      • intersect

        SetIterable<T> intersect​(SetIterable<? extends T> set)
        Returns the set of all objects that are members of both this and set. The intersection of [1, 2, 3] and [2, 3, 4] is the set [2, 3]. The output will contain instances from this, not set.
      • difference

        SetIterable<T> difference​(SetIterable<? extends T> subtrahendSet)
        Returns the set of all members of this that are not members of subtrahendSet. The difference of [1, 2, 3] and [2, 3, 4] is [1].
      • differenceInto

        <R extends Set<T>> R differenceInto​(SetIterable<? extends T> subtrahendSet,
                                            R targetSet)
        Same as difference(SetIterable) but adds all the objects to targetSet and returns it.
      • symmetricDifference

        SetIterable<T> symmetricDifference​(SetIterable<? extends T> setB)
        Returns the set of all objects that are a member of exactly one of this and setB (elements which are in one of the sets, but not in both). For instance, for the sets [1, 2, 3] and [2, 3, 4], the symmetric difference set is [1, 4] . It is the set difference of the union and the intersection.
      • isSubsetOf

        boolean isSubsetOf​(SetIterable<? extends T> candidateSuperset)
        Returns true if all the members of this are also members of candidateSuperset. For example, [1, 2] is a subset of [1, 2, 3], but [1, 4] is not.
      • isProperSubsetOf

        boolean isProperSubsetOf​(SetIterable<? extends T> candidateSuperset)
        Returns true if all the members of this are also members of candidateSuperset and the two sets are not equal. For example, [1, 2] is a proper subset of [1, 2, 3], but [1, 2, 3] is not.
      • cartesianProduct

        <B> LazyIterable<Pair<T,​B>> cartesianProduct​(SetIterable<B> set)
        Returns the set whose members are all possible ordered pairs (a, b) where a is a member of this and b is a member of set.
      • select

        SetIterable<T> select​(Predicate<? super T> predicate)
        Description copied from interface: RichIterable
        Returns all elements of the source collection that return true when evaluating the predicate. This method is also commonly called filter.

        Example using a Java 8 lambda expression:

         RichIterable<Person> selected =
             people.select(person -> person.getAddress().getCity().equals("London"));
         
        Specified by:
        select in interface RichIterable<T>
      • selectWith

        <P> SetIterable<T> selectWith​(Predicate2<? super T,​? super P> predicate,
                                      P parameter)
        Description copied from interface: RichIterable
        Similar to RichIterable.select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

        E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years

        Example using a Java 8 lambda expression:

         RichIterable<Person> selected =
             people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18));
         
        Specified by:
        selectWith in interface RichIterable<T>
        Parameters:
        predicate - a Predicate2 to use as the select criteria
        parameter - a parameter to pass in for evaluation of the second argument P in predicate
        See Also:
        RichIterable.select(Predicate)
      • reject

        SetIterable<T> reject​(Predicate<? super T> predicate)
        Description copied from interface: RichIterable
        Returns all elements of the source collection that return false when evaluating of the predicate. This method is also sometimes called filterNot and is the equivalent of calling iterable.select(Predicates.not(predicate)).

        Example using a Java 8 lambda expression:

         RichIterable<Person> rejected =
             people.reject(person -> person.person.getLastName().equals("Smith"));
         
        Specified by:
        reject in interface RichIterable<T>
        Parameters:
        predicate - a Predicate to use as the reject criteria
        Returns:
        a RichIterable that contains elements that cause Predicate.accept(Object) method to evaluate to false
      • rejectWith

        <P> SetIterable<T> rejectWith​(Predicate2<? super T,​? super P> predicate,
                                      P parameter)
        Description copied from interface: RichIterable
        Similar to RichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

        E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years

        Example using a Java 8 lambda expression:

         RichIterable<Person> rejected =
             people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18));
         
        Specified by:
        rejectWith in interface RichIterable<T>
        Parameters:
        predicate - a Predicate2 to use as the select criteria
        parameter - a parameter to pass in for evaluation of the second argument P in predicate
        See Also:
        RichIterable.select(Predicate)
      • partition

        PartitionSet<T> partition​(Predicate<? super T> predicate)
        Description copied from interface: RichIterable
        Filters a collection into a PartitionedIterable based on the evaluation of the predicate.

        Example using a Java 8 lambda expression:

         PartitionIterable<Person> newYorkersAndNonNewYorkers =
             people.partition(person -> person.getAddress().getState().getName().equals("New York"));
         
        Specified by:
        partition in interface RichIterable<T>
      • partitionWith

        <P> PartitionSet<T> partitionWith​(Predicate2<? super T,​? super P> predicate,
                                          P parameter)
        Description copied from interface: RichIterable
        Filters a collection into a PartitionIterable based on the evaluation of the predicate.

        Example using a Java 8 lambda expression:

         PartitionIterable<Person> newYorkersAndNonNewYorkers =
             people.partitionWith((Person person, String state) -> person.getAddress().getState().getName().equals(state), "New York");
         
        Specified by:
        partitionWith in interface RichIterable<T>
      • selectInstancesOf

        <S> SetIterable<S> selectInstancesOf​(Class<S> clazz)
        Description copied from interface: RichIterable
        Returns all elements of the source collection that are instances of the Class clazz.
         RichIterable<Integer> integers =
             List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);
         
        Specified by:
        selectInstancesOf in interface RichIterable<T>