public abstract class AbstractMutableBagIterable<T> extends AbstractBag<T> implements com.gs.collections.api.bag.MutableBagIterable<T>
| Constructor and Description |
|---|
AbstractMutableBagIterable() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addAll(java.util.Collection<? extends T> source) |
boolean |
addAllIterable(java.lang.Iterable<? extends T> iterable) |
<K,V> com.gs.collections.api.map.MutableMap<K,V> |
aggregateBy(com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.function.Function2<? super V,? super T,? extends V> nonMutatingAggregator)
Applies an aggregate function over the iterable grouping results into a map based on the specific groupBy function.
|
<K,V> com.gs.collections.api.map.MutableMap<K,V> |
aggregateInPlaceBy(com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy,
com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory,
com.gs.collections.api.block.procedure.Procedure2<? super V,? super T> mutatingAggregator)
Applies an aggregate procedure over the iterable grouping results into a Map based on the specific groupBy function.
|
boolean |
allSatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty.
|
<P> boolean |
allSatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter)
Returns true if the predicate evaluates to true for every element of the collection, or returns false.
|
boolean |
anySatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns true if the predicate evaluates to true for any element of the iterable.
|
<P> boolean |
anySatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter)
Returns true if the predicate evaluates to true for any element of the collection, or return false.
|
com.gs.collections.api.list.MutableList<com.gs.collections.api.tuple.primitive.ObjectIntPair<T>> |
bottomOccurrences(int n)
Returns the
count least frequently occurring items. |
com.gs.collections.api.RichIterable<com.gs.collections.api.RichIterable<T>> |
chunk(int size)
Partitions elements in fixed size chunks.
|
T |
detect(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no
element returns true.
|
T |
detectIfNone(com.gs.collections.api.block.predicate.Predicate<? super T> predicate,
com.gs.collections.api.block.function.Function0<? extends T> function)
Returns the first element of the iterable for which the predicate evaluates to true.
|
<P> T |
detectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter)
Returns the first element that evaluates to true for the specified predicate2 and parameter, or null if none
evaluate to true.
|
<P> T |
detectWithIfNone(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter,
com.gs.collections.api.block.function.Function0<? extends T> function)
Returns the first element of the iterable that evaluates to true for the specified predicate2 and parameter, or
returns the value of evaluating the specified function.
|
T |
getFirst()
Returns the first element of an iterable.
|
protected abstract com.gs.collections.api.RichIterable<T> |
getKeysView() |
T |
getLast()
Returns the last element of an iterable.
|
<V> com.gs.collections.api.map.MutableMap<V,T> |
groupByUniqueKey(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
For each element of the iterable, the function is evaluated and he results of these evaluations are collected
into a new map, where the transformed value is the key.
|
T |
max()
Returns the maximum element out of this container based on the natural order.
|
T |
max(java.util.Comparator<? super T> comparator)
Returns the maximum element out of this container based on the comparator.
|
<V extends java.lang.Comparable<? super V>> |
maxBy(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
Returns the maximum elements out of this container based on the natural order of the attribute returned by Function.
|
T |
min()
Returns the minimum element out of this container based on the natural order.
|
T |
min(java.util.Comparator<? super T> comparator)
Returns the minimum element out of this container based on the comparator.
|
<V extends java.lang.Comparable<? super V>> |
minBy(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
Returns the minimum elements out of this container based on the natural order of the attribute returned by Function.
|
boolean |
noneSatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty.
|
<P> boolean |
noneSatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter)
Returns true if the predicate evaluates to false for every element of the collection, or return false.
|
boolean |
removeAll(java.util.Collection<?> collection) |
boolean |
retainAll(java.util.Collection<?> collection) |
boolean |
retainAllIterable(java.lang.Iterable<?> iterable) |
<P> com.gs.collections.api.tuple.Twin<com.gs.collections.api.list.MutableList<T>> |
selectAndRejectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate,
P parameter)
Filters a collection into two separate collections based on a predicate returned via a Pair.
|
com.gs.collections.api.list.MutableList<com.gs.collections.api.tuple.primitive.ObjectIntPair<T>> |
topOccurrences(int n)
Returns the
count most frequently occurring items. |
collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, count, flatCollect, groupBy, groupByEach, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoWith, occurrencesSortingBy, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toListWithOccurrences, toSet, toSortedBag, toSortedBag, toSortedList, toSortedSet, toSortedSet, toStringOfItemToCountappendString, appendString, appendString, asLazy, contains, containsAll, containsAllArguments, containsAllIterable, countWith, forEach, forEachWith, forEachWithIndex, groupByUniqueKey, isEmpty, makeString, makeString, makeString, notEmpty, sumByDouble, sumByFloat, sumByInt, sumByLong, toArray, toArray, toMap, toSortedBagBy, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSetBy, toString, zip, zipWithIndexclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddOccurrences, groupBy, groupByEach, partition, partitionWith, reject, rejectWith, removeOccurrences, select, selectByOccurrences, selectInstancesOf, selectWith, setOccurrences, tap, toMapOfItemToCount, with, withAll, without, withoutAll, zipWithIndexequals, forEachWithOccurrences, hashCode, occurrencesOf, sizeDistinct, toImmutable, toStringOfItemToCountasSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, flatCollect, injectIntoWith, newEmpty, removeAllIterable, removeIf, removeIfWith, toImmutable, zipadd, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, size, toArray, toArrayappendString, appendString, appendString, asLazy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, each, flatCollect, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, isEmpty, makeString, makeString, makeString, notEmpty, reject, rejectWith, select, selectWith, size, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexprotected abstract com.gs.collections.api.RichIterable<T> getKeysView()
public boolean addAll(java.util.Collection<? extends T> source)
addAll in interface java.util.Collection<T>public boolean addAllIterable(java.lang.Iterable<? extends T> iterable)
addAllIterable in interface com.gs.collections.api.collection.MutableCollection<T>Collection.addAll(Collection)public boolean removeAll(java.util.Collection<?> collection)
removeAll in interface java.util.Collection<T>public boolean retainAll(java.util.Collection<?> collection)
retainAll in interface java.util.Collection<T>public boolean retainAllIterable(java.lang.Iterable<?> iterable)
retainAllIterable in interface com.gs.collections.api.collection.MutableCollection<T>Collection.retainAll(Collection)public <P> com.gs.collections.api.tuple.Twin<com.gs.collections.api.list.MutableList<T>> selectAndRejectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.collection.MutableCollection
e.g. return lastNames.selectAndRejectWith(PredicatesLite.lessThan(), "Mason");
selectAndRejectWith in interface com.gs.collections.api.collection.MutableCollection<T>public T getFirst()
com.gs.collections.api.RichIterableThe order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the first element could be any element from the Set.
getFirst in interface com.gs.collections.api.RichIterable<T>public T getLast()
com.gs.collections.api.RichIterableThe order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the last element could be any element from the Set.
getLast in interface com.gs.collections.api.RichIterable<T>public <V> com.gs.collections.api.map.MutableMap<V,T> groupByUniqueKey(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
com.gs.collections.api.RichIterablepublic com.gs.collections.api.RichIterable<com.gs.collections.api.RichIterable<T>> chunk(int size)
com.gs.collections.api.RichIterablechunk in interface com.gs.collections.api.RichIterable<T>size - the number of elements per chunkRichIterable containing RichIterables of size size, except the last will be
truncated if the elements don't divide evenly.public T detect(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.RichIterableExample using a Java 8 lambda expression:
Person person =
people.detect(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));
Example using an anonymous inner class:
Person person =
people.detect(new Predicate<Person>()
{
public boolean value(Person person)
{
return person.getFirstName().equals("John") && person.getLastName().equals("Smith");
}
});
detect in interface com.gs.collections.api.RichIterable<T>detect in class AbstractRichIterable<T>public <P> T detectWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.RichIterableExample using a Java 8 lambda expression:
Person person =
people.detectWith((person, fullName) -> person.getFullName().equals(fullName), "John Smith");
Example using an anonymous inner class:
Person person =
people.detectWith(new Predicate2<Person, String>()
{
public boolean value(Person person, String fullName)
{
return person.getFullName().equals(fullName);
}
}, "John Smith");
detectWith in interface com.gs.collections.api.RichIterable<T>detectWith in class AbstractRichIterable<T>public T detectIfNone(com.gs.collections.api.block.predicate.Predicate<? super T> predicate, com.gs.collections.api.block.function.Function0<? extends T> function)
com.gs.collections.api.RichIterabledetectIfNone in interface com.gs.collections.api.RichIterable<T>detectIfNone in class AbstractRichIterable<T>public <P> T detectWithIfNone(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter, com.gs.collections.api.block.function.Function0<? extends T> function)
com.gs.collections.api.RichIterabledetectWithIfNone in interface com.gs.collections.api.RichIterable<T>detectWithIfNone in class AbstractRichIterable<T>public boolean anySatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.RichIterableanySatisfy in interface com.gs.collections.api.RichIterable<T>anySatisfy in class AbstractRichIterable<T>public <P> boolean anySatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.RichIterableanySatisfyWith in interface com.gs.collections.api.RichIterable<T>anySatisfyWith in class AbstractRichIterable<T>public boolean allSatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.RichIterableallSatisfy in interface com.gs.collections.api.RichIterable<T>allSatisfy in class AbstractRichIterable<T>public <P> boolean allSatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.RichIterableallSatisfyWith in interface com.gs.collections.api.RichIterable<T>allSatisfyWith in class AbstractRichIterable<T>public boolean noneSatisfy(com.gs.collections.api.block.predicate.Predicate<? super T> predicate)
com.gs.collections.api.RichIterablenoneSatisfy in interface com.gs.collections.api.RichIterable<T>noneSatisfy in class AbstractRichIterable<T>public <P> boolean noneSatisfyWith(com.gs.collections.api.block.predicate.Predicate2<? super T,? super P> predicate, P parameter)
com.gs.collections.api.RichIterablenoneSatisfyWith in interface com.gs.collections.api.RichIterable<T>noneSatisfyWith in class AbstractRichIterable<T>public T min()
com.gs.collections.api.RichIterablemin in interface com.gs.collections.api.RichIterable<T>min in class AbstractRichIterable<T>public T min(java.util.Comparator<? super T> comparator)
com.gs.collections.api.RichIterablemin in interface com.gs.collections.api.RichIterable<T>min in class AbstractRichIterable<T>public <V extends java.lang.Comparable<? super V>> T minBy(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
com.gs.collections.api.RichIterableminBy in interface com.gs.collections.api.RichIterable<T>minBy in class AbstractRichIterable<T>public T max()
com.gs.collections.api.RichIterablemax in interface com.gs.collections.api.RichIterable<T>max in class AbstractRichIterable<T>public T max(java.util.Comparator<? super T> comparator)
com.gs.collections.api.RichIterablemax in interface com.gs.collections.api.RichIterable<T>max in class AbstractRichIterable<T>public <V extends java.lang.Comparable<? super V>> T maxBy(com.gs.collections.api.block.function.Function<? super T,? extends V> function)
com.gs.collections.api.RichIterablemaxBy in interface com.gs.collections.api.RichIterable<T>maxBy in class AbstractRichIterable<T>public <K,V> com.gs.collections.api.map.MutableMap<K,V> aggregateInPlaceBy(com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy, com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory, com.gs.collections.api.block.procedure.Procedure2<? super V,? super T> mutatingAggregator)
com.gs.collections.api.RichIterablepublic <K,V> com.gs.collections.api.map.MutableMap<K,V> aggregateBy(com.gs.collections.api.block.function.Function<? super T,? extends K> groupBy, com.gs.collections.api.block.function.Function0<? extends V> zeroValueFactory, com.gs.collections.api.block.function.Function2<? super V,? super T,? extends V> nonMutatingAggregator)
com.gs.collections.api.RichIterablepublic com.gs.collections.api.list.MutableList<com.gs.collections.api.tuple.primitive.ObjectIntPair<T>> topOccurrences(int n)
com.gs.collections.api.bag.Bagcount most frequently occurring items.
In the event of a tie, all of the items with the number of occurrences that match the occurrences of the last
item will be returned.public com.gs.collections.api.list.MutableList<com.gs.collections.api.tuple.primitive.ObjectIntPair<T>> bottomOccurrences(int n)
com.gs.collections.api.bag.Bagcount least frequently occurring items.
In the event of a tie, all of the items with the number of occurrences that match the occurrences of the last
item will be returned.