Class ImmutableEmptySortedBag<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>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Comparator<? super T> (package private) static final ImmutableSortedBag<?> private static final long -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate(package private)ImmutableEmptySortedBag(Comparator<? super T> comparator) -
Method Summary
Modifier and TypeMethodDescriptionbooleanallSatisfyWithOccurrences(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.chunk(int size) Partitions elements in fixed size chunks.<V> ImmutableList<V> 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 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.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.intReturn the total number of elements that answer true to the specified predicate.<V> ImmutableBag<V> 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>>
RThis 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 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 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.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.Returns the final elements that do not satisfy the Predicate.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.voidforEachWithOccurrences(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.getOnly()Returns the element if the iterable has exactly one element.<V> ImmutableSortedBagMultimap<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> ImmutableSortedBagMultimap<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.<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().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 thewithmethod inMutableCollectionwith 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 thewithAllmethod inMutableCollectionwith the difference that a new copy of this collection with the elements appended will be returned.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.newWithoutAll(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(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.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.Returns all elements of the source collection that return true when evaluating the predicate.selectByOccurrences(IntPredicate predicate) Returns all elements of the bag that have a number of occurrences that satisfy the predicate.<S> ImmutableSortedBag<S> selectInstancesOf(Class<S> clazz) Returns all elements of the source collection that are instances of the Classclazz.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.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.Returns the initial elements that satisfy the Predicate.Executes the Procedure for each element in the iterable and returnsthis.Converts the Bag to a Map of the Item type to its count as an Integer.toStack()Converts the OrderedIterable to a mutable MutableStack implementation.Zips thisRichIterablewith its indices.Methods inherited from class AbstractImmutableSortedBag
bottomOccurrences, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, detectLastIndex, flatCollect, partition, partitionWith, toImmutable, topOccurrences, toReversed, writeReplace, zip, zipMethods inherited from class AbstractImmutableBagIterable
add, addAll, castToCollection, clear, parallelStream, remove, removeAll, removeAllFrom, retainAll, shortCircuit, spliterator, stream, sumByDouble, sumByFloat, sumByInt, sumByLongMethods inherited from class 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, toStringOfItemToCountMethods inherited from class 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, zipWithIndexMethods inherited from interface Bag
aggregateBy, collectWithOccurrences, reduceBy, reduceInPlace, reduceInPlace, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toStringOfItemToCountMethods inherited from interface Collection
containsAll, isEmpty, removeIf, toArrayMethods inherited from interface ImmutableCollection
aggregateBy, aggregateInPlaceBy, castToCollection, parallelStream, reduceBy, spliterator, stream, sumByDouble, sumByFloat, sumByInt, sumByLongMethods inherited from interface ImmutableSortedBag
flatCollectWith, selectDuplicates, toImmutableSortedBagMethods inherited from interface InternalIterable
forEachMethods inherited from interface OrderedIterable
forEachWithIndex, getFirstOptional, getLastOptional, indexOf, rejectWithIndex, selectWithIndex, zipWithIndexMethods inherited from interface ReversibleIterable
asReversed, reverseForEach, reverseForEachWithIndexMethods inherited from interface 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 Details
-
INSTANCE
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
comparator
-
-
Constructor Details
-
ImmutableEmptySortedBag
private ImmutableEmptySortedBag() -
ImmutableEmptySortedBag
ImmutableEmptySortedBag(Comparator<? super T> comparator)
-
-
Method Details
-
newWith
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
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
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
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
-
hashCode
public int hashCode()Description copied from interface:BagReturns the hash code for this Bag, defined as this.Bag.toMapOfItemToCount().hashCode(). -
forEachWithOccurrences
Description copied from interface:BagFor each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrencesin 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>
-
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 interfaceCollection<T>- Specified by:
sizein interfaceRichIterable<T>
-
collect
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
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
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:
-
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:
-
selectInstancesOf
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
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 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
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:
-
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>
-
tap
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:
-
countBy
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
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 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
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
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
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
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>
-
occurrencesOf
Description copied from interface:BagThe occurrences of a distinct item in the bag.- Specified by:
occurrencesOfin interfaceBag<T>
-
iterator
-
min
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
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
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
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
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
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
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
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:
-
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 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
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
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
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
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
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
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
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
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
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
Description copied from interface:OrderedIterableConverts the OrderedIterable to a mutable MutableStack implementation.- Specified by:
toStackin interfaceOrderedIterable<T>
-
compareTo
- Specified by:
compareToin interfaceComparable<T>
-
chunk
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
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
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
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
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
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.
-