| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: updated number of occurrences.Add number of |
| public MutableList | bottomOccurrences(int count)
Redeclares org. Returns the |
| public <V> RichIterable | collectWithOccurrences(ObjectIntToObjectFunction<? super T, ? extends V> function)
Redeclares org. Iterates over the unique elements and their occurrences and collects the results of applying the specified function. |
| public <V> MutableBagIterableMultimap | groupBy(Function<? super T, ? extends V> function)
Redeclares org. 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> MutableBagIterableMultimap | groupByEach(Function<? super T, ? extends Iterable<V>> function)
Redeclares org. Similar to |
| public PartitionMutableBagIterable | partition(Predicate<? super T> predicate)
Redeclares org. Filters a collection into a PartitionedIterable based on the evaluation of the predicate. |
| public <P> PartitionMutableBagIterable | partitionWith(Predicate2<? super T, ? super P> predicate, P parameter)
Redeclares org. Filters a collection into a PartitionIterable based on the evaluation of the predicate. |
| public MutableBagIterable | reject(Predicate<? super T> predicate)
Redeclares org. Returns a MutableCollection with all elements that evaluate to false for the specified predicate. |
| public <P> MutableBagIterable | rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)
Redeclares org. Returns a MutableCollection with all elements that evaluate to false for the specified predicate2 and parameter. |
| public boolean | |
| public MutableBagIterable | select(Predicate<? super T> predicate)
Redeclares org. Returns a MutableCollection with all elements that evaluate to true for the specified predicate. |
| public MutableBagIterable | selectByOccurrences(IntPredicate predicate)
Redeclares org. Returns all elements of the bag that have a number of occurrences that satisfy the predicate. |
| public default MutableBagIterable | selectDuplicates()
Overrides default org. Returns all elements of the bag that have more than one occurrence. |
| public <S> MutableBagIterable | selectInstancesOf(Class<S> clazz)
Redeclares org. Returns all elements of the source collection that are instances of the Class |
| public MutableSetIterable | selectUnique()
Redeclares org. Returns a set containing all elements of the bag that have exactly one occurrence. |
| public <P> MutableBagIterable | selectWith(Predicate2<? super T, ? super P> predicate, P parameter)
Redeclares org. Returns a MutableCollection with all elements that evaluate to true for the specified predicate2 and parameter. |
| public boolean | |
| public MutableBagIterable | tap(Procedure<? super T> procedure)
Redeclares org. Executes the Procedure for each element in the iterable and returns |
| public MutableMapIterable | toMapOfItemToCount()
Redeclares org. Converts the Bag to a Map of the Item type to its count as an Integer. |
| public MutableList | topOccurrences(int count)
Redeclares org. Returns the |
| public default MutableBagIterable | with(T element)
Implements org. This method allows mutable and fixed size collections the ability to add elements to their existing elements. |
| public default MutableBagIterable | withAll(Iterable<? extends T> elements)
Implements org. This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements. |
| public default MutableBagIterable | |
| public default MutableBagIterable | without(T element)
Implements org. This method allows mutable and fixed size collections the ability to remove elements from their existing elements. |
| public default MutableBagIterable | withoutAll(Iterable<? extends T> elements)
Implements org. This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements. |
| public default MutableBagIterable | |
| public MutableSetIterable | zipWithIndex()
Redeclares org. Zips this |
| addOccurrences | back to summary |
|---|---|
| public int addOccurrences(T item, int occurrences) Add number of For Example:
MutableBagIterable<String> names = Bags.mutable.of("A", "B", "B");
Assert.assertEquals(4, names.addOccurrences("A", 3));
| |
| bottomOccurrences | back to summary |
|---|---|
| public MutableList Redeclares org. Doc from org. Returns the
| |
| collectWithOccurrences | back to summary |
|---|---|
| public <V> RichIterable Redeclares org. Doc from org. Iterates over the unique elements and their occurrences and collects the results of applying the specified function.
| |
| groupBy | back to summary |
|---|---|
| public <V> MutableBagIterableMultimap Redeclares org. Doc from org. 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);
Co-variant example for MutableCollection:
MutableMultimap<String, Person> peopleByLastName =
people.groupBy(Person::getLastName);
| |
| groupByEach | back to summary |
|---|---|
| public <V> MutableBagIterableMultimap Redeclares org. Doc from org. Similar to
| |
| partition | back to summary |
|---|---|
| public PartitionMutableBagIterable Redeclares 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"));
Co-variant example for MutableCollection:
PartitionMutableCollection<Person> newYorkersAndNonNewYorkers =
people.partition(person -> person.getAddress().getState().getName().equals("New York"));
| |
| partitionWith | back to summary |
|---|---|
| public <P> PartitionMutableBagIterable Redeclares 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");
Co-variant example for MutableCollection:
PartitionMutableCollection<Person> newYorkersAndNonNewYorkers =
people.partitionWith((Person person, String state) -> person.getAddress().getState().getName().equals(state), "New York");
| |
| reject | back to summary |
|---|---|
| public MutableBagIterable Redeclares org. Doc from org. Returns a MutableCollection with all elements that evaluate to false for the specified predicate.
MutableCollection<Person> notSmiths =
people.reject(person -> person.person.getLastName().equals("Smith"));
Using the Predicates factory:
MutableCollection<Person> notSmiths = people.reject(Predicates.attributeEqual("lastName", "Smith"));
| |
| rejectWith | back to summary |
|---|---|
| public <P> MutableBagIterable Redeclares org. Doc from org. Returns a MutableCollection with all elements that evaluate to false for the specified predicate2 and parameter. e.g.
MutableCollection<Integer> selected =
integers.rejectWith(Predicates2.equal(), Integer.valueOf(5));
| |
| removeOccurrences | back to summary |
|---|---|
| public boolean removeOccurrences(Object item, int occurrences) | |
| select | back to summary |
|---|---|
| public MutableBagIterable Redeclares org. Doc from org. Returns a MutableCollection with all elements that evaluate to true for the specified predicate.
MutableCollection<Integer> livesInLondon =
people.select(person -> person.getAddress().getCity().equals("London"));
| |
| selectByOccurrences | back to summary |
|---|---|
| public MutableBagIterable Redeclares org. Doc from org. Returns all elements of the bag that have a number of occurrences that satisfy the predicate.
| |
| selectDuplicates | back to summary |
|---|---|
| public default MutableBagIterable Overrides default org. Doc from org. Returns all elements of the bag that have more than one occurrence.
| |
| selectInstancesOf | back to summary |
|---|---|
| public <S> MutableBagIterable Redeclares 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);
Co-variant example for MutableCollection:
MutableCollection<Integer> integers =
List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);
| |
| selectUnique | back to summary |
|---|---|
| public MutableSetIterable Redeclares org. Doc from org. Returns a set containing all elements of the bag that have exactly one occurrence.
| |
| selectWith | back to summary |
|---|---|
| public <P> MutableBagIterable Redeclares org. Doc from org. Returns a MutableCollection with all elements that evaluate to true for the specified predicate2 and parameter.
MutableCollection<Integer> fives =
integers.selectWith(Predicates2.equal(), Integer.valueOf(5));
| |
| setOccurrences | back to summary |
|---|---|
| public boolean setOccurrences(T item, int occurrences) | |
| tap | back to summary |
|---|---|
| public MutableBagIterable Redeclares 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()));
| |
| toMapOfItemToCount | back to summary |
|---|---|
| public MutableMapIterable Redeclares org. Doc from org. Converts the Bag to a Map of the Item type to its count as an Integer.
| |
| topOccurrences | back to summary |
|---|---|
| public MutableList Redeclares org. Doc from org. Returns the
| |
| with | back to summary |
|---|---|
| public default MutableBagIterable Implements org. Doc from org. This method allows mutable and fixed size collections the ability to add elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new element to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
MutableCollection<String> list = list.with("1");
list = list.with("2");
return list;
In the case of FixedSizeCollection a new instance of MutableCollection will be returned by with, and any
variables that previously referenced the original collection will need to be redirected to reference the
new instance. For other MutableCollection types you will replace the reference to collection with the same
collection, since the instance will return "this" after calling add on itself.
| |
| withAll | back to summary |
|---|---|
| public default MutableBagIterable Implements org. Doc from org. This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new elements to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
MutableCollection<String> list = list.withAll(FastList.newListWith("1", "2"));
In the case of FixedSizeCollection a new instance of MutableCollection will be returned by withAll, and
any variables that previously referenced the original collection will need to be redirected to reference the
new instance. For other MutableCollection types you will replace the reference to collection with the same
collection, since the instance will return "this" after calling addAll on itself.
| |
| withOccurrences | back to summary |
|---|---|
| public default MutableBagIterable | |
| without | back to summary |
|---|---|
| public default MutableBagIterable Implements org. Doc from org. This method allows mutable and fixed size collections the ability to remove elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling remove. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
MutableCollection<String> list = list.without("1");
list = list.without("2");
return list;
In the case of FixedSizeCollection a new instance of MutableCollection will be returned by without, and
any variables that previously referenced the original collection will need to be redirected to reference the
new instance. For other MutableCollection types you will replace the reference to collection with the same
collection, since the instance will return "this" after calling remove on itself.
| |
| withoutAll | back to summary |
|---|---|
| public default MutableBagIterable Implements org. Doc from org. This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling removeAll. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
MutableCollection<String> list = list.withoutAll(FastList.newListWith("1", "2"));
In the case of FixedSizeCollection a new instance of MutableCollection will be returned by withoutAll,
and any variables that previously referenced the original collection will need to be redirected to reference the
new instance. For other MutableCollection types you will replace the reference to collection with the same
collection, since the instance will return "this" after calling removeAll on itself.
| |
| withoutOccurrences | back to summary |
|---|---|
| public default MutableBagIterable | |
| zipWithIndex | back to summary |
|---|---|
| public MutableSetIterable Redeclares org. Doc from org. Zips this
| |