Class AbstractImmutableList.ImmutableSubList<T>
- java.lang.Object
-
- org.eclipse.collections.impl.AbstractRichIterable<T>
-
- org.eclipse.collections.impl.collection.immutable.AbstractImmutableCollection<T>
-
- org.eclipse.collections.impl.list.immutable.AbstractImmutableList<T>
-
- org.eclipse.collections.impl.list.immutable.AbstractImmutableList.ImmutableSubList<T>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Iterable<T>,java.util.Collection<T>,java.util.List<T>,java.util.RandomAccess,ImmutableCollection<T>,InternalIterable<T>,ImmutableList<T>,ListIterable<T>,OrderedIterable<T>,ReversibleIterable<T>,RichIterable<T>
- Enclosing class:
- AbstractImmutableList<T>
protected static class AbstractImmutableList.ImmutableSubList<T> extends AbstractImmutableList<T> implements java.io.Serializable, java.util.RandomAccess
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.collections.impl.list.immutable.AbstractImmutableList
AbstractImmutableList.ImmutableSubList<T>
-
-
Field Summary
Fields Modifier and Type Field Description private intoffsetprivate ImmutableList<T>originalprivate static longserialVersionUIDprivate intsize
-
Constructor Summary
Constructors Modifier Constructor Description protectedImmutableSubList(ImmutableList<T> list, int fromIndex, int toIndex)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckIfOutOfBounds(int index)voideach(Procedure<? super T> procedure)The procedure is executed for each element in the iterable.<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(ObjectIntProcedure<? super T> objectIntProcedure)Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.Tget(int index)Returns the item at the specified position in this list iterable.TgetFirst()Returns the first element of an iterable.TgetLast()Returns the last element of an iterable.ImmutableList<T>newWith(T newItem)This method is similar to thewithmethod inMutableCollectionwith the difference that a new copy of this collection with the element appended will be returned.intsize()Returns the number of items in this iterable.AbstractImmutableList.ImmutableSubList<T>subList(int fromIndex, int toIndex)MutableStack<T>toStack()Converts the OrderedIterable to a mutable MutableStack implementation.protected java.lang.ObjectwriteReplace()-
Methods inherited from class org.eclipse.collections.impl.list.immutable.AbstractImmutableList
add, addAll, appendString, asParallel, asReversed, castToList, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, collectWith, corresponds, count, detectIndex, detectLastIndex, distinct, distinct, distinctBy, drop, dropWhile, equals, flatCollect, flatCollect, forEach, forEachWithIndex, groupBy, groupBy, groupByEach, groupByEach, hashCode, indexOf, injectInto, injectInto, injectInto, injectInto, injectInto, iterator, lastIndexOf, listIterator, listIterator, max, max, maxBy, min, min, minBy, newMutable, newWithAll, newWithout, newWithoutAll, partition, partitionWhile, partitionWith, regularListEquals, reject, rejectWith, rejectWith, remove, replaceAll, select, selectInstancesOf, selectWith, selectWith, set, sort, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, take, takeWhile, tap, toImmutable, toReversed, zip, zipWithIndex
-
Methods inherited from class org.eclipse.collections.impl.collection.immutable.AbstractImmutableCollection
add, addAll, castToCollection, clear, countBy, countByEach, countByWith, groupByUniqueKey, parallelStream, reduce, remove, removeAll, removeAllFrom, retainAll, spliterator, stream, sumByDouble, sumByFloat, sumByInt, sumByLong, toArray, toArray
-
Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, asLazy, collect, collectIf, contains, containsAll, containsAllArguments, containsAllIterable, countWith, detect, detectOptional, detectWith, detectWithIfNone, detectWithOptional, forEach, groupByUniqueKey, into, isEmpty, noneSatisfy, noneSatisfyWith, reject, select, toBag, toBiMap, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
-
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, groupByUniqueKey, parallelStream, reduceBy, spliterator, stream, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from interface org.eclipse.collections.api.list.ImmutableList
collectWithIndex, flatCollectWith, rejectWithIndex, selectWithIndex, toImmutableList
-
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach
-
Methods inherited from interface java.util.List
add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, spliterator, toArray, toArray
-
Methods inherited from interface org.eclipse.collections.api.list.ListIterable
binarySearch, binarySearch, forEachInBoth
-
Methods inherited from interface org.eclipse.collections.api.ordered.OrderedIterable
collectWithIndex, getFirstOptional, getLastOptional, rejectWithIndex, selectWithIndex, zip, zipWithIndex
-
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, asLazy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, contains, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getOnly, groupByAndCollect, groupByUniqueKey, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, isEmpty, makeString, makeString, makeString, makeString, maxByOptional, maxOptional, maxOptional, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reduceBy, reduceInPlace, reduceInPlace, reject, select, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toArray, toArray, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableMap, toImmutableSet, toImmutableSortedBag, 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
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
original
private final ImmutableList<T> original
-
offset
private final int offset
-
size
private final int size
-
-
Constructor Detail
-
ImmutableSubList
protected ImmutableSubList(ImmutableList<T> list, int fromIndex, int toIndex)
-
-
Method Detail
-
get
public T get(int index)
Description copied from interface:ListIterableReturns the item at the specified position in this list iterable.- Specified by:
getin interfacejava.util.List<T>- Specified by:
getin interfaceListIterable<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 interfacejava.util.List<T>- Specified by:
sizein interfaceRichIterable<T>
-
newWith
public ImmutableList<T> newWith(T newItem)
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 interfaceImmutableList<T>
-
writeReplace
protected java.lang.Object writeReplace()
-
subList
public AbstractImmutableList.ImmutableSubList<T> subList(int fromIndex, int toIndex)
- Specified by:
subListin interfaceImmutableList<T>- Specified by:
subListin interfacejava.util.List<T>- Specified by:
subListin interfaceListIterable<T>- Overrides:
subListin classAbstractImmutableList<T>- See Also:
List.subList(int, int)
-
checkIfOutOfBounds
private void checkIfOutOfBounds(int index)
-
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 interfaceListIterable<T>- Specified by:
getFirstin interfaceOrderedIterable<T>- Specified by:
getFirstin interfaceRichIterable<T>- Overrides:
getFirstin classAbstractImmutableList<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 interfaceListIterable<T>- Specified by:
getLastin interfaceOrderedIterable<T>- Specified by:
getLastin interfaceRichIterable<T>- Overrides:
getLastin classAbstractImmutableList<T>
-
toStack
public MutableStack<T> toStack()
Description copied from interface:OrderedIterableConverts the OrderedIterable to a mutable MutableStack implementation.- Specified by:
toStackin 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(ObjectIntProcedure<? super T> objectIntProcedure)
Description copied from interface:InternalIterableIterates 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:
forEachWithIndexin interfaceInternalIterable<T>- Specified by:
forEachWithIndexin interfaceOrderedIterable<T>- Overrides:
forEachWithIndexin classAbstractImmutableList<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 classAbstractImmutableList<T>
-
-