Class ImmutableEmptySortedSet<T>
- java.lang.Object
-
- org.eclipse.collections.impl.AbstractRichIterable<T>
-
- org.eclipse.collections.impl.collection.immutable.AbstractImmutableCollection<T>
-
- org.eclipse.collections.impl.set.sorted.immutable.AbstractImmutableSortedSet<T>
-
- org.eclipse.collections.impl.set.sorted.immutable.ImmutableEmptySortedSet<T>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<SortedSetIterable<T>>
,java.lang.Iterable<T>
,java.util.Collection<T>
,java.util.Set<T>
,java.util.SortedSet<T>
,ImmutableCollection<T>
,InternalIterable<T>
,OrderedIterable<T>
,ReversibleIterable<T>
,SortedIterable<T>
,RichIterable<T>
,ImmutableSetIterable<T>
,SetIterable<T>
,ImmutableSortedSet<T>
,SortedSetIterable<T>
final class ImmutableEmptySortedSet<T> extends AbstractImmutableSortedSet<T> implements java.io.Serializable
This is a zero elementImmutableSortedSet
which is created by calling the SortedSets.immutable.empty() method.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Comparator<? super T>
comparator
(package private) static ImmutableSortedSet<?>
INSTANCE
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description ImmutableEmptySortedSet()
ImmutableEmptySortedSet(java.util.Comparator<? super T> comparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <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.java.util.Comparator<? super T>
comparator()
Returns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.int
compareTo(SortedSetIterable<T> o)
boolean
contains(java.lang.Object object)
Returns true if the iterable has an element which responds true to element.equals(object).ImmutableSortedSet<T>
drop(int count)
Returns an iterable after skipping the firstcount
elements or an empty iterable if thecount
is greater than the length of the iterable.void
each(Procedure<? super T> procedure)
The procedure is executed for each element in the iterable.boolean
equals(java.lang.Object other)
Follows the same general contract asSet.equals(Object)
.T
first()
void
forEach(int startIndex, int endIndex, Procedure<? super T> procedure)
Iterates over the section of the iterable covered by the specified inclusive indexes.<P> void
forEachWith(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.void
forEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure)
Iterates over the section of the iterable covered by the specified inclusive indexes.void
forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)
Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.T
getOnly()
Returns the element if the iterable has exactly one element.int
hashCode()
Follows the same general contract asSet.hashCode()
.int
indexOf(java.lang.Object object)
Returns the index of the first occurrence of the specified item in this iterable, or -1 if this iterable does not contain the item.java.util.Iterator<T>
iterator()
T
last()
T
max()
Returns the maximum element out of this container based on the natural order.T
max(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.T
min()
Returns the minimum element out of this container based on the natural order.T
min(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.ImmutableSortedSet<T>
newWith(T element)
This method is similar to thewith
method inMutableCollection
with the difference that a new copy of this collection with the element appended will be returned.ImmutableSortedSet<T>
newWithAll(java.lang.Iterable<? extends T> elements)
This method is similar to thewithAll
method inMutableCollection
with the difference that a new copy of this collection with the elements appended will be returned.ImmutableSortedSet<T>
newWithout(T element)
This method is similar to thewithout
method inMutableCollection
with the difference that a new copy of this collection with the element removed will be returned.ImmutableSortedSet<T>
newWithoutAll(java.lang.Iterable<? extends T> elements)
This method is similar to thewithoutAll
method inMutableCollection
with the difference that a new copy of this collection with the elements removed will be returned.ImmutableSortedSet<T>
reject(Predicate<? super T> predicate)
Returns all elements of the source collection that return false when evaluating of the predicate.<P> ImmutableSortedSet<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
.ImmutableSortedSet<T>
select(Predicate<? super T> predicate)
Returns all elements of the source collection that return true when evaluating the predicate.<S> ImmutableSortedSet<S>
selectInstancesOf(java.lang.Class<S> clazz)
Returns all elements of the source collection that are instances of the Classclazz
.<P> ImmutableSortedSet<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
.int
size()
Returns the number of items in this iterable.ImmutableSortedSet<T>
take(int count)
Returns the firstcount
elements of the iterable or all the elements in the iterable ifcount
is greater than the length of the iterable.ImmutableSortedSet<T>
tap(Procedure<? super T> procedure)
Executes the Procedure for each element in the iterable and returnsthis
.MutableStack<T>
toStack()
Converts the OrderedIterable to a mutable MutableStack implementation.private java.lang.Object
writeReplace()
<S,R extends java.util.Collection<Pair<T,S>>>
Rzip(java.lang.Iterable<S> that, R target)
Same asRichIterable.zip(Iterable)
but usestarget
for output.<R extends java.util.Collection<Pair<T,java.lang.Integer>>>
RzipWithIndex(R target)
Same asRichIterable.zipWithIndex()
but usestarget
for output.-
Methods inherited from class org.eclipse.collections.impl.set.sorted.immutable.AbstractImmutableSortedSet
asParallel, asReversed, cartesianProduct, castToSortedSet, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, corresponds, detectIndex, detectLastIndex, difference, differenceInto, distinct, dropWhile, flatCollect, getFirst, getLast, groupBy, groupByEach, headSet, intersect, intersectInto, isProperSubsetOf, isSubsetOf, newMutable, partition, partitionWhile, partitionWith, powerSet, subSet, symmetricDifference, symmetricDifferenceInto, tailSet, takeWhile, toImmutable, toReversed, union, unionInto, zip, zipWithIndex
-
Methods inherited from class org.eclipse.collections.impl.collection.immutable.AbstractImmutableCollection
add, addAll, castToCollection, chunk, clear, countBy, countByEach, countByWith, groupByUniqueKey, parallelStream, reduce, remove, removeAll, removeAllFrom, retainAll, spliterator, stream, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, asLazy, collect, collectIf, collectWith, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectOptional, detectWith, detectWithIfNone, detectWithOptional, flatCollect, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, isEmpty, noneSatisfy, noneSatisfyWith, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.collections.api.collection.ImmutableCollection
aggregateBy, aggregateInPlaceBy, castToCollection, countBy, countByEach, countByWith, flatCollectWith, groupByUniqueKey, parallelStream, spliterator, stream, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from interface org.eclipse.collections.api.set.sorted.ImmutableSortedSet
flatCollectWith, toImmutableSortedSet
-
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach
-
Methods inherited from interface org.eclipse.collections.api.ordered.OrderedIterable
getFirstOptional, getLastOptional, rejectWithIndex, selectWithIndex
-
Methods inherited from interface org.eclipse.collections.api.ordered.ReversibleIterable
reverseForEach, reverseForEachWithIndex
-
Methods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, 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, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString
-
-
-
-
Field Detail
-
INSTANCE
static final ImmutableSortedSet<?> INSTANCE
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
comparator
private final java.util.Comparator<? super T> comparator
-
-
Constructor Detail
-
ImmutableEmptySortedSet
ImmutableEmptySortedSet()
-
ImmutableEmptySortedSet
ImmutableEmptySortedSet(java.util.Comparator<? super T> comparator)
-
-
Method Detail
-
writeReplace
private java.lang.Object writeReplace()
-
equals
public boolean equals(java.lang.Object other)
Description copied from interface:SetIterable
Follows the same general contract asSet.equals(Object)
.- Specified by:
equals
in interfacejava.util.Collection<T>
- Specified by:
equals
in interfacejava.util.Set<T>
- Specified by:
equals
in interfaceSetIterable<T>
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
Description copied from interface:SetIterable
Follows the same general contract asSet.hashCode()
.- Specified by:
hashCode
in interfacejava.util.Collection<T>
- Specified by:
hashCode
in interfacejava.util.Set<T>
- Specified by:
hashCode
in interfaceSetIterable<T>
- Overrides:
hashCode
in classjava.lang.Object
-
newWith
public ImmutableSortedSet<T> newWith(T element)
Description copied from interface:ImmutableCollection
This method is similar to thewith
method inMutableCollection
with the difference that a new copy of this collection with the element appended will be returned.- Specified by:
newWith
in interfaceImmutableCollection<T>
- Specified by:
newWith
in interfaceImmutableSortedSet<T>
- Overrides:
newWith
in classAbstractImmutableSortedSet<T>
-
newWithAll
public ImmutableSortedSet<T> newWithAll(java.lang.Iterable<? extends T> elements)
Description copied from interface:ImmutableCollection
This method is similar to thewithAll
method inMutableCollection
with the difference that a new copy of this collection with the elements appended will be returned.- Specified by:
newWithAll
in interfaceImmutableCollection<T>
- Specified by:
newWithAll
in interfaceImmutableSortedSet<T>
- Overrides:
newWithAll
in classAbstractImmutableSortedSet<T>
-
newWithout
public ImmutableSortedSet<T> newWithout(T element)
Description copied from interface:ImmutableCollection
This method is similar to thewithout
method inMutableCollection
with the difference that a new copy of this collection with the element removed will be returned.- Specified by:
newWithout
in interfaceImmutableCollection<T>
- Specified by:
newWithout
in interfaceImmutableSortedSet<T>
- Overrides:
newWithout
in classAbstractImmutableSortedSet<T>
-
newWithoutAll
public ImmutableSortedSet<T> newWithoutAll(java.lang.Iterable<? extends T> elements)
Description copied from interface:ImmutableCollection
This method is similar to thewithoutAll
method inMutableCollection
with the difference that a new copy of this collection with the elements removed will be returned.- Specified by:
newWithoutAll
in interfaceImmutableCollection<T>
- Specified by:
newWithoutAll
in interfaceImmutableSortedSet<T>
- Overrides:
newWithoutAll
in classAbstractImmutableSortedSet<T>
-
size
public int size()
Description copied from interface:RichIterable
Returns the number of items in this iterable.- Specified by:
size
in interfacejava.util.Collection<T>
- Specified by:
size
in interfaceRichIterable<T>
- Specified by:
size
in interfacejava.util.Set<T>
-
contains
public boolean contains(java.lang.Object object)
Description copied from interface:RichIterable
Returns true if the iterable has an element which responds true to element.equals(object).- Specified by:
contains
in interfacejava.util.Collection<T>
- Specified by:
contains
in interfaceRichIterable<T>
- Specified by:
contains
in interfacejava.util.Set<T>
- Overrides:
contains
in classAbstractRichIterable<T>
-
tap
public ImmutableSortedSet<T> tap(Procedure<? super T> procedure)
Description copied from interface:RichIterable
Executes 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()));
Example using an anonymous inner class:
RichIterable<Person> tapped = people.tap(new Procedure<Person>() { public void value(Person person) { LOGGER.info(person.getName()); } });
- Specified by:
tap
in interfaceImmutableCollection<T>
- Specified by:
tap
in interfaceImmutableSetIterable<T>
- Specified by:
tap
in interfaceImmutableSortedSet<T>
- Specified by:
tap
in interfaceOrderedIterable<T>
- Specified by:
tap
in interfaceReversibleIterable<T>
- Specified by:
tap
in interfaceRichIterable<T>
- Specified by:
tap
in interfaceSetIterable<T>
- Specified by:
tap
in interfaceSortedIterable<T>
- Specified by:
tap
in interfaceSortedSetIterable<T>
- Overrides:
tap
in classAbstractImmutableSortedSet<T>
- See Also:
RichIterable.each(Procedure)
,RichIterable.forEach(Procedure)
-
each
public void each(Procedure<? super T> procedure)
Description copied from interface:RichIterable
The procedure is executed for each element in the iterable.Example using a Java 8 lambda expression:
people.each(person -> LOGGER.info(person.getName()));
Example using an anonymous inner class:
people.each(new Procedure<Person>() { public void value(Person person) { LOGGER.info(person.getName()); } });
This method is a variant ofInternalIterable.forEach(Procedure)
that has a signature conflict withIterable.forEach(java.util.function.Consumer)
.- Specified by:
each
in interfaceRichIterable<T>
- See Also:
InternalIterable.forEach(Procedure)
,Iterable.forEach(java.util.function.Consumer)
-
forEach
public void forEach(int startIndex, int endIndex, Procedure<? super T> procedure)
Description copied from interface:OrderedIterable
Iterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive.e.g. OrderedIterable<People> people = FastList.newListWith(ted, mary, bob, sally) people.forEach(0, 1, new Procedure<Person>() { public void value(Person person) { LOGGER.info(person.getName()); } });
This code would output ted and mary's names.
- Specified by:
forEach
in interfaceOrderedIterable<T>
-
forEachWithIndex
public void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)
Description copied from interface:InternalIterable
Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.Example using a Java 8 lambda:
people.forEachWithIndex((Person person, int index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));
Example using an anonymous inner class:
people.forEachWithIndex(new ObjectIntProcedure<Person>() { public void value(Person person, int index) { LOGGER.info("Index: " + index + " person: " + person.getName()); } });
- Specified by:
forEachWithIndex
in interfaceInternalIterable<T>
- Specified by:
forEachWithIndex
in interfaceOrderedIterable<T>
- Overrides:
forEachWithIndex
in classAbstractRichIterable<T>
-
forEachWithIndex
public void forEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure)
Description copied from interface:OrderedIterable
Iterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive.e.g. OrderedIterable<People> people = FastList.newListWith(ted, mary, bob, sally) people.forEachWithIndex(0, 1, new ObjectIntProcedure<Person>() { public void value(Person person, int index) { LOGGER.info(person.getName()); } });
This code would output ted and mary's names.
- Specified by:
forEachWithIndex
in interfaceOrderedIterable<T>
-
forEachWith
public <P> void forEachWith(Procedure2<? super T,? super P> procedure, P parameter)
Description copied from interface:InternalIterable
The 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:
forEachWith
in interfaceInternalIterable<T>
- Overrides:
forEachWith
in classAbstractRichIterable<T>
-
select
public ImmutableSortedSet<T> select(Predicate<? super T> predicate)
Description copied from interface:RichIterable
Returns 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"));
Example using an anonymous inner class:
RichIterable<Person> selected = people.select(new Predicate<Person>() { public boolean accept(Person person) { return person.getAddress().getCity().equals("London"); } });
- Specified by:
select
in interfaceImmutableCollection<T>
- Specified by:
select
in interfaceImmutableSetIterable<T>
- Specified by:
select
in interfaceImmutableSortedSet<T>
- Specified by:
select
in interfaceOrderedIterable<T>
- Specified by:
select
in interfaceReversibleIterable<T>
- Specified by:
select
in interfaceRichIterable<T>
- Specified by:
select
in interfaceSetIterable<T>
- Specified by:
select
in interfaceSortedIterable<T>
- Specified by:
select
in interfaceSortedSetIterable<T>
- Overrides:
select
in classAbstractImmutableSortedSet<T>
-
selectWith
public <P> ImmutableSortedSet<T> selectWith(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:RichIterable
Similar toRichIterable.select(Predicate)
, except with an evaluation parameter for the second generic argument inPredicate2
.E.g. return a
Collection
of 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));
Example using an anonymous inner class:
RichIterable<Person> selected = people.selectWith(new Predicate2<Person, Integer>() { public boolean accept(Person person, Integer age) { return person.getAge()>= age; } }, Integer.valueOf(18));
- Specified by:
selectWith
in interfaceImmutableCollection<T>
- Specified by:
selectWith
in interfaceImmutableSetIterable<T>
- Specified by:
selectWith
in interfaceImmutableSortedSet<T>
- Specified by:
selectWith
in interfaceOrderedIterable<T>
- Specified by:
selectWith
in interfaceReversibleIterable<T>
- Specified by:
selectWith
in interfaceRichIterable<T>
- Specified by:
selectWith
in interfaceSetIterable<T>
- Specified by:
selectWith
in interfaceSortedIterable<T>
- Specified by:
selectWith
in interfaceSortedSetIterable<T>
- Overrides:
selectWith
in classAbstractImmutableSortedSet<T>
- Parameters:
predicate
- aPredicate2
to use as the select criteriaparameter
- a parameter to pass in for evaluation of the second argumentP
inpredicate
- See Also:
RichIterable.select(Predicate)
-
reject
public ImmutableSortedSet<T> reject(Predicate<? super T> predicate)
Description copied from interface:RichIterable
Returns 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"));
Example using an anonymous inner class:
RichIterable<Person> rejected = people.reject(new Predicate<Person>() { public boolean accept(Person person) { return person.person.getLastName().equals("Smith"); } });
- Specified by:
reject
in interfaceImmutableCollection<T>
- Specified by:
reject
in interfaceImmutableSetIterable<T>
- Specified by:
reject
in interfaceImmutableSortedSet<T>
- Specified by:
reject
in interfaceOrderedIterable<T>
- Specified by:
reject
in interfaceReversibleIterable<T>
- Specified by:
reject
in interfaceRichIterable<T>
- Specified by:
reject
in interfaceSetIterable<T>
- Specified by:
reject
in interfaceSortedIterable<T>
- Specified by:
reject
in interfaceSortedSetIterable<T>
- Overrides:
reject
in classAbstractImmutableSortedSet<T>
- Parameters:
predicate
- aPredicate
to use as the reject criteria- Returns:
- a RichIterable that contains elements that cause
Predicate.accept(Object)
method to evaluate to false
-
rejectWith
public <P> ImmutableSortedSet<T> rejectWith(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:RichIterable
Similar toRichIterable.reject(Predicate)
, except with an evaluation parameter for the second generic argument inPredicate2
.E.g. return a
Collection
of 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));
Example using an anonymous inner class:
MutableList<Person> rejected = people.rejectWith(new Predicate2<Person, Integer>() { public boolean accept(Person person, Integer age) { return person.getAge() < age; } }, Integer.valueOf(18));
- Specified by:
rejectWith
in interfaceImmutableCollection<T>
- Specified by:
rejectWith
in interfaceImmutableSetIterable<T>
- Specified by:
rejectWith
in interfaceImmutableSortedSet<T>
- Specified by:
rejectWith
in interfaceOrderedIterable<T>
- Specified by:
rejectWith
in interfaceReversibleIterable<T>
- Specified by:
rejectWith
in interfaceRichIterable<T>
- Specified by:
rejectWith
in interfaceSetIterable<T>
- Specified by:
rejectWith
in interfaceSortedIterable<T>
- Specified by:
rejectWith
in interfaceSortedSetIterable<T>
- Overrides:
rejectWith
in classAbstractImmutableSortedSet<T>
- Parameters:
predicate
- aPredicate2
to use as the select criteriaparameter
- a parameter to pass in for evaluation of the second argumentP
inpredicate
- See Also:
RichIterable.select(Predicate)
-
selectInstancesOf
public <S> ImmutableSortedSet<S> selectInstancesOf(java.lang.Class<S> clazz)
Description copied from interface:RichIterable
Returns 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:
selectInstancesOf
in interfaceImmutableCollection<T>
- Specified by:
selectInstancesOf
in interfaceImmutableSetIterable<T>
- Specified by:
selectInstancesOf
in interfaceImmutableSortedSet<T>
- Specified by:
selectInstancesOf
in interfaceOrderedIterable<T>
- Specified by:
selectInstancesOf
in interfaceReversibleIterable<T>
- Specified by:
selectInstancesOf
in interfaceRichIterable<T>
- Specified by:
selectInstancesOf
in interfaceSetIterable<T>
- Specified by:
selectInstancesOf
in interfaceSortedIterable<T>
- Specified by:
selectInstancesOf
in interfaceSortedSetIterable<T>
- Overrides:
selectInstancesOf
in classAbstractImmutableSortedSet<T>
-
collectWithIndex
public <V> ImmutableList<V> collectWithIndex(ObjectIntToObjectFunction<? super T,? extends V> function)
Description copied from interface:OrderedIterable
Returns a new OrderedIterable using results obtained by applying the specified function to each element and its corresponding index.- Specified by:
collectWithIndex
in interfaceImmutableSortedSet<T>
- Specified by:
collectWithIndex
in interfaceOrderedIterable<T>
- Specified by:
collectWithIndex
in interfaceReversibleIterable<T>
- Specified by:
collectWithIndex
in interfaceSortedSetIterable<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:OrderedIterable
Adds elements to the target Collection using results obtained by applying the specified function to each element and its corresponding index.- Specified by:
collectWithIndex
in interfaceOrderedIterable<T>
- Since:
- 9.1.
-
iterator
public java.util.Iterator<T> iterator()
-
min
public T min(java.util.Comparator<? super T> comparator)
Description copied from interface:RichIterable
Returns the minimum element out of this container based on the comparator.- Specified by:
min
in interfaceRichIterable<T>
- Overrides:
min
in classAbstractRichIterable<T>
-
max
public T max(java.util.Comparator<? super T> comparator)
Description copied from interface:RichIterable
Returns the maximum element out of this container based on the comparator.- Specified by:
max
in interfaceRichIterable<T>
- Overrides:
max
in classAbstractRichIterable<T>
-
min
public T min()
Description copied from interface:RichIterable
Returns the minimum element out of this container based on the natural order.- Specified by:
min
in interfaceOrderedIterable<T>
- Specified by:
min
in interfaceRichIterable<T>
- Specified by:
min
in interfaceSortedIterable<T>
- Overrides:
min
in classAbstractRichIterable<T>
-
max
public T max()
Description copied from interface:RichIterable
Returns the maximum element out of this container based on the natural order.- Specified by:
max
in interfaceOrderedIterable<T>
- Specified by:
max
in interfaceRichIterable<T>
- Specified by:
max
in interfaceSortedIterable<T>
- Overrides:
max
in classAbstractRichIterable<T>
-
minBy
public <V extends java.lang.Comparable<? super V>> T minBy(Function<? super T,? extends V> function)
Description copied from interface:RichIterable
Returns the minimum elements out of this container based on the natural order of the attribute returned by Function.- Specified by:
minBy
in interfaceRichIterable<T>
- Overrides:
minBy
in classAbstractRichIterable<T>
-
maxBy
public <V extends java.lang.Comparable<? super V>> T maxBy(Function<? super T,? extends V> function)
Description copied from interface:RichIterable
Returns the maximum elements out of this container based on the natural order of the attribute returned by Function.- Specified by:
maxBy
in interfaceRichIterable<T>
- Overrides:
maxBy
in classAbstractRichIterable<T>
-
zip
public <S,R extends java.util.Collection<Pair<T,S>>> R zip(java.lang.Iterable<S> that, R target)
Description copied from interface:RichIterable
Same asRichIterable.zip(Iterable)
but usestarget
for output.- Specified by:
zip
in interfaceOrderedIterable<T>
- Specified by:
zip
in interfaceRichIterable<T>
- Overrides:
zip
in classAbstractRichIterable<T>
-
zipWithIndex
public <R extends java.util.Collection<Pair<T,java.lang.Integer>>> R zipWithIndex(R target)
Description copied from interface:RichIterable
Same asRichIterable.zipWithIndex()
but usestarget
for output.- Specified by:
zipWithIndex
in interfaceOrderedIterable<T>
- Specified by:
zipWithIndex
in interfaceRichIterable<T>
- Overrides:
zipWithIndex
in classAbstractRichIterable<T>
-
toStack
public MutableStack<T> toStack()
Description copied from interface:OrderedIterable
Converts the OrderedIterable to a mutable MutableStack implementation.- Specified by:
toStack
in interfaceOrderedIterable<T>
- Overrides:
toStack
in classAbstractImmutableSortedSet<T>
-
indexOf
public int indexOf(java.lang.Object object)
Description copied from interface:OrderedIterable
Returns the index of the first occurrence of the specified item in this iterable, or -1 if this iterable does not contain the item.- Specified by:
indexOf
in interfaceOrderedIterable<T>
- See Also:
List.indexOf(Object)
-
comparator
public java.util.Comparator<? super T> comparator()
Description copied from interface:SortedSetIterable
Returns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.- Specified by:
comparator
in interfaceSortedIterable<T>
- Specified by:
comparator
in interfacejava.util.SortedSet<T>
- Specified by:
comparator
in interfaceSortedSetIterable<T>
-
compareTo
public int compareTo(SortedSetIterable<T> o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<T>
-
take
public ImmutableSortedSet<T> take(int count)
Description copied from interface:ReversibleIterable
Returns the firstcount
elements of the iterable or all the elements in the iterable ifcount
is greater than the length of the iterable.- Specified by:
take
in interfaceImmutableSortedSet<T>
- Specified by:
take
in interfaceReversibleIterable<T>
- Specified by:
take
in interfaceSortedSetIterable<T>
- Parameters:
count
- the number of items to take.
-
drop
public ImmutableSortedSet<T> drop(int count)
Description copied from interface:ReversibleIterable
Returns an iterable after skipping the firstcount
elements or an empty iterable if thecount
is greater than the length of the iterable.- Specified by:
drop
in interfaceImmutableSortedSet<T>
- Specified by:
drop
in interfaceReversibleIterable<T>
- Specified by:
drop
in interfaceSortedSetIterable<T>
- Parameters:
count
- the number of items to drop.
-
getOnly
public T getOnly()
Description copied from interface:RichIterable
Returns the element if the iterable has exactly one element. Otherwise, throwIllegalStateException
.- Specified by:
getOnly
in interfaceRichIterable<T>
- Returns:
- an element of an iterable.
-
-