Class TreeBag<T>
java.lang.Object
org.eclipse.collections.impl.AbstractRichIterable<T>
org.eclipse.collections.impl.bag.AbstractBag<T>
org.eclipse.collections.impl.bag.mutable.AbstractMutableBagIterable<T>
org.eclipse.collections.impl.bag.sorted.mutable.AbstractMutableSortedBag<T>
org.eclipse.collections.impl.bag.sorted.mutable.TreeBag<T>
- All Implemented Interfaces:
Externalizable, Serializable, Cloneable, Comparable<SortedBag<T>>, Iterable<T>, Collection<T>, Bag<T>, MutableBagIterable<T>, MutableSortedBag<T>, SortedBag<T>, MutableCollection<T>, InternalIterable<T>, OrderedIterable<T>, ReversibleIterable<T>, SortedIterable<T>, RichIterable<T>
A TreeBag is a MutableSortedBag which uses a SortedMap as its underlying data store. Each key in the SortedMap represents some item,
and the value in the map represents the current number of occurrences of that item.
- Since:
- 4.2
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate MutableSortedMap<T, Counter> private static final longprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanintaddOccurrences(T item, int occurrences) Add number ofoccurrencesfor anitem.booleanallSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate) Returns true if the predicate evaluates to true for all elements of the Bag.booleananySatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate) Returns true if the predicate evaluates to true for any element of the Bag.voidclear()clone()Comparator<? super T> Returns the comparator used to order the elements in this bag, or null if this bag uses the natural ordering of its elements.intbooleanReturns true if the iterable has an element which responds true to element.equals(object).<S> booleancorresponds(OrderedIterable<S> other, Predicate2<? super T, ? super S> predicate) Returns true if both OrderedIterables have the same length andpredicatereturns true for all corresponding elements e1 of thisOrderedIterableand e2 ofother.intdetectIndex(Predicate<? super T> predicate) Returns the index of the first element of theOrderedIterablefor which thepredicateevaluates to true.detectWithOccurrences(ObjectIntPredicate<? super T> predicate) Returns an element of the Bag that satisfies the predicate or null if such an element does not existdistinct()Returns a newSortedIterablecontaining the distinct elements in this iterable.Returns an unmodifiable view on the distinct elements with the same complexity as the Bag implementation.drop(int count) Returns an iterable after skipping the firstcountelements or an empty iterable if thecountis greater than the length of the iterable.voidThe procedure is executed for each element in the iterable.booleanTwo bagsb1andb2are equal ifm1.toMapOfItemToCount().equals(m2.toMapOfItemToCount()).voidIterates over the section of the iterable covered by the specified inclusive indexes.<P> voidforEachWith(Procedure2<? super T, ? super P> procedure, P parameter) The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.voidforEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure) Iterates over the section of the iterable covered by the specified inclusive indexes.voidforEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure) Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.voidforEachWithOccurrences(ObjectIntProcedure<? super T> procedure) For each distinct item, with the number of occurrences, execute the specified procedure.protected RichIterable<T> <V> TreeBagMultimap<V, T> 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.<V> TreeBagMultimap<V, T> groupByEach(Function<? super T, ? extends Iterable<V>> function) Similar toRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys for each value.inthashCode()Returns the hash code for this Bag, defined as this.Bag.toMapOfItemToCount().hashCode().intReturns the index of the first occurrence of the specified item in this iterable, or -1 if this iterable does not contain the item.booleanisEmpty()Returns true if this iterable has zero items.iterator()static <E> TreeBag<E> newBag()static <E> TreeBag<E> static <E> TreeBag<E> newBag(Comparator<? super E> comparator) static <E> TreeBag<E> newBag(Comparator<? super E> comparator, Iterable<? extends E> iterable) static <E> TreeBag<E> newBagWith(E... elements) static <E> TreeBag<E> newBagWith(Comparator<? super E> comparator, E... elements) newEmpty()Creates a new empty mutable version of the same collection type.booleannoneSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate) Returns true if the Bag is empty or if the predicate evaluates to false for all elements of the Bag.intoccurrencesOf(Object item) The occurrences of a distinct item in the bag.voidbooleanbooleanremoveAllIterable(Iterable<?> iterable) booleanRemoves all elements in the collection that evaluate to true for the specified predicate.<P> booleanremoveIfWith(Predicate2<? super T, ? super P> predicate, P parameter) Removes all elements in the collection that evaluate to true for the specified predicate2 and parameter.booleanremoveOccurrences(Object item, int occurrences) selectByOccurrences(IntPredicate predicate) Returns all elements of the bag that have a number of occurrences that satisfy the predicate.booleansetOccurrences(T item, int occurrences) intsize()Returns the number of items in this iterable.intThe size of the Bag when counting only distinct elements.take(int count) Returns the firstcountelements of the iterable or all the elements in the iterable ifcountis greater than the length of the iterable.toStack()Converts the OrderedIterable to a mutable MutableStack implementation.This method allows mutable and fixed size collections the ability to add elements to their existing elements.This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements.This method allows mutable and fixed size collections the ability to remove elements from their existing elements.withoutAll(Iterable<? extends T> iterable) This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements.voidZips thisRichIterablewith its indices.Methods inherited from class AbstractMutableSortedBag
asParallel, asSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, collectWithIndex, collectWithIndex, collectWithOccurrences, countBy, countByEach, countByWith, detectLastIndex, dropWhile, flatCollect, partition, partitionWhile, partitionWith, reject, rejectWith, select, selectInstancesOf, selectWith, takeWhile, tap, toImmutable, toMapOfItemToCount, toReversed, zipMethods inherited from class AbstractMutableBagIterable
addAll, addAllBag, addAllIterable, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, bottomOccurrences, chunk, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, getFirst, getLast, groupByUniqueKey, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, removeAll, retainAll, retainAllIterable, selectAndRejectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, topOccurrencesMethods inherited from class AbstractBag
collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, count, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, groupBy, groupByEach, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoWith, occurrencesSortingBy, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toList, toListWithOccurrences, toSet, toSortedBag, toSortedBag, toSortedList, toSortedSet, toSortedSet, toStringOfItemToCountMethods inherited from class AbstractRichIterable
appendString, appendString, asLazy, containsAll, containsAllArguments, containsAllIterable, countWith, forEach, groupByUniqueKey, into, toBiMap, toMap, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSetBy, toString, zip, zipWithIndexMethods inherited from interface Bag
aggregateBy, collectWithOccurrences, reduceBy, reduceInPlace, reduceInPlace, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toStringOfItemToCountMethods inherited from interface Collection
addAll, containsAll, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArrayMethods inherited from interface InternalIterable
forEachMethods inherited from interface MutableBagIterable
bottomOccurrences, selectDuplicates, selectUnique, topOccurrencesMethods inherited from interface MutableCollection
addAllIterable, aggregateBy, aggregateInPlaceBy, flatCollectWith, groupByUniqueKey, injectIntoWith, retainAllIterable, selectAndRejectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, toArray, toArrayMethods inherited from interface MutableSortedBag
flatCollectWith, selectDuplicates, selectUnique, toImmutableSortedBag, withOccurrences, withoutOccurrencesMethods inherited from interface OrderedIterable
getFirst, getFirstOptional, getLast, getLastOptional, rejectWithIndex, selectWithIndex, zip, zipWithIndexMethods inherited from interface ReversibleIterable
asReversed, reverseForEach, reverseForEachWithIndexMethods inherited from interface RichIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, makeString, makeString, makeString, makeString, max, maxBy, maxByOptional, maxOptional, maxOptional, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reduceBy, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
items
-
size
private int size
-
-
Constructor Details
-
TreeBag
public TreeBag() -
TreeBag
-
TreeBag
-
TreeBag
-
TreeBag
-
-
Method Details
-
newBag
-
newBag
-
newBag
-
newBag
public static <E> TreeBag<E> newBag(Comparator<? super E> comparator, Iterable<? extends E> iterable) -
newBagWith
-
newBagWith
-
clone
- Specified by:
clonein interfaceMutableSortedBag<T>- Specified by:
clonein classAbstractMutableSortedBag<T>
-
equals
-
hashCode
public int hashCode()Description copied from interface:BagReturns the hash code for this Bag, defined as this.Bag.toMapOfItemToCount().hashCode(). -
getKeysView
- Specified by:
getKeysViewin classAbstractMutableBagIterable<T>
-
sizeDistinct
public int sizeDistinct()Description copied from interface:BagThe size of the Bag when counting only distinct elements.- Specified by:
sizeDistinctin interfaceBag<T>
-
forEachWithOccurrences
Description copied from interface:BagFor each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrencesin interfaceBag<T>
-
selectByOccurrences
Description copied from interface:BagReturns all elements of the bag that have a number of occurrences that satisfy the predicate.- Specified by:
selectByOccurrencesin interfaceBag<T>- Specified by:
selectByOccurrencesin interfaceMutableBagIterable<T>- Specified by:
selectByOccurrencesin interfaceMutableSortedBag<T>- Specified by:
selectByOccurrencesin interfaceSortedBag<T>
-
occurrencesOf
Description copied from interface:BagThe occurrences of a distinct item in the bag.- Specified by:
occurrencesOfin interfaceBag<T>
-
anySatisfyWithOccurrences
Description copied from interface:BagReturns true if the predicate evaluates to true for any element of the Bag. Returns false if the Bag is empty or if no element returns true for the predicate.- Specified by:
anySatisfyWithOccurrencesin interfaceBag<T>
-
allSatisfyWithOccurrences
Description copied from interface:BagReturns true if the predicate evaluates to true for all elements of the Bag. Returns false if the Bag is empty or if not all elements return true for the predicate.- Specified by:
allSatisfyWithOccurrencesin interfaceBag<T>
-
noneSatisfyWithOccurrences
Description copied from interface:BagReturns true if the Bag is empty or if the predicate evaluates to false for all elements of the Bag. Returns false if the predicate evaluates to true for at least one element of the Bag.- Specified by:
noneSatisfyWithOccurrencesin interfaceBag<T>
-
detectWithOccurrences
Description copied from interface:BagReturns an element of the Bag that satisfies the predicate or null if such an element does not exist- Specified by:
detectWithOccurrencesin interfaceBag<T>
-
isEmpty
public boolean isEmpty()Description copied from interface:RichIterableReturns true if this iterable has zero items.- Specified by:
isEmptyin interfaceCollection<T>- Specified by:
isEmptyin interfaceRichIterable<T>- Overrides:
isEmptyin classAbstractRichIterable<T>
-
remove
- Specified by:
removein interfaceCollection<T>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<T>
-
contains
Description copied from interface:RichIterableReturns true if the iterable has an element which responds true to element.equals(object).- Specified by:
containsin interfaceCollection<T>- Specified by:
containsin interfaceRichIterable<T>- Overrides:
containsin classAbstractRichIterable<T>
-
compareTo
- Specified by:
compareToin interfaceComparable<T>
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
each
Description copied from interface:RichIterableThe procedure is executed for each element in the iterable.Example using a Java 8 lambda expression:
people.each(person -> LOGGER.info(person.getName()));
This method is a variant ofInternalIterable.forEach(Procedure)that has a signature conflict withIterable.forEach(java.util.function.Consumer).- Specified by:
eachin interfaceRichIterable<T>- See Also:
-
forEachWithIndex
Description copied from interface:InternalIterableIterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.Example using a Java 8 lambda:
people.forEachWithIndex((Person person, int index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));Example using an anonymous inner class:
people.forEachWithIndex(new ObjectIntProcedure<Person>() { public void value(Person person, int index) { LOGGER.info("Index: " + index + " person: " + person.getName()); } });- Specified by:
forEachWithIndexin interfaceInternalIterable<T>- Specified by:
forEachWithIndexin interfaceOrderedIterable<T>- Overrides:
forEachWithIndexin classAbstractRichIterable<T>
-
forEach
Description copied from interface:OrderedIterableIterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive.e.g. OrderedIterable<Person> people = FastList.newListWith(ted, mary, bob, sally) people.forEach(0, 1, person -> LOGGER.info(person.getName()));
This code would output ted and mary's names.
- Specified by:
forEachin interfaceOrderedIterable<T>
-
forEachWithIndex
public void forEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure) Description copied from interface:OrderedIterableIterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive.e.g. OrderedIterable<People> people = FastList.newListWith(ted, mary, bob, sally) people.forEachWithIndex(0, 1, (person, index) -> LOGGER.info(person.getName()));
This code would output ted and mary's names.
- Specified by:
forEachWithIndexin interfaceOrderedIterable<T>
-
forEachWith
Description copied from interface:InternalIterableThe procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.Example using a Java 8 lambda:
people.forEachWith((Person person, Person other) -> { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } }, fred);Example using an anonymous inner class:
people.forEachWith(new Procedure2<Person, Person>() { public void value(Person person, Person other) { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } } }, fred);- Specified by:
forEachWithin interfaceInternalIterable<T>- Overrides:
forEachWithin classAbstractRichIterable<T>
-
iterator
-
addOccurrences
Description copied from interface:MutableBagIterableAdd number ofoccurrencesfor anitem. If theitemdoes not exist, then theitemis added to the bag.For Example:
MutableBagIterable<String> names = Bags.mutable.of("A", "B", "B"); Assert.assertEquals(4, names.addOccurrences("A", 3));- Specified by:
addOccurrencesin interfaceMutableBagIterable<T>- Returns:
- updated number of occurrences.
-
removeOccurrences
- Specified by:
removeOccurrencesin interfaceMutableBagIterable<T>
-
setOccurrences
- Specified by:
setOccurrencesin interfaceMutableBagIterable<T>
-
without
Description copied from interface:MutableCollectionThis 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 ofFixedSizeCollectiona 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.- Specified by:
withoutin interfaceMutableBagIterable<T>- Specified by:
withoutin interfaceMutableCollection<T>- Specified by:
withoutin interfaceMutableSortedBag<T>- See Also:
-
withAll
Description copied from interface:MutableCollectionThis 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 ofFixedSizeCollectiona 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.- Specified by:
withAllin interfaceMutableBagIterable<T>- Specified by:
withAllin interfaceMutableCollection<T>- Specified by:
withAllin interfaceMutableSortedBag<T>- See Also:
-
withoutAll
Description copied from interface:MutableCollectionThis 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 ofFixedSizeCollectiona 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.- Specified by:
withoutAllin interfaceMutableBagIterable<T>- Specified by:
withoutAllin interfaceMutableCollection<T>- Specified by:
withoutAllin interfaceMutableSortedBag<T>- See Also:
-
with
Description copied from interface:MutableCollectionThis 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 ofFixedSizeCollectiona 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.- Specified by:
within interfaceMutableBagIterable<T>- Specified by:
within interfaceMutableCollection<T>- Specified by:
within interfaceMutableSortedBag<T>- See Also:
-
newEmpty
Description copied from interface:MutableCollectionCreates a new empty mutable version of the same collection type. For example, if this instance is a FastList, this method will return a new empty FastList. If the class of this instance is immutable or fixed size (i.e. SingletonList) then a mutable alternative to the class will be provided.- Specified by:
newEmptyin interfaceMutableCollection<T>- Specified by:
newEmptyin interfaceMutableSortedBag<T>
-
removeIf
Description copied from interface:MutableCollectionRemoves all elements in the collection that evaluate to true for the specified predicate.e.g. return lastNames.removeIf(Predicates.isNull());
- Specified by:
removeIfin interfaceMutableCollection<T>
-
removeIfWith
Description copied from interface:MutableCollectionRemoves all elements in the collection that evaluate to true for the specified predicate2 and parameter.return lastNames.removeIfWith(Predicates2.isNull(), null);
- Specified by:
removeIfWithin interfaceMutableCollection<T>
-
removeAllIterable
- Specified by:
removeAllIterablein interfaceMutableCollection<T>- See Also:
-
size
public int size()Description copied from interface:RichIterableReturns the number of items in this iterable.- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfaceRichIterable<T>
-
indexOf
Description copied from interface:OrderedIterableReturns the index of the first occurrence of the specified item in this iterable, or -1 if this iterable does not contain the item.- Specified by:
indexOfin interfaceOrderedIterable<T>- See Also:
-
zipWithIndex
Description copied from interface:RichIterableZips thisRichIterablewith its indices.- Specified by:
zipWithIndexin interfaceBag<T>- Specified by:
zipWithIndexin interfaceMutableBagIterable<T>- Specified by:
zipWithIndexin interfaceMutableCollection<T>- Specified by:
zipWithIndexin interfaceMutableSortedBag<T>- Specified by:
zipWithIndexin interfaceOrderedIterable<T>- Specified by:
zipWithIndexin interfaceReversibleIterable<T>- Specified by:
zipWithIndexin interfaceRichIterable<T>- Specified by:
zipWithIndexin interfaceSortedBag<T>- Specified by:
zipWithIndexin interfaceSortedIterable<T>- Returns:
- A new
RichIterablecontaining pairs consisting of all elements of thisRichIterablepaired with their index. Indices start at 0. - See Also:
-
distinct
Description copied from interface:SortedIterableReturns a newSortedIterablecontaining the distinct elements in this iterable.Conceptually similar to
RichIterable.toSet().RichIterable.toList()but retains the original order. If an element appears multiple times in this iterable, the first one will be copied into the result.- Specified by:
distinctin interfaceMutableSortedBag<T>- Specified by:
distinctin interfaceOrderedIterable<T>- Specified by:
distinctin interfaceReversibleIterable<T>- Specified by:
distinctin interfaceSortedBag<T>- Specified by:
distinctin interfaceSortedIterable<T>- Returns:
SortedIterableof distinct elements
-
groupBy
Description copied from interface:RichIterableFor 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);- Specified by:
groupByin interfaceBag<T>- Specified by:
groupByin interfaceMutableBagIterable<T>- Specified by:
groupByin interfaceMutableCollection<T>- Specified by:
groupByin interfaceMutableSortedBag<T>- Specified by:
groupByin interfaceOrderedIterable<T>- Specified by:
groupByin interfaceReversibleIterable<T>- Specified by:
groupByin interfaceRichIterable<T>- Specified by:
groupByin interfaceSortedBag<T>- Specified by:
groupByin interfaceSortedIterable<T>
-
groupByEach
Description copied from interface:RichIterableSimilar toRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys for each value.- Specified by:
groupByEachin interfaceBag<T>- Specified by:
groupByEachin interfaceMutableBagIterable<T>- Specified by:
groupByEachin interfaceMutableCollection<T>- Specified by:
groupByEachin interfaceMutableSortedBag<T>- Specified by:
groupByEachin interfaceOrderedIterable<T>- Specified by:
groupByEachin interfaceReversibleIterable<T>- Specified by:
groupByEachin interfaceRichIterable<T>- Specified by:
groupByEachin interfaceSortedBag<T>- Specified by:
groupByEachin interfaceSortedIterable<T>
-
detectIndex
Description copied from interface:OrderedIterableReturns the index of the first element of theOrderedIterablefor which thepredicateevaluates to true. Returns -1 if no element evaluates true for thepredicate.- Specified by:
detectIndexin interfaceOrderedIterable<T>
-
corresponds
public <S> boolean corresponds(OrderedIterable<S> other, Predicate2<? super T, ? super S> predicate) Description copied from interface:OrderedIterableReturns true if both OrderedIterables have the same length andpredicatereturns true for all corresponding elements e1 of thisOrderedIterableand e2 ofother. Thepredicateis evaluated for each element at the same position of eachOrderedIterablein a forward iteration order. This is a short circuit pattern.- Specified by:
correspondsin interfaceOrderedIterable<T>
-
toStack
Description copied from interface:OrderedIterableConverts the OrderedIterable to a mutable MutableStack implementation.- Specified by:
toStackin interfaceOrderedIterable<T>
-
take
Description copied from interface:ReversibleIterableReturns the firstcountelements of the iterable or all the elements in the iterable ifcountis greater than the length of the iterable.- Specified by:
takein interfaceMutableSortedBag<T>- Specified by:
takein interfaceReversibleIterable<T>- Specified by:
takein interfaceSortedBag<T>- Parameters:
count- the number of items to take.
-
drop
Description copied from interface:ReversibleIterableReturns an iterable after skipping the firstcountelements or an empty iterable if thecountis greater than the length of the iterable.- Specified by:
dropin interfaceMutableSortedBag<T>- Specified by:
dropin interfaceReversibleIterable<T>- Specified by:
dropin interfaceSortedBag<T>- Parameters:
count- the number of items to drop.
-
comparator
Description copied from interface:SortedBagReturns the comparator used to order the elements in this bag, or null if this bag uses the natural ordering of its elements.- Specified by:
comparatorin interfaceSortedBag<T>- Specified by:
comparatorin interfaceSortedIterable<T>
-
with
-
with
-
add
- Specified by:
addin interfaceCollection<T>
-
with
-
distinctView
Description copied from interface:BagReturns an unmodifiable view on the distinct elements with the same complexity as the Bag implementation.- Specified by:
distinctViewin interfaceBag<T>- Returns:
- an unmodifiable view on the distinct elements of the Bag.
-