Top Description Methods
org.eclipse.collections.api.set

public Interface UnsortedSetIterable<T>

extends SetIterable<T>
Known Direct Subinterfaces
org.eclipse.collections.api.set.ImmutableSet, org.eclipse.collections.api.set.MutableSet
Imports
java.util.concurrent.ExecutorService, org.eclipse.collections.api.block.function.Function, .Function2, org.eclipse.collections.api.block.function.primitive.BooleanFunction, .ByteFunction, .CharFunction, .DoubleFunction, .FloatFunction, .IntFunction, .LongFunction, .ShortFunction, org.eclipse.collections.api.block.predicate.Predicate, .Predicate2, org.eclipse.collections.api.block.procedure.Procedure, org.eclipse.collections.api.multimap.set.UnsortedSetMultimap, org.eclipse.collections.api.ordered.OrderedIterable, org.eclipse.collections.api.set.primitive.BooleanSet, .ByteSet, .CharSet, .DoubleSet, .FloatSet, .IntSet, .LongSet, .ShortSet, org.eclipse.collections.api.tuple.Pair

An iterable whose items are unique.

Method Summary

Modifier and TypeMethod and Description
public ParallelUnsortedSetIterable<T>
asParallel(ExecutorService executorService, int batchSize)

Redeclares org.eclipse.collections.api.set.SetIterable.asParallel.

Returns a parallel iterable of this SetIterable.

