public abstract class AbstractImmutableBag<T> extends AbstractImmutableCollection<T> implements ImmutableBag<T>
Constructor and Description |
---|
AbstractImmutableBag() |
Modifier and Type | Method and Description |
---|---|
ImmutableBooleanBag |
collectBoolean(BooleanFunction<? super T> booleanFunction)
Returns a new primitive
boolean iterable with the results of applying the specified function on each element
of the source collection. |
ImmutableByteBag |
collectByte(ByteFunction<? super T> byteFunction)
Returns a new primitive
byte iterable with the results of applying the specified function on each element
of the source collection. |
ImmutableCharBag |
collectChar(CharFunction<? super T> charFunction)
Returns a new primitive
char iterable with the results of applying the specified function on each element
of the source collection. |
ImmutableDoubleBag |
collectDouble(DoubleFunction<? super T> doubleFunction)
Returns a new primitive
double iterable with the results of applying the specified function on each element
of the source collection. |
ImmutableFloatBag |
collectFloat(FloatFunction<? super T> floatFunction)
Returns a new primitive
float iterable with the results of applying the specified function on each element
of the source collection. |
ImmutableIntBag |
collectInt(IntFunction<? super T> intFunction)
Returns a new primitive
int iterable with the results of applying the specified function on each element
of the source collection. |
ImmutableLongBag |
collectLong(LongFunction<? super T> longFunction)
Returns a new primitive
long iterable with the results of applying the specified function on each element
of the source collection. |
ImmutableShortBag |
collectShort(ShortFunction<? super T> shortFunction)
Returns a new primitive
short iterable with the results of applying the specified function on each element
of the source collection. |
<P,V> ImmutableBag<V> |
collectWith(Function2<? super T,? super P,? extends V> function,
P parameter)
Same as collect with a
Function2 and specified parameter which is passed to the block
|
PartitionImmutableBag<T> |
partition(Predicate<? super T> predicate)
Filters a collection into a PartitionedIterable based on the evaluation of the predicate.
|
<P> PartitionImmutableBag<T> |
partitionWith(Predicate2<? super T,? super P> predicate,
P parameter)
Filters a collection into a PartitionIterable based on the evaluation of the predicate.
|
<P> ImmutableBag<T> |
rejectWith(Predicate2<? super T,? super P> predicate,
P parameter)
Similar to
RichIterable.reject(Predicate) , except with an evaluation parameter for the second generic argument in Predicate2 . |
<P> ImmutableBag<T> |
selectWith(Predicate2<? super T,? super P> predicate,
P parameter)
Similar to
RichIterable.select(Predicate) , except with an evaluation parameter for the second generic argument in Predicate2 . |
String |
toStringOfItemToCount()
Returns a string representation of this bag.
|
add, addAll, aggregateBy, aggregateInPlaceBy, chunk, clear, remove, removeAll, retainAll
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectIfNone, detectWith, detectWithIfNone, flatCollect, forEachWith, forEachWithIndex, groupBy, groupByEach, injectInto, injectInto, injectInto, injectInto, injectInto, isEmpty, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toList, toMap, toSet, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
collect, collectIf, flatCollect, groupBy, groupByEach, newWith, newWithAll, newWithout, newWithoutAll, reject, select, selectByOccurrences, selectInstancesOf, zip, zipWithIndex
toImmutable
equals, forEachWithOccurrences, hashCode, occurrencesOf, sizeDistinct, toMapOfItemToCount
aggregateBy, aggregateInPlaceBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectIfNone, detectWith, detectWithIfNone, flatCollect, getFirst, getLast, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, isEmpty, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, reject, rejectWith, select, selectWith, size, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toList, toMap, toSet, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
forEach, forEachWith, forEachWithIndex
forEach, iterator, spliterator
aggregateBy, aggregateInPlaceBy, groupByUniqueKey
contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeIf, size, spliterator, stream, toArray, toArray
public <P> ImmutableBag<T> selectWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
RichIterable.select(Predicate)
, except with an evaluation parameter for the second generic argument in Predicate2
.selectWith
in interface Bag<T>
selectWith
in interface ImmutableBag<T>
selectWith
in interface UnsortedBag<T>
selectWith
in interface ImmutableCollection<T>
selectWith
in interface RichIterable<T>
predicate
- a Predicate2
to use as the select criteriaparameter
- a parameter to pass in for evaluation of the second argument P
in predicate
RichIterable.select(Predicate)
public <P> ImmutableBag<T> rejectWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
RichIterable.reject(Predicate)
, except with an evaluation parameter for the second generic argument in Predicate2
.rejectWith
in interface Bag<T>
rejectWith
in interface ImmutableBag<T>
rejectWith
in interface UnsortedBag<T>
rejectWith
in interface ImmutableCollection<T>
rejectWith
in interface RichIterable<T>
predicate
- a Predicate2
to use as the select criteriaparameter
- a parameter to pass in for evaluation of the second argument P
in predicate
RichIterable.select(Predicate)
public PartitionImmutableBag<T> partition(Predicate<? super T> predicate)
RichIterable
e.g. return people.partition(new Predicate<Person>() { public boolean accept(Person person) { return person.getAddress().getState().getName().equals("New York"); } });
partition
in interface Bag<T>
partition
in interface ImmutableBag<T>
partition
in interface UnsortedBag<T>
partition
in interface ImmutableCollection<T>
partition
in interface RichIterable<T>
public <P> PartitionImmutableBag<T> partitionWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
e.g. return people.partitionWith(new Predicate2<Person, String>() { public boolean accept(Person person, String state) { return person.getAddress().getState().getName().equals(state); } }, "New York");
partitionWith
in interface Bag<T>
partitionWith
in interface ImmutableBag<T>
partitionWith
in interface ImmutableCollection<T>
partitionWith
in interface RichIterable<T>
public ImmutableBooleanBag collectBoolean(BooleanFunction<? super T> booleanFunction)
RichIterable
boolean
iterable with the results of applying the specified function on each element
of the source collection. This method is also commonly called transform or map.
e.g. return people.collectBoolean(new BooleanFunction<Person>() { public boolean booleanValueOf(Person person) { return person.hasDrivingLicense(); } });
collectBoolean
in interface ImmutableBag<T>
collectBoolean
in interface UnsortedBag<T>
collectBoolean
in interface ImmutableCollection<T>
collectBoolean
in interface RichIterable<T>
public ImmutableByteBag collectByte(ByteFunction<? super T> byteFunction)
RichIterable
byte
iterable with the results of applying the specified function on each element
of the source collection. This method is also commonly called transform or map.
e.g. return people.collectByte(new ByteFunction<Person>() { public byte byteValueOf(Person person) { return person.getCode(); } });
collectByte
in interface ImmutableBag<T>
collectByte
in interface UnsortedBag<T>
collectByte
in interface ImmutableCollection<T>
collectByte
in interface RichIterable<T>
public ImmutableCharBag collectChar(CharFunction<? super T> charFunction)
RichIterable
char
iterable with the results of applying the specified function on each element
of the source collection. This method is also commonly called transform or map.
e.g. return people.collectChar(new CharFunction<Person>() { public char charValueOf(Person person) { return person.getMiddleInitial(); } });
collectChar
in interface ImmutableBag<T>
collectChar
in interface UnsortedBag<T>
collectChar
in interface ImmutableCollection<T>
collectChar
in interface RichIterable<T>
public ImmutableDoubleBag collectDouble(DoubleFunction<? super T> doubleFunction)
RichIterable
double
iterable with the results of applying the specified function on each element
of the source collection. This method is also commonly called transform or map.
e.g. return people.collectDouble(new DoubleFunction<Person>() { public double doubleValueOf(Person person) { return person.getMilesFromNorthPole(); } });
collectDouble
in interface ImmutableBag<T>
collectDouble
in interface UnsortedBag<T>
collectDouble
in interface ImmutableCollection<T>
collectDouble
in interface RichIterable<T>
public ImmutableFloatBag collectFloat(FloatFunction<? super T> floatFunction)
RichIterable
float
iterable with the results of applying the specified function on each element
of the source collection. This method is also commonly called transform or map.
e.g. return people.collectFloat(new FloatFunction<Person>() { public float floatValueOf(Person person) { return person.getHeightInInches(); } });
collectFloat
in interface ImmutableBag<T>
collectFloat
in interface UnsortedBag<T>
collectFloat
in interface ImmutableCollection<T>
collectFloat
in interface RichIterable<T>
public ImmutableIntBag collectInt(IntFunction<? super T> intFunction)
RichIterable
int
iterable with the results of applying the specified function on each element
of the source collection. This method is also commonly called transform or map.
e.g. return people.collectInt(new IntFunction<Person>() { public int intValueOf(Person person) { return person.getAge(); } });
collectInt
in interface ImmutableBag<T>
collectInt
in interface UnsortedBag<T>
collectInt
in interface ImmutableCollection<T>
collectInt
in interface RichIterable<T>
public ImmutableLongBag collectLong(LongFunction<? super T> longFunction)
RichIterable
long
iterable with the results of applying the specified function on each element
of the source collection. This method is also commonly called transform or map.
e.g. return people.collectLong(new LongFunction<Person>() { public long longValueOf(Person person) { return person.getGuid(); } });
collectLong
in interface ImmutableBag<T>
collectLong
in interface UnsortedBag<T>
collectLong
in interface ImmutableCollection<T>
collectLong
in interface RichIterable<T>
public ImmutableShortBag collectShort(ShortFunction<? super T> shortFunction)
RichIterable
short
iterable with the results of applying the specified function on each element
of the source collection. This method is also commonly called transform or map.
e.g. return people.collectShort(new ShortFunction<Person>() { public short shortValueOf(Person person) { return person.getNumberOfJunkMailItemsReceivedPerMonth(); } });
collectShort
in interface ImmutableBag<T>
collectShort
in interface UnsortedBag<T>
collectShort
in interface ImmutableCollection<T>
collectShort
in interface RichIterable<T>
public <P,V> ImmutableBag<V> collectWith(Function2<? super T,? super P,? extends V> function, P parameter)
RichIterable
Function2
and specified parameter which is passed to the block
e.g. Function2addParameterFunction = new Function2 () { public Integer value(final Integer each, final Integer parameter) { return each + parameter; } }; FastList.newListWith(1, 2, 3).collectWith(addParameterFunction, Integer.valueOf(1));
collectWith
in interface ImmutableBag<T>
collectWith
in interface UnsortedBag<T>
collectWith
in interface ImmutableCollection<T>
collectWith
in interface RichIterable<T>
function
- A Function2
to use as the collect transformation functionparameter
- A parameter to pass in for evaluation of the second argument P
in function
RichIterable
that contains the transformed elements returned by Function2.value(Object, Object)
RichIterable.collect(Function)
public String toStringOfItemToCount()
Bag
Bag.forEachWithOccurrences(ObjectIntProcedure)
and Iterable.iterator()
. The element-count mappings are enclosed in braces ("{}"). Adjacent mappings are
separated by the characters ", " (comma and space). Each element-count mapping is rendered as the element
followed by an equals sign ("=") followed by the number of ooccurrences. Elements and are converted to
strings as by String.valueOf(Object)
.
The string representation is similar to AbstractMap.toString()
, not RichIterable.toString()
.toStringOfItemToCount
in interface Bag<T>
Copyright © 2004–2019. All rights reserved.