Class AbstractMutableList.SubList<T>
- java.lang.Object
-
- org.eclipse.collections.impl.AbstractRichIterable<T>
-
- org.eclipse.collections.impl.collection.mutable.AbstractMutableCollection<T>
-
- org.eclipse.collections.impl.list.mutable.AbstractMutableList<T>
-
- org.eclipse.collections.impl.list.mutable.AbstractMutableList.SubList<T>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable<T>
,java.util.Collection<T>
,java.util.List<T>
,java.util.RandomAccess
,MutableCollection<T>
,InternalIterable<T>
,ListIterable<T>
,MutableList<T>
,OrderedIterable<T>
,ReversibleIterable<T>
,RichIterable<T>
- Direct Known Subclasses:
AbstractMemoryEfficientMutableList.SubList
- Enclosing class:
- AbstractMutableList<T>
protected static class AbstractMutableList.SubList<T> extends AbstractMutableList<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.mutable.AbstractMutableList
AbstractMutableList.SubList<T>
-
-
Field Summary
Fields Modifier and Type Field Description private int
offset
private MutableList<T>
original
private static long
serialVersionUID
private int
size
-
Constructor Summary
Constructors Modifier Constructor Description protected
SubList(AbstractMutableList<T> list, int fromIndex, int toIndex)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, T element)
boolean
add(T o)
boolean
addAll(int index, java.util.Collection<? extends T> collection)
boolean
addAll(java.util.Collection<? extends T> collection)
private void
checkIfOutOfBounds(int index)
void
clear()
MutableList<T>
clone()
<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(ObjectIntProcedure<? super T> objectIntProcedure)
Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.T
get(int index)
Returns the item at the specified position in this list iterable.T
getFirst()
Returns the first element of an iterable.T
getLast()
Returns the last element of an iterable.java.util.Iterator<T>
iterator()
java.util.ListIterator<T>
listIterator(int index)
T
remove(int index)
T
set(int index, T element)
int
size()
Returns the number of items in this iterable.MutableList<T>
subList(int fromIndex, int toIndex)
MutableList<T>
toReversed()
Returns a new MutableList in reverse order.MutableStack<T>
toStack()
Converts the OrderedIterable to a mutable MutableStack implementation.protected java.lang.Object
writeReplace()
-
Methods inherited from class org.eclipse.collections.impl.list.mutable.AbstractMutableList
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, asParallel, asReversed, asSynchronized, asUnmodifiable, binarySearch, chunk, collect, collectIf, collectWith, contains, containsAll, corresponds, count, countWith, detect, detectIndex, detectLastIndex, detectOptional, detectWith, detectWithOptional, distinct, distinct, distinctBy, drop, dropWhile, each, equals, flatCollect, forEach, forEachWithIndex, groupBy, groupByEach, groupByUniqueKey, hashCode, indexOf, injectInto, injectInto, injectInto, injectInto, injectIntoWith, lastIndexOf, listIterator, max, max, maxBy, min, min, minBy, newEmpty, noneSatisfy, noneSatisfyWith, partition, partitionWhile, partitionWith, reject, rejectWith, removeAll, removeIf, removeIfWith, retainAll, select, selectAndRejectWith, selectInstancesOf, selectWith, sortThisByBoolean, sortThisByByte, sortThisByChar, sortThisByDouble, sortThisByFloat, sortThisByInt, sortThisByLong, sortThisByShort, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, take, takeWhile, tap, toSet, toSortedList, zip, zip, zipWithIndex, zipWithIndex
-
Methods inherited from class org.eclipse.collections.impl.collection.mutable.AbstractMutableCollection
addAllIterable, countBy, countByEach, countByWith, reduce, remove, removeAllIterable, retainAllIterable, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
asLazy, containsAllArguments, containsAllIterable, detectWithIfNone, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, into, isEmpty, toArray, toArray, toBag, toBiMap, toList, toMap, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach
-
Methods inherited from interface java.util.List
isEmpty, remove, replaceAll, sort, spliterator, toArray, toArray
-
Methods inherited from interface org.eclipse.collections.api.list.ListIterable
binarySearch, forEachInBoth
-
Methods inherited from interface org.eclipse.collections.api.collection.MutableCollection
addAllIterable, aggregateBy, aggregateInPlaceBy, countBy, countByEach, countByWith, removeAllIterable, retainAllIterable, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from interface org.eclipse.collections.api.list.MutableList
collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, collectWithIndex, flatCollect, flatCollectWith, reject, rejectWith, rejectWithIndex, reverseThis, select, selectWith, selectWithIndex, shuffleThis, shuffleThis, sortThis, sortThis, sortThisBy, toImmutable, toImmutableList, with, withAll, without, withoutAll
-
Methods inherited from interface org.eclipse.collections.api.ordered.OrderedIterable
collectWithIndex, 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, appendString, asLazy, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, countBy, countByEach, countByWith, detectIfNone, detectWithIfNone, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, isEmpty, makeString, makeString, makeString, makeString, maxByOptional, maxOptional, maxOptional, minByOptional, minOptional, minOptional, notEmpty, reduce, reduceInPlace, reduceInPlace, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toArray, toArray, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSortedBag, toSortedBag, toSortedBagBy, 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 MutableList<T> original
-
offset
private final int offset
-
size
private int size
-
-
Constructor Detail
-
SubList
protected SubList(AbstractMutableList<T> list, int fromIndex, int toIndex)
-
-
Method Detail
-
toReversed
public MutableList<T> toReversed()
Description copied from interface:MutableList
Returns a new MutableList in reverse order.- Specified by:
toReversed
in interfaceListIterable<T>
- Specified by:
toReversed
in interfaceMutableList<T>
- Specified by:
toReversed
in interfaceReversibleIterable<T>
-
writeReplace
protected java.lang.Object writeReplace()
-
add
public boolean add(T o)
- Specified by:
add
in interfacejava.util.Collection<T>
- Specified by:
add
in interfacejava.util.List<T>
- Overrides:
add
in classAbstractMutableCollection<T>
-
get
public T get(int index)
Description copied from interface:ListIterable
Returns the item at the specified position in this list iterable.- Specified by:
get
in interfacejava.util.List<T>
- Specified by:
get
in interfaceListIterable<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 interfacejava.util.List<T>
- Specified by:
size
in interfaceRichIterable<T>
-
clear
public void clear()
-
addAll
public boolean addAll(java.util.Collection<? extends T> collection)
- Specified by:
addAll
in interfacejava.util.Collection<T>
- Specified by:
addAll
in interfacejava.util.List<T>
- Overrides:
addAll
in classAbstractMutableCollection<T>
-
addAll
public boolean addAll(int index, java.util.Collection<? extends T> collection)
- Specified by:
addAll
in interfacejava.util.List<T>
-
iterator
public java.util.Iterator<T> iterator()
-
listIterator
public java.util.ListIterator<T> listIterator(int index)
- Specified by:
listIterator
in interfacejava.util.List<T>
- Specified by:
listIterator
in interfaceListIterable<T>
- Overrides:
listIterator
in classAbstractMutableList<T>
- See Also:
List.listIterator(int)
-
subList
public MutableList<T> subList(int fromIndex, int toIndex)
- Specified by:
subList
in interfacejava.util.List<T>
- Specified by:
subList
in interfaceListIterable<T>
- Specified by:
subList
in interfaceMutableList<T>
- Overrides:
subList
in classAbstractMutableList<T>
- See Also:
List.subList(int, int)
-
checkIfOutOfBounds
private void checkIfOutOfBounds(int index)
-
clone
public MutableList<T> clone()
- Specified by:
clone
in interfaceMutableList<T>
- Overrides:
clone
in classAbstractMutableList<T>
-
getFirst
public T getFirst()
Description copied from interface:RichIterable
Returns 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:
getFirst
in interfaceListIterable<T>
- Specified by:
getFirst
in interfaceOrderedIterable<T>
- Specified by:
getFirst
in interfaceRichIterable<T>
- Overrides:
getFirst
in classAbstractMutableList<T>
-
getLast
public T getLast()
Description copied from interface:RichIterable
Returns 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:
getLast
in interfaceListIterable<T>
- Specified by:
getLast
in interfaceOrderedIterable<T>
- Specified by:
getLast
in interfaceRichIterable<T>
- Overrides:
getLast
in classAbstractMutableList<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>
-
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 classAbstractMutableList<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 classAbstractMutableList<T>
-
-