public <V> UnsortedSetIterable<V>
collect(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.RichIterable.collect.

Returns a new collection with the results of applying the specified function on each element of the source collection.

public BooleanSet
collectBoolean(BooleanFunction<? super T> booleanFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectBoolean.

Returns a new primitive boolean iterable with the results of applying the specified function on each element of the source collection.

public ByteSet
collectByte(ByteFunction<? super T> byteFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectByte.

Returns a new primitive byte iterable with the results of applying the specified function on each element of the source collection.

public CharSet
collectChar(CharFunction<? super T> charFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectChar.

Returns a new primitive char iterable with the results of applying the specified function on each element of the source collection.

public DoubleSet
collectDouble(DoubleFunction<? super T> doubleFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectDouble.

Returns a new primitive double iterable with the results of applying the specified function on each element of the source collection.

public FloatSet
collectFloat(FloatFunction<? super T> floatFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectFloat.

Returns a new primitive float iterable with the results of applying the specified function on each element of the source collection.

public <V> UnsortedSetIterable<V>
collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.RichIterable.collectIf.

Returns a new collection with the results of applying the specified function on each element of the source collection, but only for those elements which return true upon evaluation of the predicate.

public IntSet
collectInt(IntFunction<? super T> intFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectInt.

Returns a new primitive int iterable with the results of applying the specified function on each element of the source collection.

public LongSet
collectLong(LongFunction<? super T> longFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectLong.

Returns a new primitive long iterable with the results of applying the specified function on each element of the source collection.

public ShortSet
collectShort(ShortFunction<? super T> shortFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectShort.

Returns a new primitive short iterable with the results of applying the specified function on each element of the source collection.

public <P, V> UnsortedSetIterable<V>
collectWith(Function2<? super T, ? super P, ? extends V> function, P parameter)

Redeclares org.eclipse.collections.api.RichIterable.collectWith.

Same as collect(Function) with a Function2 and specified parameter which is passed to the block.

public UnsortedSetIterable<T>
difference(SetIterable<? extends T> subtrahendSet)

Redeclares org.eclipse.collections.api.set.SetIterable.difference.

Returns the set of all members of this that are not members of subtrahendSet.

public <V> UnsortedSetIterable<V>
flatCollect(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.RichIterable.flatCollect.

flatCollect is a special case of collect(Function).

public default <P, V> UnsortedSetIterable<V>
flatCollectWith(Function2<? super T, ? super P, ? extends Iterable<V>> function, P parameter)

Overrides default org.eclipse.collections.api.RichIterable.flatCollectWith.

Same as flatCollect, only with a Function2 that is passed an extra parameter.

public <V> UnsortedSetMultimap<V, T>
groupBy(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.RichIterable.groupBy.

For each element of the iterable, the function is evaluated and the results of these evaluations are collected into a new multimap, where the transformed value is the key and the original values are added to the same (or similar) species of collection as the source iterable.

public <V> UnsortedSetMultimap<V, T>
groupByEach(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.RichIterable.groupByEach.

Similar to groupBy(Function), except the result of evaluating function will return a collection of keys for each value.

public UnsortedSetIterable<T>
intersect(SetIterable<? extends T> set)

Redeclares org.eclipse.collections.api.set.SetIterable.intersect.

Returns the set of all objects that are members of both this and set.

public UnsortedSetIterable<UnsortedSetIterable<T>>
powerSet()

Returns the set whose members are all possible subsets of this.

public UnsortedSetIterable<T>
reject(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.set.SetIterable.reject.

Returns all elements of the source collection that return false when evaluating of the predicate.

public <P> UnsortedSetIterable<T>
rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.set.SetIterable.rejectWith.

Similar to reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

public UnsortedSetIterable<T>
select(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.set.SetIterable.select.

Returns all elements of the source collection that return true when evaluating the predicate.

public <S> UnsortedSetIterable<S>
selectInstancesOf(Class<S> clazz)

Redeclares org.eclipse.collections.api.set.SetIterable.selectInstancesOf.

Returns all elements of the source collection that are instances of the Class clazz.

public <P> UnsortedSetIterable<T>
selectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.set.SetIterable.selectWith.

Similar to select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

public UnsortedSetIterable<T>
symmetricDifference(SetIterable<? extends T> setB)

Redeclares org.eclipse.collections.api.set.SetIterable.symmetricDifference.

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).

public UnsortedSetIterable<T>
tap(Procedure<? super T> procedure)

Redeclares org.eclipse.collections.api.set.SetIterable.tap.

Executes the Procedure for each element in the iterable and returns this.

public ImmutableSet<T>
toImmutable()

Redeclares org.eclipse.collections.api.set.SetIterable.toImmutable.

Converts the UnsortedSetIterable to an immutable implementation.

public UnsortedSetIterable<T>
union(SetIterable<? extends T> set)

Redeclares org.eclipse.collections.api.set.SetIterable.union.

Returns the set of all objects that are a member of this or set or both.

public <S> UnsortedSetIterable<Pair<T, S>>
zip(Iterable<S> that)

Redeclares org.eclipse.collections.api.RichIterable.zip.

Deprecated in 6.0. Use OrderedIterable#zip(Iterable) instead.

Returns a RichIterable formed from this RichIterable and another RichIterable by combining corresponding elements in pairs.

public UnsortedSetIterable<Pair<T, Integer>>
zipWithIndex()

Redeclares org.eclipse.collections.api.set.SetIterable.zipWithIndex.

Deprecated in 6.0. Use OrderedIterable#zipWithIndex() instead.

Zips this RichIterable with its indices.

Inherited from org.eclipse.collections.api.set.SetIterable:
cartesianProductdifferenceIntoequalshashCodeintersectIntoisProperSubsetOfisSubsetOfpartitionpartitionWithsymmetricDifferenceIntounionInto

Method Detail

asParallelback to summary
public ParallelUnsortedSetIterable<T> asParallel(ExecutorService executorService, int batchSize)

Redeclares org.eclipse.collections.api.set.SetIterable.asParallel.

Doc from org.eclipse.collections.api.set.SetIterable.asParallel.

Returns a parallel iterable of this SetIterable.

Annotations
@Override
collectback to summary
public <V> UnsortedSetIterable<V> collect(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.RichIterable.collect.

Doc from org.eclipse.collections.api.RichIterable.collect.

Returns a new collection with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

RichIterable<String> names =
    people.collect(person -> person.getFirstName() + " " + person.getLastName());
Annotations
@Override
collectBooleanback to summary
public BooleanSet collectBoolean(BooleanFunction<? super T> booleanFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectBoolean.

Doc from org.eclipse.collections.api.RichIterable.collectBoolean.

Returns a new primitive boolean iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

BooleanIterable licenses =
    people.collectBoolean(person -> person.hasDrivingLicense());
Annotations
@Override
collectByteback to summary
public ByteSet collectByte(ByteFunction<? super T> byteFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectByte.

Doc from org.eclipse.collections.api.RichIterable.collectByte.

Returns a new primitive byte iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

ByteIterable bytes =
    people.collectByte(person -> person.getCode());
Annotations
@Override
collectCharback to summary
public CharSet collectChar(CharFunction<? super T> charFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectChar.

Doc from org.eclipse.collections.api.RichIterable.collectChar.

Returns a new primitive char iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

CharIterable chars =
    people.collectChar(person -> person.getMiddleInitial());
Annotations
@Override
collectDoubleback to summary
public DoubleSet collectDouble(DoubleFunction<? super T> doubleFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectDouble.

Doc from org.eclipse.collections.api.RichIterable.collectDouble.

Returns a new primitive double iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

DoubleIterable doubles =
    people.collectDouble(person -> person.getMilesFromNorthPole());
Annotations
@Override
collectFloatback to summary
public FloatSet collectFloat(FloatFunction<? super T> floatFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectFloat.

Doc from org.eclipse.collections.api.RichIterable.collectFloat.

Returns a new primitive float iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

FloatIterable floats =
    people.collectFloat(person -> person.getHeightInInches());
Annotations
@Override
collectIfback to summary
public <V> UnsortedSetIterable<V> collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.RichIterable.collectIf.

Doc from org.eclipse.collections.api.RichIterable.collectIf.

Returns a new collection with the results of applying the specified function on each element of the source collection, but only for those elements which return true upon evaluation of the predicate. This is the optimized equivalent of calling iterable.select(predicate).collect(function).

Example using a Java 8 lambda and method reference:

RichIterable<String> strings = Lists.mutable.with(1, 2, 3).collectIf(e -> e != null, Object::toString);

Example using Predicates factory:

RichIterable<String> strings = Lists.mutable.with(1, 2, 3).collectIf(Predicates.notNull(), Functions.getToString());
Annotations
@Override
collectIntback to summary
public IntSet collectInt(IntFunction<? super T> intFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectInt.

Doc from org.eclipse.collections.api.RichIterable.collectInt.

Returns a new primitive int iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

IntIterable ints =
    people.collectInt(person -> person.getAge());
Annotations
@Override
collectLongback to summary
public LongSet collectLong(LongFunction<? super T> longFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectLong.

Doc from org.eclipse.collections.api.RichIterable.collectLong.

Returns a new primitive long iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

LongIterable longs =
    people.collectLong(person -> person.getGuid());
Annotations
@Override
collectShortback to summary
public ShortSet collectShort(ShortFunction<? super T> shortFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectShort.

Doc from org.eclipse.collections.api.RichIterable.collectShort.

Returns a new primitive short iterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

Example using a Java 8 lambda expression:

ShortIterable shorts =
    people.collectShort(person -> person.getNumberOfJunkMailItemsReceivedPerMonth());
Annotations
@Override
collectWithback to summary
public <P, V> UnsortedSetIterable<V> collectWith(Function2<? super T, ? super P, ? extends V> function, P parameter)

Redeclares org.eclipse.collections.api.RichIterable.collectWith.

Doc from org.eclipse.collections.api.RichIterable.collectWith.

Same as collect(Function) with a Function2 and specified parameter which is passed to the block.

Example using a Java 8 lambda expression:

RichIterable<Integer> integers =
    Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1));
Annotations
@Override
differenceback to summary
public UnsortedSetIterable<T> difference(SetIterable<? extends T> subtrahendSet)

Redeclares org.eclipse.collections.api.set.SetIterable.difference.

Doc from org.eclipse.collections.api.set.SetIterable.difference.

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].

Annotations
@Override
flatCollectback to summary
public <V> UnsortedSetIterable<V> flatCollect(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.RichIterable.flatCollect.

Doc from org.eclipse.collections.api.RichIterable.flatCollect.

flatCollect is a special case of collect(Function). With collect, when the Function returns a collection, the result is a collection of collections. flatCollect outputs a single "flattened" collection instead. This method is commonly called flatMap.

Consider the following example where we have a Person class, and each Person has a list of Address objects. Take the following Function:

Function<Person, List<Address>> addressFunction = Person::getAddresses;
RichIterable<Person> people = ...;
Using collect returns a collection of collections of addresses.
RichIterable<List<Address>> addresses = people.collect(addressFunction);
Using flatCollect returns a single flattened list of addresses.
RichIterable<Address> addresses = people.flatCollect(addressFunction);
Annotations
@Override
flatCollectWithback to summary
public default <P, V> UnsortedSetIterable<V> flatCollectWith(Function2<? super T, ? super P, ? extends Iterable<V>> function, P parameter)

Overrides default org.eclipse.collections.api.RichIterable.flatCollectWith.

Doc from org.eclipse.collections.api.RichIterable.flatCollectWith.

Same as flatCollect, only with a Function2 that is passed an extra parameter.

Annotations
@Override
Since
9.2
groupByback to summary
public <V> UnsortedSetMultimap<V, T> groupBy(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.RichIterable.groupBy.

Doc from org.eclipse.collections.api.RichIterable.groupBy.

For each element of the iterable, the function is evaluated and the results of these evaluations are collected into a new multimap, where the transformed value is the key and the original values are added to the same (or similar) species of collection as the source iterable.

Example using a Java 8 method reference:

Multimap<String, Person> peopleByLastName =
    people.groupBy(Person::getLastName);
Annotations
@Override
groupByEachback to summary
public <V> UnsortedSetMultimap<V, T> groupByEach(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.RichIterable.groupByEach.

Doc from org.eclipse.collections.api.RichIterable.groupByEach.

Similar to groupBy(Function), except the result of evaluating function will return a collection of keys for each value.

Annotations
@Override
intersectback to summary
public UnsortedSetIterable<T> intersect(SetIterable<? extends T> set)

Redeclares org.eclipse.collections.api.set.SetIterable.intersect.

Doc from org.eclipse.collections.api.set.SetIterable.intersect.

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 the smaller of the two sets (this or set) based on the size. If the sizes are equal, the output will contain instances from this.

Note

If you need to ensure that the memory references from this are preserved in the resulting set, consider using this.select(that::contains) instead.

Annotations
@Override
powerSetback to summary
public UnsortedSetIterable<UnsortedSetIterable<T>> powerSet()

Returns the set whose members are all possible subsets of this. For example, the powerset of [1, 2] is [[], [1], [2], [1, 2]].

rejectback to summary
public UnsortedSetIterable<T> reject(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.set.SetIterable.reject.

Doc from org.eclipse.collections.api.RichIterable.reject.

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"));
Annotations
@Override
rejectWithback to summary
public <P> UnsortedSetIterable<T> rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.set.SetIterable.rejectWith.

Doc from org.eclipse.collections.api.RichIterable.rejectWith.

Similar to 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));
Annotations
@Override
selectback to summary
public UnsortedSetIterable<T> select(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.set.SetIterable.select.

Doc from org.eclipse.collections.api.RichIterable.select.

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"));
Annotations
@Override
selectInstancesOfback to summary
public <S> UnsortedSetIterable<S> selectInstancesOf(Class<S> clazz)

Redeclares org.eclipse.collections.api.set.SetIterable.selectInstancesOf.

Doc from org.eclipse.collections.api.RichIterable.selectInstancesOf.

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);
Annotations
@Override
selectWithback to summary
public <P> UnsortedSetIterable<T> selectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.set.SetIterable.selectWith.

Doc from org.eclipse.collections.api.RichIterable.selectWith.

Similar to 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));
Annotations
@Override
symmetricDifferenceback to summary
public UnsortedSetIterable<T> symmetricDifference(SetIterable<? extends T> setB)

Redeclares org.eclipse.collections.api.set.SetIterable.symmetricDifference.

Doc from org.eclipse.collections.api.set.SetIterable.symmetricDifference.

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.

Annotations
@Override
tapback to summary
public UnsortedSetIterable<T> tap(Procedure<? super T> procedure)

Redeclares org.eclipse.collections.api.set.SetIterable.tap.

Doc from org.eclipse.collections.api.RichIterable.tap.

Executes the Procedure for each element in the iterable and returns this.

Example using a Java 8 lambda expression:

RichIterable<Person> tapped =
    people.tap(person -> LOGGER.info(person.getName()));
Annotations
@Override
toImmutableback to summary
public ImmutableSet<T> toImmutable()

Redeclares org.eclipse.collections.api.set.SetIterable.toImmutable.

Converts the UnsortedSetIterable to an immutable implementation. Returns this for immutable sets.

Annotations
@Override
Since
5.0
unionback to summary
public UnsortedSetIterable<T> union(SetIterable<? extends T> set)

Redeclares org.eclipse.collections.api.set.SetIterable.union.

Doc from org.eclipse.collections.api.set.SetIterable.union.

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.

Annotations
@Override
zipback to summary
public <S> UnsortedSetIterable<Pair<T, S>> zip(Iterable<S> that)

Redeclares org.eclipse.collections.api.RichIterable.zip.

Doc from org.eclipse.collections.api.RichIterable.zip.

Deprecated

in 6.0. Use OrderedIterable#zip(Iterable) instead.

Returns a RichIterable formed from this RichIterable and another RichIterable by combining corresponding elements in pairs. If one of the two RichIterables is longer than the other, its remaining elements are ignored.

Annotations
@Override
@Deprecated
zipWithIndexback to summary
public UnsortedSetIterable<Pair<T, Integer>> zipWithIndex()

Redeclares org.eclipse.collections.api.set.SetIterable.zipWithIndex.

Doc from org.eclipse.collections.api.RichIterable.zipWithIndex.

Deprecated

in 6.0. Use OrderedIterable#zipWithIndex() instead.

Zips this RichIterable with its indices.

Annotations
@Override
@Deprecated