| Access | Constructor and Description |
|---|---|
| public |
| AbstractMutableBag | back to summary |
|---|---|
| public AbstractMutableBag() | |
| asParallel | back to summary |
|---|---|
public ParallelUnsortedBag
| |
| asSynchronized | back to summary |
|---|---|
| public SynchronizedBag Implements org. Doc from org. Returns a synchronized wrapper backed by this collection. This is the equivalent of using
MutableCollection synchedCollection = collection.asSynchronized();
...
synchedCollection.forEach(each -> ... );
synchedCollection.select(each -> ... );
synchedCollection.collect(each -> ... );
If you want to iterate using an imperative style, you must protect external iterators using
a synchronized block. This includes explicit iterators as well as JDK 5 style for loops.
| |
| asUnmodifiable | back to summary |
|---|---|
| public UnmodifiableBag Implements org. Doc from org. Returns an unmodifiable view of this collection. This is the equivalent of using
| |
| collect | back to summary |
|---|---|
| public <V> MutableBag Implements org. Doc from org. 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());
| |
| collectIf | back to summary |
|---|---|
| public <V> MutableBag Implements org. Doc from org. 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());
| |
| collectWith | back to summary |
|---|---|
| public <P, V> MutableBag Implements org. Doc from org. Same as Example using a Java 8 lambda expression:
RichIterable<Integer> integers =
Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1));
| |
| collectWithOccurrences | back to summary |
|---|---|
| public <V> MutableBag Implements org. Doc from org. Iterates over the unique elements and their occurrences and collects the results of applying the specified function.
| |
| countBy | back to summary |
|---|---|
| public <V> MutableBag Overrides org. Overrides default org. Doc from org. This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.
| |
| countByEach | back to summary |
|---|---|
| public <V> MutableBag Overrides org. Overrides default org. Doc from org. This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.
| |
| countByWith | back to summary |
|---|---|
| public <V, P> MutableBag Overrides org. Overrides default org. Doc from org. This method will count the number of occurrences of each value calculated by applying the function to each element of the collection with the specified parameter as the second argument.
| |
| flatCollect | back to summary |
|---|---|
| public <V> MutableBag Implements org. Doc from org.
Consider the following example where we have a 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);
| |
| partition | back to summary |
|---|---|
| public PartitionMutableBag Implements org. Doc from org. 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"));
| |
| partitionWith | back to summary |
|---|---|
| public <P> PartitionMutableBag Implements org. Doc from org. 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");
| |
| reject | back to summary |
|---|---|
| public MutableBag Implements org. Doc from org. 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"));
| |
| rejectWith | back to summary |
|---|---|
| public <P> MutableBag Implements org. Doc from org. Similar to
E.g. return a Example using a Java 8 lambda expression:
RichIterable<Person> rejected =
people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18));
| |
| select | back to summary |
|---|---|
| public MutableBag Implements org. Doc from org. 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"));
| |
| selectInstancesOf | back to summary |
|---|---|
| public <S> MutableBag Implements org. Doc from org. Returns all elements of the source collection that are instances of the Class
RichIterable<Integer> integers =
List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);
| |
| selectWith | back to summary |
|---|---|
| public <P> MutableBag Implements org. Doc from org. Similar to
E.g. return a Example using a Java 8 lambda expression:
RichIterable<Person> selected =
people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18));
| |
| tap | back to summary |
|---|---|
| public MutableBag Implements org. Doc from org. Executes the Procedure for each element in the iterable and returns Example using a Java 8 lambda expression:
RichIterable<Person> tapped =
people.tap(person -> LOGGER.info(person.getName()));
| |
| toImmutable | back to summary |
|---|---|
| public ImmutableBag Implements org. Doc from org. Converts this
| |
| zip | back to summary |
|---|---|
| public <S> MutableBag Implements org. Doc from org. Deprecated in 6.0. Use Returns a
| |
| zipWithIndex | back to summary |
|---|---|
| public MutableSet Implements org. Doc from org. Deprecated in 6.0. Use Zips this
| |