Class ImmutableSortedBagImpl<T>
- All Implemented Interfaces:
Serializable
,Comparable<SortedBag<T>>
,Iterable<T>
,Collection<T>
,Bag<T>
,ImmutableBagIterable<T>
,ImmutableSortedBag<T>
,SortedBag<T>
,ImmutableCollection<T>
,InternalIterable<T>
,OrderedIterable<T>
,ReversibleIterable<T>
,SortedIterable<T>
,RichIterable<T>
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Comparator
<? super T> private final T[]
private final int[]
private static final long
private final int
-
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
ImmutableSortedBagImpl
(SortedBag<T> sortedBag) private
ImmutableSortedBagImpl
(T[] elements, int[] occurrences, Comparator<? super T> comparator) -
Method Summary
Modifier and TypeMethodDescriptionboolean
allSatisfy
(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
(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
allSatisfyWithOccurrences
(ObjectIntPredicate<? super T> predicate) Returns true if the predicate evaluates to true for all elements of the Bag.boolean
anySatisfy
(Predicate<? super T> predicate) Returns true if the predicate evaluates to true for any element of the iterable.<P> boolean
anySatisfyWith
(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.boolean
anySatisfyWithOccurrences
(ObjectIntPredicate<? super T> predicate) Returns true if the predicate evaluates to true for any element of the Bag.<V> ImmutableList
<V> collectWithIndex
(ObjectIntToObjectFunction<? super T, ? extends V> function) Returns a new OrderedIterable using results obtained by applying the specified function to each element and its corresponding index.<V,
R extends Collection<V>>
RcollectWithIndex
(ObjectIntToObjectFunction<? super T, ? extends V> function, R target) Adds elements to the target Collection using results obtained by applying the specified function to each element and its corresponding index.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.int
boolean
Returns true if the iterable has an element which responds true to element.equals(object).<S> boolean
corresponds
(OrderedIterable<S> other, Predicate2<? super T, ? super S> predicate) Returns true if both OrderedIterables have the same length andpredicate
returns true for all corresponding elements e1 of thisOrderedIterable
and e2 ofother
.Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true.int
detectIndex
(Predicate<? super T> predicate) Returns the index of the first element of theOrderedIterable
for which thepredicate
evaluates to true.private int
detectNotIndex
(Predicate<? super T> predicate) detectOptional
(Predicate<? super T> predicate) Returns the first element of the iterable for which the predicate evaluates to true as an Optional.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 newSortedIterable
containing 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 firstcount
elements or an empty iterable if thecount
is greater than the length of the iterable.Returns the final elements that do not satisfy the Predicate.void
The procedure is executed for each element in the iterable.boolean
Two bagsb1
andb2
are equal ifm1.toMapOfItemToCount().equals(m2.toMapOfItemToCount())
.void
Iterates over the section of the iterable covered by the specified inclusive indexes.void
forEachWithIndex
(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure) Iterates over the section of the iterable covered by the specified inclusive indexes.void
forEachWithIndex
(ObjectIntProcedure<? super T> objectIntProcedure) Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.void
forEachWithOccurrences
(ObjectIntProcedure<? super T> procedure) For each distinct item, with the number of occurrences, execute the specified procedure.getFirst()
Returns the first element of an iterable.getLast()
Returns the last element of an iterable.int
hashCode()
Returns the hash code for this Bag, defined as this.Bag.toMapOfItemToCount()
.hashCode().int
Returns the index of the first occurrence of the specified item in this iterable, or -1 if this iterable does not contain the item.iterator()
max()
Returns the maximum element out of this container based on the natural order.max
(Comparator<? super T> comparator) Returns the maximum element out of this container based on the comparator.<V extends Comparable<? super V>>
TReturns the maximum elements out of this container based on the natural order of the attribute returned by Function.min()
Returns the minimum element out of this container based on the natural order.min
(Comparator<? super T> comparator) Returns the minimum element out of this container based on the comparator.<V extends Comparable<? super V>>
TReturns the minimum elements out of this container based on the natural order of the attribute returned by Function.This method is similar to thewith
method inMutableCollection
with the difference that a new copy of this collection with the element appended will be returned.newWithAll
(Iterable<? extends T> elements) This method is similar to thewithAll
method inMutableCollection
with the difference that a new copy of this collection with the elements appended will be returned.newWithout
(T element) This method is similar to thewithout
method inMutableCollection
with the difference that a new copy of this collection with the element removed will be returned.boolean
noneSatisfy
(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
(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
noneSatisfyWithOccurrences
(ObjectIntPredicate<? super T> predicate) Returns true if the Bag is empty or if the predicate evaluates to false for all elements of the Bag.int
occurrencesOf
(Object item) The occurrences of a distinct item in the bag.partitionWhile
(Predicate<? super T> predicate) Returns a Partition of the initial elements that satisfy the Predicate and the remaining elements.int
size()
Returns the number of items in this iterable.int
The size of the Bag when counting only distinct elements.take
(int count) Returns the firstcount
elements of the iterable or all the elements in the iterable ifcount
is greater than the length of the iterable.Returns the initial elements that satisfy the Predicate.Object[]
toArray()
Converts this iterable to an array.<E> E[]
toArray
(E[] array) Converts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.Converts the Bag to a Map of the Item type to its count as an Integer.Converts the collection to a MutableList implementation and sorts it using the natural order of the elements.Converts the collection to a MutableSortedSet implementation and sorts it using the natural order of the elements.toSortedSet
(Comparator<? super T> comparator) Converts the collection to a MutableSortedSet implementation and sorts it using the specified comparator.Methods inherited from class org.eclipse.collections.impl.bag.sorted.immutable.AbstractImmutableSortedBag
asReversed, bottomOccurrences, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, collectWithOccurrences, countBy, countByEach, countByWith, detectLastIndex, flatCollect, groupBy, groupByEach, groupByUniqueKey, newWithoutAll, partition, partitionWith, reject, rejectWith, select, selectByOccurrences, selectInstancesOf, selectWith, tap, toImmutable, topOccurrences, toReversed, toStack, writeReplace, zip, zip, zipWithIndex
Methods inherited from class org.eclipse.collections.impl.bag.immutable.AbstractImmutableBagIterable
add, addAll, castToCollection, clear, parallelStream, remove, removeAll, removeAllFrom, retainAll, shortCircuit, spliterator, stream, sumByDouble, sumByFloat, sumByInt, sumByLong
Methods inherited from class org.eclipse.collections.impl.bag.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, toBag, toList, toListWithOccurrences, toSet, toSortedBag, toSortedBag, toSortedList, toStringOfItemToCount
Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
appendString, appendString, asLazy, containsAll, containsAllArguments, containsAllIterable, countWith, detectWith, detectWithIfNone, detectWithOptional, forEach, forEachWith, groupByUniqueKey, into, isEmpty, toBiMap, toMap, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSetBy, toString, zipWithIndex
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.collections.api.bag.Bag
aggregateBy, collectWithOccurrences, reduceInPlace, reduceInPlace, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toStringOfItemToCount
Methods inherited from interface java.util.Collection
containsAll, isEmpty, removeIf, toArray
Methods inherited from interface org.eclipse.collections.api.collection.ImmutableCollection
aggregateBy, aggregateInPlaceBy, castToCollection, parallelStream, spliterator, stream, sumByDouble, sumByFloat, sumByInt, sumByLong
Methods inherited from interface org.eclipse.collections.api.bag.sorted.ImmutableSortedBag
flatCollectWith, selectDuplicates, selectUnique, toImmutableSortedBag
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach, forEachWith
Methods inherited from interface org.eclipse.collections.api.ordered.OrderedIterable
getFirstOptional, getLastOptional, rejectWithIndex, selectWithIndex, zipWithIndex
Methods inherited from interface org.eclipse.collections.api.ordered.ReversibleIterable
reverseForEach, reverseForEachWithIndex
Methods inherited from interface org.eclipse.collections.api.RichIterable
appendString, appendString, appendString, asLazy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detectIfNone, 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, isEmpty, makeString, makeString, makeString, makeString, maxByOptional, maxOptional, maxOptional, minByOptional, minOptional, minOptional, notEmpty, reduce, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSetBy, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
elements
-
occurrences
private final int[] occurrences -
comparator
-
size
private final int size
-
-
Constructor Details
-
ImmutableSortedBagImpl
-
ImmutableSortedBagImpl
-
-
Method Details
-
newWith
Description copied from interface:ImmutableCollection
This method is similar to thewith
method inMutableCollection
with the difference that a new copy of this collection with the element appended will be returned.- Specified by:
newWith
in interfaceImmutableCollection<T>
- Specified by:
newWith
in interfaceImmutableSortedBag<T>
-
newWithout
Description copied from interface:ImmutableCollection
This method is similar to thewithout
method inMutableCollection
with the difference that a new copy of this collection with the element removed will be returned.- Specified by:
newWithout
in interfaceImmutableCollection<T>
- Specified by:
newWithout
in interfaceImmutableSortedBag<T>
-
newWithAll
Description copied from interface:ImmutableCollection
This method is similar to thewithAll
method inMutableCollection
with the difference that a new copy of this collection with the elements appended will be returned.- Specified by:
newWithAll
in interfaceImmutableCollection<T>
- Specified by:
newWithAll
in interfaceImmutableSortedBag<T>
-
comparator
Description copied from interface:SortedBag
Returns the comparator used to order the elements in this bag, or null if this bag uses the natural ordering of its elements.- Specified by:
comparator
in interfaceSortedBag<T>
- Specified by:
comparator
in interfaceSortedIterable<T>
-
min
Description copied from interface:RichIterable
Returns the minimum element out of this container based on the natural order.- Specified by:
min
in interfaceOrderedIterable<T>
- Specified by:
min
in interfaceRichIterable<T>
- Specified by:
min
in interfaceSortedBag<T>
- Specified by:
min
in interfaceSortedIterable<T>
- Overrides:
min
in classAbstractRichIterable<T>
-
min
Description copied from interface:RichIterable
Returns the minimum element out of this container based on the comparator.- Specified by:
min
in interfaceRichIterable<T>
- Overrides:
min
in classAbstractRichIterable<T>
-
minBy
Description copied from interface:RichIterable
Returns the minimum elements out of this container based on the natural order of the attribute returned by Function.- Specified by:
minBy
in interfaceRichIterable<T>
- Overrides:
minBy
in classAbstractRichIterable<T>
-
max
Description copied from interface:RichIterable
Returns the maximum element out of this container based on the natural order.- Specified by:
max
in interfaceOrderedIterable<T>
- Specified by:
max
in interfaceRichIterable<T>
- Specified by:
max
in interfaceSortedBag<T>
- Specified by:
max
in interfaceSortedIterable<T>
- Overrides:
max
in classAbstractRichIterable<T>
-
max
Description copied from interface:RichIterable
Returns the maximum element out of this container based on the comparator.- Specified by:
max
in interfaceRichIterable<T>
- Overrides:
max
in classAbstractRichIterable<T>
-
maxBy
Description copied from interface:RichIterable
Returns the maximum elements out of this container based on the natural order of the attribute returned by Function.- Specified by:
maxBy
in interfaceRichIterable<T>
- Overrides:
maxBy
in classAbstractRichIterable<T>
-
takeWhile
Description copied from interface:SortedIterable
Returns the initial elements that satisfy the Predicate. Short circuits at the first element which does not satisfy the Predicate.- Specified by:
takeWhile
in interfaceImmutableSortedBag<T>
- Specified by:
takeWhile
in interfaceOrderedIterable<T>
- Specified by:
takeWhile
in interfaceReversibleIterable<T>
- Specified by:
takeWhile
in interfaceSortedBag<T>
- Specified by:
takeWhile
in interfaceSortedIterable<T>
-
dropWhile
Description copied from interface:SortedIterable
Returns the final elements that do not satisfy the Predicate. Short circuits at the first element which does satisfy the Predicate.- Specified by:
dropWhile
in interfaceImmutableSortedBag<T>
- Specified by:
dropWhile
in interfaceOrderedIterable<T>
- Specified by:
dropWhile
in interfaceReversibleIterable<T>
- Specified by:
dropWhile
in interfaceSortedBag<T>
- Specified by:
dropWhile
in interfaceSortedIterable<T>
-
detectIndex
Description copied from interface:OrderedIterable
Returns the index of the first element of theOrderedIterable
for which thepredicate
evaluates to true. Returns -1 if no element evaluates true for thepredicate
.- Specified by:
detectIndex
in interfaceOrderedIterable<T>
-
detectNotIndex
-
partitionWhile
Description copied from interface:SortedIterable
Returns a Partition of the initial elements that satisfy the Predicate and the remaining elements. Short circuits at the first element which does satisfy the Predicate.- Specified by:
partitionWhile
in interfaceOrderedIterable<T>
- Specified by:
partitionWhile
in interfaceReversibleIterable<T>
- Specified by:
partitionWhile
in interfaceSortedBag<T>
- Specified by:
partitionWhile
in interfaceSortedIterable<T>
-
forEachWithOccurrences
Description copied from interface:Bag
For each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrences
in interfaceBag<T>
-
anySatisfyWithOccurrences
Description copied from interface:Bag
Returns 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:
anySatisfyWithOccurrences
in interfaceBag<T>
-
allSatisfyWithOccurrences
Description copied from interface:Bag
Returns 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:
allSatisfyWithOccurrences
in interfaceBag<T>
-
noneSatisfyWithOccurrences
Description copied from interface:Bag
Returns 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:
noneSatisfyWithOccurrences
in interfaceBag<T>
-
detectWithOccurrences
Description copied from interface:Bag
Returns an element of the Bag that satisfies the predicate or null if such an element does not exist- Specified by:
detectWithOccurrences
in interfaceBag<T>
-
sizeDistinct
public int sizeDistinct()Description copied from interface:Bag
The size of the Bag when counting only distinct elements.- Specified by:
sizeDistinct
in interfaceBag<T>
-
size
public int size()Description copied from interface:RichIterable
Returns the number of items in this iterable.- Specified by:
size
in interfaceCollection<T>
- Specified by:
size
in interfaceRichIterable<T>
-
indexOf
Description copied from interface:OrderedIterable
Returns 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:
indexOf
in interfaceOrderedIterable<T>
- See Also:
-
getFirst
Description copied from interface:RichIterable
Returns the first element of an iterable. In the case of a List it is the element at the first index. In the case of any other Collection, it is the first element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.The 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.
- Specified by:
getFirst
in interfaceOrderedIterable<T>
- Specified by:
getFirst
in interfaceRichIterable<T>
-
getLast
Description copied from interface:RichIterable
Returns the last element of an iterable. In the case of a List it is the element at the last index. In the case of any other Collection, it is the last element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.The 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.
- Specified by:
getLast
in interfaceOrderedIterable<T>
- Specified by:
getLast
in interfaceRichIterable<T>
-
forEach
Description copied from interface:OrderedIterable
Iterates 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.forEach(0, 1, new Procedure<Person>() { public void value(Person person) { LOGGER.info(person.getName()); } });
This code would output ted and mary's names.
- Specified by:
forEach
in interfaceOrderedIterable<T>
-
each
Description copied from interface:RichIterable
The procedure is executed for each element in the iterable.Example using a Java 8 lambda expression:
people.each(person -> LOGGER.info(person.getName()));
Example using an anonymous inner class:
people.each(new Procedure<Person>() { public void value(Person 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:
each
in interfaceRichIterable<T>
- See Also:
-
forEachWithIndex
Description copied from interface:InternalIterable
Iterates 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:
forEachWithIndex
in interfaceInternalIterable<T>
- Specified by:
forEachWithIndex
in interfaceOrderedIterable<T>
- Overrides:
forEachWithIndex
in classAbstractRichIterable<T>
-
collectWithIndex
public <V> ImmutableList<V> collectWithIndex(ObjectIntToObjectFunction<? super T, ? extends V> function) Description copied from interface:OrderedIterable
Returns a new OrderedIterable using results obtained by applying the specified function to each element and its corresponding index.- Specified by:
collectWithIndex
in interfaceImmutableSortedBag<T>
- Specified by:
collectWithIndex
in interfaceOrderedIterable<T>
- Specified by:
collectWithIndex
in interfaceReversibleIterable<T>
- Specified by:
collectWithIndex
in interfaceSortedBag<T>
- Since:
- 9.1.
-
collectWithIndex
public <V,R extends Collection<V>> R collectWithIndex(ObjectIntToObjectFunction<? super T, ? extends V> function, R target) Description copied from interface:OrderedIterable
Adds elements to the target Collection using results obtained by applying the specified function to each element and its corresponding index.- Specified by:
collectWithIndex
in interfaceOrderedIterable<T>
- Since:
- 9.1.
-
forEachWithIndex
public void forEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure) Description copied from interface:OrderedIterable
Iterates 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, new ObjectIntProcedure<Person>() { public void value(Person person, int index) { LOGGER.info(person.getName()); } });
This code would output ted and mary's names.
- Specified by:
forEachWithIndex
in interfaceOrderedIterable<T>
-
occurrencesOf
Description copied from interface:Bag
The occurrences of a distinct item in the bag.- Specified by:
occurrencesOf
in interfaceBag<T>
-
distinct
Description copied from interface:SortedIterable
Returns a newSortedIterable
containing 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:
distinct
in interfaceImmutableSortedBag<T>
- Specified by:
distinct
in interfaceOrderedIterable<T>
- Specified by:
distinct
in interfaceReversibleIterable<T>
- Specified by:
distinct
in interfaceSortedBag<T>
- Specified by:
distinct
in interfaceSortedIterable<T>
- Returns:
SortedIterable
of distinct elements
-
corresponds
Description copied from interface:OrderedIterable
Returns true if both OrderedIterables have the same length andpredicate
returns true for all corresponding elements e1 of thisOrderedIterable
and e2 ofother
. Thepredicate
is evaluated for each element at the same position of eachOrderedIterable
in a forward iteration order. This is a short circuit pattern.- Specified by:
corresponds
in interfaceOrderedIterable<T>
-
toSortedList
Description copied from interface:RichIterable
Converts the collection to a MutableList implementation and sorts it using the natural order of the elements.- Specified by:
toSortedList
in interfaceRichIterable<T>
-
toSortedSet
Description copied from interface:RichIterable
Converts the collection to a MutableSortedSet implementation and sorts it using the natural order of the elements.- Specified by:
toSortedSet
in interfaceRichIterable<T>
- Overrides:
toSortedSet
in classAbstractBag<T>
-
toSortedSet
Description copied from interface:RichIterable
Converts the collection to a MutableSortedSet implementation and sorts it using the specified comparator.- Specified by:
toSortedSet
in interfaceRichIterable<T>
- Overrides:
toSortedSet
in classAbstractBag<T>
-
toArray
Description copied from interface:RichIterable
Converts this iterable to an array.- Specified by:
toArray
in interfaceCollection<T>
- Specified by:
toArray
in interfaceRichIterable<T>
- Overrides:
toArray
in classAbstractRichIterable<T>
- See Also:
-
toArray
public <E> E[] toArray(E[] array) Description copied from interface:RichIterable
Converts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.- Specified by:
toArray
in interfaceCollection<T>
- Specified by:
toArray
in interfaceRichIterable<T>
- Overrides:
toArray
in classAbstractRichIterable<T>
- See Also:
-
toMapOfItemToCount
Description copied from interface:Bag
Converts the Bag to a Map of the Item type to its count as an Integer.- Specified by:
toMapOfItemToCount
in interfaceBag<T>
- Specified by:
toMapOfItemToCount
in interfaceImmutableBagIterable<T>
- Specified by:
toMapOfItemToCount
in interfaceImmutableSortedBag<T>
- Specified by:
toMapOfItemToCount
in interfaceSortedBag<T>
-
compareTo
- Specified by:
compareTo
in interfaceComparable<T>
-
allSatisfy
Description copied from interface:RichIterable
Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty. Otherwise, returns false.- Specified by:
allSatisfy
in interfaceRichIterable<T>
- Overrides:
allSatisfy
in classAbstractRichIterable<T>
-
allSatisfyWith
Description copied from interface:RichIterable
Returns true if the predicate evaluates to true for every element of the collection, or returns false.- Specified by:
allSatisfyWith
in interfaceRichIterable<T>
- Overrides:
allSatisfyWith
in classAbstractRichIterable<T>
-
anySatisfy
Description copied from interface:RichIterable
Returns true if the predicate evaluates to true for any element of the iterable. Returns false if the iterable is empty, or if no element returned true when evaluating the predicate.- Specified by:
anySatisfy
in interfaceRichIterable<T>
- Overrides:
anySatisfy
in classAbstractRichIterable<T>
-
anySatisfyWith
Description copied from interface:RichIterable
Returns true if the predicate evaluates to true for any element of the collection, or return false. Returns false if the collection is empty.- Specified by:
anySatisfyWith
in interfaceRichIterable<T>
- Overrides:
anySatisfyWith
in classAbstractRichIterable<T>
-
noneSatisfy
Description copied from interface:RichIterable
Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty. Otherwise, returns false.- Specified by:
noneSatisfy
in interfaceRichIterable<T>
- Overrides:
noneSatisfy
in classAbstractRichIterable<T>
-
noneSatisfyWith
Description copied from interface:RichIterable
Returns true if the predicate evaluates to false for every element of the collection, or return false. Returns true if the collection is empty.- Specified by:
noneSatisfyWith
in interfaceRichIterable<T>
- Overrides:
noneSatisfyWith
in classAbstractRichIterable<T>
-
detect
Description copied from interface:RichIterable
Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true. This method is commonly called find.Example 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 accept(Person person) { return person.getFirstName().equals("John") && person.getLastName().equals("Smith"); } });
- Specified by:
detect
in interfaceRichIterable<T>
- Overrides:
detect
in classAbstractRichIterable<T>
-
detectOptional
Description copied from interface:RichIterable
Returns the first element of the iterable for which the predicate evaluates to true as an Optional. This method is commonly called find.Example using a Java 8 lambda expression:
Person person = people.detectOptional(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));
- Specified by:
detectOptional
in interfaceRichIterable<T>
- Overrides:
detectOptional
in classAbstractRichIterable<T>
-
contains
Description copied from interface:RichIterable
Returns true if the iterable has an element which responds true to element.equals(object).- Specified by:
contains
in interfaceCollection<T>
- Specified by:
contains
in interfaceRichIterable<T>
- Overrides:
contains
in classAbstractRichIterable<T>
-
iterator
-
take
Description copied from interface:ReversibleIterable
Returns the firstcount
elements of the iterable or all the elements in the iterable ifcount
is greater than the length of the iterable.- Specified by:
take
in interfaceImmutableSortedBag<T>
- Specified by:
take
in interfaceReversibleIterable<T>
- Specified by:
take
in interfaceSortedBag<T>
- Parameters:
count
- the number of items to take.
-
drop
Description copied from interface:ReversibleIterable
Returns an iterable after skipping the firstcount
elements or an empty iterable if thecount
is greater than the length of the iterable.- Specified by:
drop
in interfaceImmutableSortedBag<T>
- Specified by:
drop
in interfaceReversibleIterable<T>
- Specified by:
drop
in interfaceSortedBag<T>
- Parameters:
count
- the number of items to drop.
-
equals
Description copied from interface:Bag
Two bagsb1
andb2
are equal ifm1.toMapOfItemToCount().equals(m2.toMapOfItemToCount())
. -
hashCode
public int hashCode()Description copied from interface:Bag
Returns the hash code for this Bag, defined as this.Bag.toMapOfItemToCount()
.hashCode(). -
distinctView
Description copied from interface:Bag
Returns an unmodifiable view on the distinct elements with the same complexity as the Bag implementation.- Specified by:
distinctView
in interfaceBag<T>
- Returns:
- an unmodifiable view on the distinct elements of the Bag.
-