Class ImmutableEmptySortedBag<T>
- java.lang.Object
-
- org.eclipse.collections.impl.AbstractRichIterable<T>
-
- org.eclipse.collections.impl.bag.AbstractBag<T>
-
- org.eclipse.collections.impl.bag.immutable.AbstractImmutableBagIterable<T>
-
- org.eclipse.collections.impl.bag.sorted.immutable.AbstractImmutableSortedBag<T>
-
- org.eclipse.collections.impl.bag.sorted.immutable.ImmutableEmptySortedBag<T>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<SortedBag<T>>,java.lang.Iterable<T>,java.util.Collection<T>,Bag<T>,ImmutableBagIterable<T>,ImmutableSortedBag<T>,SortedBag<T>,ImmutableCollection<T>,InternalIterable<T>,OrderedIterable<T>,ReversibleIterable<T>,SortedIterable<T>,RichIterable<T>
class ImmutableEmptySortedBag<T> extends AbstractImmutableSortedBag<T> implements java.io.Serializable
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Comparator<? super T>comparator(package private) static ImmutableSortedBag<?>INSTANCEprivate static longserialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description privateImmutableEmptySortedBag()(package private)ImmutableEmptySortedBag(java.util.Comparator<? super T> comparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.RichIterable<RichIterable<T>>chunk(int size)Partitions elements in fixed size chunks.<V> ImmutableList<V>collect(Function<? super T,? extends V> function)Returns a new collection with the results of applying the specified function on each element of the source collection.<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 java.util.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.<V> ImmutableList<V>collectWithOccurrences(ObjectIntToObjectFunction<? super T,? extends V> function)Iterates over the unique elements and their occurrences and collects the results of applying the specified function.java.util.Comparator<? super T>comparator()Returns the comparator used to order the elements in this bag, or null if this bag uses the natural ordering of its elements.intcompareTo(SortedBag<T> o)booleancontains(java.lang.Object object)Returns 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.intcount(Predicate<? super T> predicate)Return the total number of elements that answer true to the specified predicate.<V> ImmutableBag<V>countBy(Function<? super T,? extends V> function)This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.<V,R extends MutableBagIterable<V>>
RcountBy(Function<? super T,? extends V> function, R target)This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.<V> ImmutableBag<V>countByEach(Function<? super T,? extends java.lang.Iterable<V>> function)This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.<V,R extends MutableBagIterable<V>>
RcountByEach(Function<? super T,? extends java.lang.Iterable<V>> function, R target)This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.<V,P>
ImmutableBag<V>countByWith(Function2<? super T,? super P,? extends V> function, P parameter)This method will count the number of occurrences of each value calculated by applying the function to each element of the collection with the specified parameter as the second argument.<V,P,R extends MutableBagIterable<V>>
RcountByWith(Function2<? super T,? super P,? extends V> function, P parameter, R target)This method will count the number of occurrences of each value calculated by applying the function to each element of the collection with the specified parameter as the second argument.intdetectIndex(Predicate<? super T> predicate)Returns the index of the first element of theOrderedIterablefor which thepredicateevaluates to true.TdetectWithOccurrences(ObjectIntPredicate<? super T> predicate)Returns an element of the Bag that satisfies the predicate or null if such an element does not existImmutableSortedSet<T>distinct()Returns a newSortedIterablecontaining the distinct elements in this iterable.RichIterable<T>distinctView()Returns an unmodifiable view on the distinct elements with the same complexity as the Bag implementation.ImmutableSortedBag<T>drop(int count)Returns an iterable after skipping the firstcountelements or an empty iterable if thecountis greater than the length of the iterable.ImmutableSortedBag<T>dropWhile(Predicate<? super T> predicate)Returns the final elements that do not satisfy the Predicate.voideach(Procedure<? super T> procedure)The procedure is executed for each element in the iterable.booleanequals(java.lang.Object other)Two bagsb1andb2are equal ifm1.toMapOfItemToCount().equals(m2.toMapOfItemToCount()).voidforEach(int startIndex, int endIndex, Procedure<? super T> procedure)Iterates 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.voidforEachWithOccurrences(ObjectIntProcedure<? super T> procedure)For each distinct item, with the number of occurrences, execute the specified procedure.TgetFirst()Returns the first element of an iterable.TgetLast()Returns the last element of an iterable.TgetOnly()Returns the element if the iterable has exactly one element.<V> ImmutableSortedBagMultimap<V,T>groupBy(Function<? super T,? extends V> function)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> ImmutableSortedBagMultimap<V,T>groupByEach(Function<? super T,? extends java.lang.Iterable<V>> function)Similar toRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys for each value.<V> ImmutableMap<V,T>groupByUniqueKey(Function<? super T,? extends V> function)For each element of the iterable, the function is evaluated, and the results of these evaluations are collected into a new map, where the transformed value is the key.inthashCode()Returns the hash code for this Bag, defined as this.Bag.toMapOfItemToCount().hashCode().java.util.Iterator<T>iterator()Tmax()Returns the maximum element out of this container based on the natural order.Tmax(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>>
TmaxBy(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.Tmin()Returns the minimum element out of this container based on the natural order.Tmin(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>>
TminBy(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.ImmutableSortedBag<T>newWith(T element)This method is similar to thewithmethod inMutableCollectionwith the difference that a new copy of this collection with the element appended will be returned.ImmutableSortedBag<T>newWithAll(java.lang.Iterable<? extends T> elements)This method is similar to thewithAllmethod inMutableCollectionwith the difference that a new copy of this collection with the elements appended will be returned.ImmutableSortedBag<T>newWithout(T element)This method is similar to thewithoutmethod inMutableCollectionwith the difference that a new copy of this collection with the element removed will be returned.ImmutableSortedBag<T>newWithoutAll(java.lang.Iterable<? extends T> elements)This method is similar to thewithoutAllmethod inMutableCollectionwith the difference that a new copy of this collection with the elements removed will be returned.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(java.lang.Object item)The occurrences of a distinct item in the bag.PartitionImmutableSortedBag<T>partitionWhile(Predicate<? super T> predicate)Returns a Partition of the initial elements that satisfy the Predicate and the remaining elements.ImmutableSortedBag<T>reject(Predicate<? super T> predicate)Returns all elements of the source collection that return false when evaluating of the predicate.<P> ImmutableSortedBag<T>rejectWith(Predicate2<? super T,? super P> predicate, P parameter)Similar toRichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.ImmutableSortedBag<T>select(Predicate<? super T> predicate)Returns all elements of the source collection that return true when evaluating the predicate.ImmutableSortedBag<T>selectByOccurrences(IntPredicate predicate)Returns all elements of the bag that have a number of occurrences that satisfy the predicate.<S> ImmutableSortedBag<S>selectInstancesOf(java.lang.Class<S> clazz)Returns all elements of the source collection that are instances of the Classclazz.ImmutableSortedSet<T>selectUnique()Returns a set containing all elements of the bag that have exactly one occurrence.<P> ImmutableSortedBag<T>selectWith(Predicate2<? super T,? super P> predicate, P parameter)Similar toRichIterable.select(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.intsize()Returns the number of items in this iterable.intsizeDistinct()The size of the Bag when counting only distinct elements.ImmutableSortedBag<T>take(int count)Returns the firstcountelements of the iterable or all the elements in the iterable ifcountis greater than the length of the iterable.ImmutableSortedBag<T>takeWhile(Predicate<? super T> predicate)Returns the initial elements that satisfy the Predicate.ImmutableSortedBag<T>tap(Procedure<? super T> procedure)Executes the Procedure for each element in the iterable and returnsthis.MutableSortedMap<T,java.lang.Integer>toMapOfItemToCount()Converts the Bag to a Map of the Item type to its count as an Integer.MutableStack<T>toStack()Converts the OrderedIterable to a mutable MutableStack implementation.ImmutableSortedSet<Pair<T,java.lang.Integer>>zipWithIndex()Zips thisRichIterablewith its indices.-
Methods inherited from class org.eclipse.collections.impl.bag.sorted.immutable.AbstractImmutableSortedBag
bottomOccurrences, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, detectLastIndex, flatCollect, partition, partitionWith, toImmutable, topOccurrences, toReversed, writeReplace, zip, zip
-
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, 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, toStringOfItemToCount
-
Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, asLazy, containsAll, containsAllArguments, containsAllIterable, countWith, detect, detectOptional, detectWith, detectWithIfNone, detectWithOptional, forEach, forEachWithIndex, groupByUniqueKey, into, isEmpty, noneSatisfy, noneSatisfyWith, 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, reduceBy, reduceInPlace, reduceInPlace, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toStringOfItemToCount
-
Methods inherited from interface org.eclipse.collections.api.collection.ImmutableCollection
aggregateBy, aggregateInPlaceBy, castToCollection, parallelStream, reduceBy, spliterator, stream, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from interface org.eclipse.collections.api.bag.sorted.ImmutableSortedBag
flatCollectWith, selectDuplicates, toImmutableSortedBag
-
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach
-
Methods inherited from interface org.eclipse.collections.api.ordered.OrderedIterable
forEachWithIndex, getFirstOptional, getLastOptional, indexOf, rejectWithIndex, selectWithIndex, zipWithIndex
-
Methods inherited from interface org.eclipse.collections.api.ordered.ReversibleIterable
asReversed, reverseForEach, reverseForEachWithIndex
-
Methods inherited from interface org.eclipse.collections.api.RichIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, 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, noneSatisfy, noneSatisfyWith, notEmpty, reduce, 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 Detail
-
INSTANCE
static final ImmutableSortedBag<?> INSTANCE
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
comparator
private final java.util.Comparator<? super T> comparator
-
-
Constructor Detail
-
ImmutableEmptySortedBag
private ImmutableEmptySortedBag()
-
ImmutableEmptySortedBag
ImmutableEmptySortedBag(java.util.Comparator<? super T> comparator)
-
-
Method Detail
-
newWith
public ImmutableSortedBag<T> newWith(T element)
Description copied from interface:ImmutableCollectionThis method is similar to thewithmethod inMutableCollectionwith the difference that a new copy of this collection with the element appended will be returned.- Specified by:
newWithin interfaceImmutableCollection<T>- Specified by:
newWithin interfaceImmutableSortedBag<T>
-
newWithAll
public ImmutableSortedBag<T> newWithAll(java.lang.Iterable<? extends T> elements)
Description copied from interface:ImmutableCollectionThis method is similar to thewithAllmethod inMutableCollectionwith the difference that a new copy of this collection with the elements appended will be returned.- Specified by:
newWithAllin interfaceImmutableCollection<T>- Specified by:
newWithAllin interfaceImmutableSortedBag<T>
-
newWithout
public ImmutableSortedBag<T> newWithout(T element)
Description copied from interface:ImmutableCollectionThis method is similar to thewithoutmethod inMutableCollectionwith the difference that a new copy of this collection with the element removed will be returned.- Specified by:
newWithoutin interfaceImmutableCollection<T>- Specified by:
newWithoutin interfaceImmutableSortedBag<T>
-
newWithoutAll
public ImmutableSortedBag<T> newWithoutAll(java.lang.Iterable<? extends T> elements)
Description copied from interface:ImmutableCollectionThis method is similar to thewithoutAllmethod inMutableCollectionwith the difference that a new copy of this collection with the elements removed will be returned.- Specified by:
newWithoutAllin interfaceImmutableCollection<T>- Specified by:
newWithoutAllin interfaceImmutableSortedBag<T>- Overrides:
newWithoutAllin classAbstractImmutableSortedBag<T>
-
equals
public boolean equals(java.lang.Object other)
Description copied from interface:BagTwo bagsb1andb2are equal ifm1.toMapOfItemToCount().equals(m2.toMapOfItemToCount()).
-
hashCode
public int hashCode()
Description copied from interface:BagReturns the hash code for this Bag, defined as this.Bag.toMapOfItemToCount().hashCode().
-
forEachWithOccurrences
public void forEachWithOccurrences(ObjectIntProcedure<? super T> procedure)
Description copied from interface:BagFor each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrencesin interfaceBag<T>
-
anySatisfyWithOccurrences
public boolean anySatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
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
public boolean allSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
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
public boolean noneSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
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
public T detectWithOccurrences(ObjectIntPredicate<? super T> predicate)
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>
-
sizeDistinct
public int sizeDistinct()
Description copied from interface:BagThe size of the Bag when counting only distinct elements.- Specified by:
sizeDistinctin interfaceBag<T>
-
size
public int size()
Description copied from interface:RichIterableReturns the number of items in this iterable.- Specified by:
sizein interfacejava.util.Collection<T>- Specified by:
sizein interfaceRichIterable<T>
-
collect
public <V> ImmutableList<V> collect(Function<? super T,? extends V> function)
Description copied from interface:RichIterableReturns a new collection with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
RichIterable<String> names = people.collect(person -> person.getFirstName() + " " + person.getLastName());- Specified by:
collectin interfaceImmutableCollection<T>- Specified by:
collectin interfaceImmutableSortedBag<T>- Specified by:
collectin interfaceOrderedIterable<T>- Specified by:
collectin interfaceReversibleIterable<T>- Specified by:
collectin interfaceRichIterable<T>- Specified by:
collectin interfaceSortedBag<T>- Overrides:
collectin classAbstractImmutableSortedBag<T>
-
select
public ImmutableSortedBag<T> select(Predicate<? super T> predicate)
Description copied from interface:RichIterableReturns all elements of the source collection that return true when evaluating the predicate. This method is also commonly called filter.Example using a Java 8 lambda expression:
RichIterable<Person> selected = people.select(person -> person.getAddress().getCity().equals("London"));- Specified by:
selectin interfaceBag<T>- Specified by:
selectin interfaceImmutableBagIterable<T>- Specified by:
selectin interfaceImmutableCollection<T>- Specified by:
selectin interfaceImmutableSortedBag<T>- Specified by:
selectin interfaceOrderedIterable<T>- Specified by:
selectin interfaceReversibleIterable<T>- Specified by:
selectin interfaceRichIterable<T>- Specified by:
selectin interfaceSortedBag<T>- Specified by:
selectin interfaceSortedIterable<T>- Overrides:
selectin classAbstractImmutableSortedBag<T>
-
reject
public ImmutableSortedBag<T> reject(Predicate<? super T> predicate)
Description copied from interface:RichIterableReturns all elements of the source collection that return false when evaluating of the predicate. This method is also sometimes called filterNot and is the equivalent of calling iterable.select(Predicates.not(predicate)).Example using a Java 8 lambda expression:
RichIterable<Person> rejected = people.reject(person -> person.person.getLastName().equals("Smith"));- Specified by:
rejectin interfaceBag<T>- Specified by:
rejectin interfaceImmutableBagIterable<T>- Specified by:
rejectin interfaceImmutableCollection<T>- Specified by:
rejectin interfaceImmutableSortedBag<T>- Specified by:
rejectin interfaceOrderedIterable<T>- Specified by:
rejectin interfaceReversibleIterable<T>- Specified by:
rejectin interfaceRichIterable<T>- Specified by:
rejectin interfaceSortedBag<T>- Specified by:
rejectin interfaceSortedIterable<T>- Overrides:
rejectin classAbstractImmutableSortedBag<T>- Parameters:
predicate- aPredicateto use as the reject criteria- Returns:
- a RichIterable that contains elements that cause
Predicate.accept(Object)method to evaluate to false
-
selectWith
public <P> ImmutableSortedBag<T> selectWith(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:RichIterableSimilar toRichIterable.select(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
RichIterable<Person> selected = people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18));- Specified by:
selectWithin interfaceBag<T>- Specified by:
selectWithin interfaceImmutableBagIterable<T>- Specified by:
selectWithin interfaceImmutableCollection<T>- Specified by:
selectWithin interfaceImmutableSortedBag<T>- Specified by:
selectWithin interfaceOrderedIterable<T>- Specified by:
selectWithin interfaceReversibleIterable<T>- Specified by:
selectWithin interfaceRichIterable<T>- Specified by:
selectWithin interfaceSortedBag<T>- Specified by:
selectWithin interfaceSortedIterable<T>- Overrides:
selectWithin classAbstractImmutableSortedBag<T>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicate- See Also:
RichIterable.select(Predicate)
-
rejectWith
public <P> ImmutableSortedBag<T> rejectWith(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:RichIterableSimilar toRichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
RichIterable<Person> rejected = people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18));- Specified by:
rejectWithin interfaceBag<T>- Specified by:
rejectWithin interfaceImmutableBagIterable<T>- Specified by:
rejectWithin interfaceImmutableCollection<T>- Specified by:
rejectWithin interfaceImmutableSortedBag<T>- Specified by:
rejectWithin interfaceOrderedIterable<T>- Specified by:
rejectWithin interfaceReversibleIterable<T>- Specified by:
rejectWithin interfaceRichIterable<T>- Specified by:
rejectWithin interfaceSortedBag<T>- Specified by:
rejectWithin interfaceSortedIterable<T>- Overrides:
rejectWithin classAbstractImmutableSortedBag<T>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicate- See Also:
RichIterable.select(Predicate)
-
selectInstancesOf
public <S> ImmutableSortedBag<S> selectInstancesOf(java.lang.Class<S> clazz)
Description copied from interface:RichIterableReturns all elements of the source collection that are instances of the Classclazz.RichIterable<Integer> integers = List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);- Specified by:
selectInstancesOfin interfaceBag<T>- Specified by:
selectInstancesOfin interfaceImmutableBagIterable<T>- Specified by:
selectInstancesOfin interfaceImmutableCollection<T>- Specified by:
selectInstancesOfin interfaceImmutableSortedBag<T>- Specified by:
selectInstancesOfin interfaceOrderedIterable<T>- Specified by:
selectInstancesOfin interfaceReversibleIterable<T>- Specified by:
selectInstancesOfin interfaceRichIterable<T>- Specified by:
selectInstancesOfin interfaceSortedBag<T>- Specified by:
selectInstancesOfin interfaceSortedIterable<T>- Overrides:
selectInstancesOfin classAbstractImmutableSortedBag<T>
-
groupBy
public <V> ImmutableSortedBagMultimap<V,T> groupBy(Function<? super T,? extends V> function)
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 interfaceImmutableBagIterable<T>- Specified by:
groupByin interfaceImmutableCollection<T>- Specified by:
groupByin interfaceImmutableSortedBag<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>- Overrides:
groupByin classAbstractImmutableSortedBag<T>
-
groupByEach
public <V> ImmutableSortedBagMultimap<V,T> groupByEach(Function<? super T,? extends java.lang.Iterable<V>> function)
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 interfaceImmutableBagIterable<T>- Specified by:
groupByEachin interfaceImmutableCollection<T>- Specified by:
groupByEachin interfaceImmutableSortedBag<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>- Overrides:
groupByEachin classAbstractImmutableSortedBag<T>
-
groupByUniqueKey
public <V> ImmutableMap<V,T> groupByUniqueKey(Function<? super T,? extends V> function)
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 map, where the transformed value is the key. The generated keys must each be unique, or else an exception is thrown.- Specified by:
groupByUniqueKeyin interfaceImmutableCollection<T>- Specified by:
groupByUniqueKeyin interfaceRichIterable<T>- Overrides:
groupByUniqueKeyin classAbstractImmutableSortedBag<T>- See Also:
RichIterable.groupBy(Function)
-
contains
public boolean contains(java.lang.Object object)
Description copied from interface:RichIterableReturns true if the iterable has an element which responds true to element.equals(object).- Specified by:
containsin interfacejava.util.Collection<T>- Specified by:
containsin interfaceRichIterable<T>- Overrides:
containsin classAbstractRichIterable<T>
-
tap
public ImmutableSortedBag<T> tap(Procedure<? super T> procedure)
Description copied from interface:RichIterableExecutes the Procedure for each element in the iterable and returnsthis.Example using a Java 8 lambda expression:
RichIterable<Person> tapped = people.tap(person -> LOGGER.info(person.getName()));- Specified by:
tapin interfaceBag<T>- Specified by:
tapin interfaceImmutableBagIterable<T>- Specified by:
tapin interfaceImmutableCollection<T>- Specified by:
tapin interfaceImmutableSortedBag<T>- Specified by:
tapin interfaceOrderedIterable<T>- Specified by:
tapin interfaceReversibleIterable<T>- Specified by:
tapin interfaceRichIterable<T>- Specified by:
tapin interfaceSortedBag<T>- Specified by:
tapin interfaceSortedIterable<T>- Overrides:
tapin classAbstractImmutableSortedBag<T>- See Also:
RichIterable.each(Procedure),RichIterable.forEach(Procedure)
-
countBy
public <V> ImmutableBag<V> countBy(Function<? super T,? extends V> function)
Description copied from interface:RichIterableThis method will count the number of occurrences of each value calculated by applying the function to each element of the collection.- Specified by:
countByin interfaceImmutableCollection<T>- Specified by:
countByin interfaceImmutableSortedBag<T>- Specified by:
countByin interfaceRichIterable<T>- Overrides:
countByin classAbstractImmutableSortedBag<T>- Since:
- 9.0
-
countBy
public <V,R extends MutableBagIterable<V>> R countBy(Function<? super T,? extends V> function, R target)
Description copied from interface:RichIterableThis method will count the number of occurrences of each value calculated by applying the function to each element of the collection.- Specified by:
countByin interfaceRichIterable<T>- Since:
- 9.0
-
countByWith
public <V,P> ImmutableBag<V> countByWith(Function2<? super T,? super P,? extends V> function, P parameter)
Description copied from interface:RichIterableThis method will count the number of occurrences of each value calculated by applying the function to each element of the collection with the specified parameter as the second argument.- Specified by:
countByWithin interfaceImmutableCollection<T>- Specified by:
countByWithin interfaceImmutableSortedBag<T>- Specified by:
countByWithin interfaceRichIterable<T>- Overrides:
countByWithin classAbstractImmutableSortedBag<T>- Since:
- 9.0
-
countByWith
public <V,P,R extends MutableBagIterable<V>> R countByWith(Function2<? super T,? super P,? extends V> function, P parameter, R target)
Description copied from interface:RichIterableThis method will count the number of occurrences of each value calculated by applying the function to each element of the collection with the specified parameter as the second argument.- Specified by:
countByWithin interfaceRichIterable<T>- Since:
- 9.0
-
countByEach
public <V> ImmutableBag<V> countByEach(Function<? super T,? extends java.lang.Iterable<V>> function)
Description copied from interface:RichIterableThis method will count the number of occurrences of each value calculated by applying the function to each element of the collection.- Specified by:
countByEachin interfaceImmutableCollection<T>- Specified by:
countByEachin interfaceImmutableSortedBag<T>- Specified by:
countByEachin interfaceRichIterable<T>- Overrides:
countByEachin classAbstractImmutableSortedBag<T>- Since:
- 10.0.0
-
countByEach
public <V,R extends MutableBagIterable<V>> R countByEach(Function<? super T,? extends java.lang.Iterable<V>> function, R target)
Description copied from interface:RichIterableThis method will count the number of occurrences of each value calculated by applying the function to each element of the collection.- Specified by:
countByEachin interfaceRichIterable<T>- Since:
- 10.0.0
-
selectByOccurrences
public ImmutableSortedBag<T> selectByOccurrences(IntPredicate predicate)
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 interfaceImmutableBagIterable<T>- Specified by:
selectByOccurrencesin interfaceImmutableSortedBag<T>- Specified by:
selectByOccurrencesin interfaceSortedBag<T>- Overrides:
selectByOccurrencesin classAbstractImmutableSortedBag<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>
-
forEach
public void forEach(int startIndex, int endIndex, Procedure<? super T> procedure)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>
-
each
public void each(Procedure<? super T> procedure)
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:
InternalIterable.forEach(Procedure),Iterable.forEach(java.util.function.Consumer)
-
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
public <P> void forEachWith(Procedure2<? super T,? super P> procedure, P parameter)
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>
-
occurrencesOf
public int occurrencesOf(java.lang.Object item)
Description copied from interface:BagThe occurrences of a distinct item in the bag.- Specified by:
occurrencesOfin interfaceBag<T>
-
iterator
public java.util.Iterator<T> iterator()
-
min
public T min(java.util.Comparator<? super T> comparator)
Description copied from interface:RichIterableReturns the minimum element out of this container based on the comparator.- Specified by:
minin interfaceRichIterable<T>- Overrides:
minin classAbstractRichIterable<T>
-
max
public T max(java.util.Comparator<? super T> comparator)
Description copied from interface:RichIterableReturns the maximum element out of this container based on the comparator.- Specified by:
maxin interfaceRichIterable<T>- Overrides:
maxin classAbstractRichIterable<T>
-
min
public T min()
Description copied from interface:RichIterableReturns the minimum element out of this container based on the natural order.- Specified by:
minin interfaceOrderedIterable<T>- Specified by:
minin interfaceRichIterable<T>- Specified by:
minin interfaceSortedBag<T>- Specified by:
minin interfaceSortedIterable<T>- Overrides:
minin classAbstractRichIterable<T>
-
max
public T max()
Description copied from interface:RichIterableReturns the maximum element out of this container based on the natural order.- Specified by:
maxin interfaceOrderedIterable<T>- Specified by:
maxin interfaceRichIterable<T>- Specified by:
maxin interfaceSortedBag<T>- Specified by:
maxin interfaceSortedIterable<T>- Overrides:
maxin classAbstractRichIterable<T>
-
minBy
public <V extends java.lang.Comparable<? super V>> T minBy(Function<? super T,? extends V> function)
Description copied from interface:RichIterableReturns the minimum elements out of this container based on the natural order of the attribute returned by Function.- Specified by:
minByin interfaceRichIterable<T>- Overrides:
minByin classAbstractRichIterable<T>
-
maxBy
public <V extends java.lang.Comparable<? super V>> T maxBy(Function<? super T,? extends V> function)
Description copied from interface:RichIterableReturns the maximum elements out of this container based on the natural order of the attribute returned by Function.- Specified by:
maxByin interfaceRichIterable<T>- Overrides:
maxByin classAbstractRichIterable<T>
-
comparator
public java.util.Comparator<? super T> 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>
-
zipWithIndex
public ImmutableSortedSet<Pair<T,java.lang.Integer>> zipWithIndex()
Description copied from interface:RichIterableZips thisRichIterablewith its indices.- Specified by:
zipWithIndexin interfaceBag<T>- Specified by:
zipWithIndexin interfaceImmutableBagIterable<T>- Specified by:
zipWithIndexin interfaceImmutableCollection<T>- Specified by:
zipWithIndexin interfaceImmutableSortedBag<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>- Overrides:
zipWithIndexin classAbstractImmutableSortedBag<T>- Returns:
- A new
RichIterablecontaining pairs consisting of all elements of thisRichIterablepaired with their index. Indices start at 0. - See Also:
RichIterable.zip(Iterable)
-
collectWithIndex
public <V> ImmutableList<V> collectWithIndex(ObjectIntToObjectFunction<? super T,? extends V> function)
Description copied from interface:OrderedIterableReturns a new OrderedIterable using results obtained by applying the specified function to each element and its corresponding index.- Specified by:
collectWithIndexin interfaceImmutableSortedBag<T>- Specified by:
collectWithIndexin interfaceOrderedIterable<T>- Specified by:
collectWithIndexin interfaceReversibleIterable<T>- Specified by:
collectWithIndexin interfaceSortedBag<T>- Since:
- 9.1.
-
collectWithIndex
public <V,R extends java.util.Collection<V>> R collectWithIndex(ObjectIntToObjectFunction<? super T,? extends V> function, R target)
Description copied from interface:OrderedIterableAdds elements to the target Collection using results obtained by applying the specified function to each element and its corresponding index.- Specified by:
collectWithIndexin interfaceOrderedIterable<T>- Since:
- 9.1.
-
collectWithOccurrences
public <V> ImmutableList<V> collectWithOccurrences(ObjectIntToObjectFunction<? super T,? extends V> function)
Description copied from interface:BagIterates over the unique elements and their occurrences and collects the results of applying the specified function.- Specified by:
collectWithOccurrencesin interfaceBag<T>- Specified by:
collectWithOccurrencesin interfaceImmutableBagIterable<T>- Specified by:
collectWithOccurrencesin interfaceImmutableSortedBag<T>- Specified by:
collectWithOccurrencesin interfaceSortedBag<T>- Overrides:
collectWithOccurrencesin classAbstractImmutableSortedBag<T>
-
partitionWhile
public PartitionImmutableSortedBag<T> partitionWhile(Predicate<? super T> predicate)
Description copied from interface:SortedIterableReturns 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:
partitionWhilein interfaceOrderedIterable<T>- Specified by:
partitionWhilein interfaceReversibleIterable<T>- Specified by:
partitionWhilein interfaceSortedBag<T>- Specified by:
partitionWhilein interfaceSortedIterable<T>
-
distinct
public ImmutableSortedSet<T> 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 interfaceImmutableSortedBag<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
-
getFirst
public T getFirst()
Description copied from interface:RichIterableReturns 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:
getFirstin interfaceOrderedIterable<T>- Specified by:
getFirstin interfaceRichIterable<T>
-
getLast
public T getLast()
Description copied from interface:RichIterableReturns 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:
getLastin interfaceOrderedIterable<T>- Specified by:
getLastin interfaceRichIterable<T>
-
getOnly
public T getOnly()
Description copied from interface:RichIterableReturns the element if the iterable has exactly one element. Otherwise, throwIllegalStateException.- Specified by:
getOnlyin interfaceRichIterable<T>- Returns:
- an element of an iterable.
-
takeWhile
public ImmutableSortedBag<T> takeWhile(Predicate<? super T> predicate)
Description copied from interface:SortedIterableReturns the initial elements that satisfy the Predicate. Short circuits at the first element which does not satisfy the Predicate.- Specified by:
takeWhilein interfaceImmutableSortedBag<T>- Specified by:
takeWhilein interfaceOrderedIterable<T>- Specified by:
takeWhilein interfaceReversibleIterable<T>- Specified by:
takeWhilein interfaceSortedBag<T>- Specified by:
takeWhilein interfaceSortedIterable<T>
-
dropWhile
public ImmutableSortedBag<T> dropWhile(Predicate<? super T> predicate)
Description copied from interface:SortedIterableReturns the final elements that do not satisfy the Predicate. Short circuits at the first element which does satisfy the Predicate.- Specified by:
dropWhilein interfaceImmutableSortedBag<T>- Specified by:
dropWhilein interfaceOrderedIterable<T>- Specified by:
dropWhilein interfaceReversibleIterable<T>- Specified by:
dropWhilein interfaceSortedBag<T>- Specified by:
dropWhilein interfaceSortedIterable<T>
-
detectIndex
public int detectIndex(Predicate<? super T> predicate)
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>
-
count
public int count(Predicate<? super T> predicate)
Description copied from interface:RichIterableReturn the total number of elements that answer true to the specified predicate.Example using a Java 8 lambda expression:
int count = people.count(person -> person.getAddress().getState().getName().equals("New York"));- Specified by:
countin interfaceRichIterable<T>- Overrides:
countin classAbstractBag<T>
-
toStack
public MutableStack<T> toStack()
Description copied from interface:OrderedIterableConverts the OrderedIterable to a mutable MutableStack implementation.- Specified by:
toStackin interfaceOrderedIterable<T>
-
compareTo
public int compareTo(SortedBag<T> o)
- Specified by:
compareToin interfacejava.lang.Comparable<T>
-
chunk
public RichIterable<RichIterable<T>> chunk(int size)
Description copied from interface:RichIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceRichIterable<T>- Overrides:
chunkin classAbstractImmutableSortedBag<T>- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingRichIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-
toMapOfItemToCount
public MutableSortedMap<T,java.lang.Integer> toMapOfItemToCount()
Description copied from interface:BagConverts the Bag to a Map of the Item type to its count as an Integer.- Specified by:
toMapOfItemToCountin interfaceBag<T>- Specified by:
toMapOfItemToCountin interfaceImmutableBagIterable<T>- Specified by:
toMapOfItemToCountin interfaceImmutableSortedBag<T>- Specified by:
toMapOfItemToCountin interfaceSortedBag<T>
-
take
public ImmutableSortedBag<T> take(int count)
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 interfaceImmutableSortedBag<T>- Specified by:
takein interfaceReversibleIterable<T>- Specified by:
takein interfaceSortedBag<T>- Parameters:
count- the number of items to take.
-
drop
public ImmutableSortedBag<T> drop(int count)
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 interfaceImmutableSortedBag<T>- Specified by:
dropin interfaceReversibleIterable<T>- Specified by:
dropin interfaceSortedBag<T>- Parameters:
count- the number of items to drop.
-
selectUnique
public ImmutableSortedSet<T> selectUnique()
Description copied from interface:BagReturns a set containing all elements of the bag that have exactly one occurrence.- Specified by:
selectUniquein interfaceBag<T>- Specified by:
selectUniquein interfaceImmutableBagIterable<T>- Specified by:
selectUniquein interfaceImmutableSortedBag<T>- Specified by:
selectUniquein interfaceSortedBag<T>
-
distinctView
public RichIterable<T> 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.
-
-