Class AbstractMemoryEfficientMutableList<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.fixed.AbstractMemoryEfficientMutableList<T>
-
- All Implemented Interfaces:
java.lang.Cloneable
,java.lang.Iterable<T>
,java.util.Collection<T>
,java.util.List<T>
,java.util.RandomAccess
,FixedSizeCollection<T>
,MutableCollection<T>
,InternalIterable<T>
,FixedSizeList<T>
,ListIterable<T>
,MutableList<T>
,OrderedIterable<T>
,ReversibleIterable<T>
,RichIterable<T>
- Direct Known Subclasses:
DoubletonList
,EmptyList
,QuadrupletonList
,QuintupletonList
,SextupletonList
,SingletonList
,TripletonList
public abstract class AbstractMemoryEfficientMutableList<T> extends AbstractMutableList<T> implements FixedSizeList<T>, java.util.RandomAccess
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
AbstractMemoryEfficientMutableList.SubList<T>
-
Constructor Summary
Constructors Constructor Description AbstractMemoryEfficientMutableList()
-
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)
boolean
addAllIterable(java.lang.Iterable<? extends T> iterable)
void
clear()
FixedSizeList<T>
clone()
private void
insertionSort(java.util.Comparator<? super T> comparator)
private boolean
isPreviousGreaterThanCurrent(java.util.Comparator<? super T> comparator, int index)
java.util.ListIterator<T>
listIterator()
java.util.ListIterator<T>
listIterator(int index)
T
remove(int index)
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection<?> collection)
boolean
removeAllIterable(java.lang.Iterable<?> iterable)
boolean
removeIf(Predicate<? super T> predicate)
Removes all elements in the collection that evaluate to true for the specified predicate.<P> boolean
removeIfWith(Predicate2<? super T,? super P> predicate, P parameter)
Removes all elements in the collection that evaluate to true for the specified predicate2 and parameter.boolean
retainAll(java.util.Collection<?> collection)
boolean
retainAllIterable(java.lang.Iterable<?> iterable)
void
sort(java.util.Comparator<? super T> comparator)
This method checks if comparator is null and use a ComparableComparator if it is.MutableList<T>
subList(int fromIndex, int toIndex)
FixedSizeList<T>
tap(Procedure<? super T> procedure)
Executes the Procedure for each element in the iterable and returnsthis
.FixedSizeList<T>
toReversed()
Returns a new MutableList in reverse order.MutableList<T>
withAll(java.lang.Iterable<? extends T> elements)
This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements.MutableList<T>
without(T element)
This method allows mutable and fixed size collections the ability to remove elements from their existing elements.MutableList<T>
withoutAll(java.lang.Iterable<? extends T> elements)
This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements.-
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, forEachWith, forEachWithIndex, forEachWithIndex, getFirst, getLast, groupBy, groupByEach, groupByUniqueKey, hashCode, indexOf, injectInto, injectInto, injectInto, injectInto, injectIntoWith, iterator, lastIndexOf, max, max, maxBy, min, min, minBy, newEmpty, noneSatisfy, noneSatisfyWith, partition, partitionWhile, partitionWith, reject, rejectWith, select, selectAndRejectWith, selectInstancesOf, selectWith, sortThisByBoolean, sortThisByByte, sortThisByChar, sortThisByDouble, sortThisByFloat, sortThisByInt, sortThisByLong, sortThisByShort, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, take, takeWhile, toSet, toSortedList, zip, zip, zipWithIndex, zipWithIndex
-
Methods inherited from class org.eclipse.collections.impl.collection.mutable.AbstractMutableCollection
countBy, countByEach, countByWith, reduce, 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.list.FixedSizeList
sortThis, sortThis, with
-
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach, forEachWith
-
Methods inherited from interface java.util.List
contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, replaceAll, set, size, spliterator, toArray, toArray
-
Methods inherited from interface org.eclipse.collections.api.list.ListIterable
asParallel, binarySearch, binarySearch, equals, forEachInBoth, get, getFirst, getLast, hashCode, lastIndexOf
-
Methods inherited from interface org.eclipse.collections.api.collection.MutableCollection
aggregateBy, aggregateInPlaceBy, countBy, countByEach, countByWith, groupByUniqueKey, injectIntoWith, selectAndRejectWith, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from interface org.eclipse.collections.api.list.MutableList
asSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, collectWithIndex, distinct, distinct, distinctBy, drop, dropWhile, flatCollect, flatCollectWith, groupBy, groupByEach, newEmpty, partition, partitionWhile, partitionWith, reject, rejectWith, rejectWithIndex, reverseThis, select, selectInstancesOf, selectWith, selectWithIndex, shuffleThis, shuffleThis, sortThisBy, sortThisByBoolean, sortThisByByte, sortThisByChar, sortThisByDouble, sortThisByFloat, sortThisByInt, sortThisByLong, sortThisByShort, take, takeWhile, toImmutable, toImmutableList, zip, zipWithIndex
-
Methods inherited from interface org.eclipse.collections.api.ordered.OrderedIterable
collectWithIndex, corresponds, detectIndex, forEach, forEachWithIndex, forEachWithIndex, getFirstOptional, getLastOptional, indexOf, max, min, rejectWithIndex, selectWithIndex, toStack, zip, zipWithIndex
-
Methods inherited from interface org.eclipse.collections.api.ordered.ReversibleIterable
asReversed, detectLastIndex, 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, contains, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, isEmpty, makeString, makeString, makeString, makeString, max, maxBy, maxByOptional, maxOptional, maxOptional, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, size, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, 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
-
-
-
-
Method Detail
-
clone
public FixedSizeList<T> clone()
- Specified by:
clone
in interfaceMutableList<T>
- Overrides:
clone
in classAbstractMutableList<T>
-
tap
public FixedSizeList<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 interfaceFixedSizeCollection<T>
- Specified by:
tap
in interfaceFixedSizeList<T>
- Specified by:
tap
in interfaceListIterable<T>
- Specified by:
tap
in interfaceMutableCollection<T>
- Specified by:
tap
in interfaceMutableList<T>
- Specified by:
tap
in interfaceOrderedIterable<T>
- Specified by:
tap
in interfaceReversibleIterable<T>
- Specified by:
tap
in interfaceRichIterable<T>
- Overrides:
tap
in classAbstractMutableList<T>
- See Also:
RichIterable.each(Procedure)
,RichIterable.forEach(Procedure)
-
add
public boolean add(T o)
- Specified by:
add
in interfacejava.util.Collection<T>
- Specified by:
add
in interfaceFixedSizeCollection<T>
- Specified by:
add
in interfacejava.util.List<T>
- Overrides:
add
in classAbstractMutableCollection<T>
-
addAll
public boolean addAll(java.util.Collection<? extends T> collection)
- Specified by:
addAll
in interfacejava.util.Collection<T>
- Specified by:
addAll
in interfaceFixedSizeCollection<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>
-
addAllIterable
public boolean addAllIterable(java.lang.Iterable<? extends T> iterable)
- Specified by:
addAllIterable
in interfaceFixedSizeCollection<T>
- Specified by:
addAllIterable
in interfaceMutableCollection<T>
- Overrides:
addAllIterable
in classAbstractMutableCollection<T>
- See Also:
Collection.addAll(Collection)
-
remove
public boolean remove(java.lang.Object o)
- Specified by:
remove
in interfacejava.util.Collection<T>
- Specified by:
remove
in interfaceFixedSizeCollection<T>
- Specified by:
remove
in interfacejava.util.List<T>
- Overrides:
remove
in classAbstractMutableCollection<T>
-
removeAll
public boolean removeAll(java.util.Collection<?> collection)
- Specified by:
removeAll
in interfacejava.util.Collection<T>
- Specified by:
removeAll
in interfaceFixedSizeCollection<T>
- Specified by:
removeAll
in interfacejava.util.List<T>
- Overrides:
removeAll
in classAbstractMutableList<T>
-
removeAllIterable
public boolean removeAllIterable(java.lang.Iterable<?> iterable)
- Specified by:
removeAllIterable
in interfaceFixedSizeCollection<T>
- Specified by:
removeAllIterable
in interfaceMutableCollection<T>
- Overrides:
removeAllIterable
in classAbstractMutableCollection<T>
- See Also:
Collection.removeAll(Collection)
-
removeIf
public boolean removeIf(Predicate<? super T> predicate)
Description copied from interface:MutableCollection
Removes all elements in the collection that evaluate to true for the specified predicate.e.g. return lastNames.removeIf(Predicates.isNull());
- Specified by:
removeIf
in interfaceFixedSizeCollection<T>
- Specified by:
removeIf
in interfaceMutableCollection<T>
- Overrides:
removeIf
in classAbstractMutableList<T>
-
removeIfWith
public <P> boolean removeIfWith(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:MutableCollection
Removes all elements in the collection that evaluate to true for the specified predicate2 and parameter.return lastNames.removeIfWith(Predicates2.isNull(), null);
- Specified by:
removeIfWith
in interfaceFixedSizeCollection<T>
- Specified by:
removeIfWith
in interfaceMutableCollection<T>
- Overrides:
removeIfWith
in classAbstractMutableList<T>
-
retainAll
public boolean retainAll(java.util.Collection<?> collection)
- Specified by:
retainAll
in interfacejava.util.Collection<T>
- Specified by:
retainAll
in interfaceFixedSizeCollection<T>
- Specified by:
retainAll
in interfacejava.util.List<T>
- Overrides:
retainAll
in classAbstractMutableList<T>
-
retainAllIterable
public boolean retainAllIterable(java.lang.Iterable<?> iterable)
- Specified by:
retainAllIterable
in interfaceFixedSizeCollection<T>
- Specified by:
retainAllIterable
in interfaceMutableCollection<T>
- Overrides:
retainAllIterable
in classAbstractMutableCollection<T>
- See Also:
Collection.retainAll(Collection)
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Collection<T>
- Specified by:
clear
in interfaceFixedSizeCollection<T>
- Specified by:
clear
in interfacejava.util.List<T>
-
sort
public void sort(java.util.Comparator<? super T> comparator)
This method checks if comparator is null and use a ComparableComparator if it is.- Specified by:
sort
in interfacejava.util.List<T>
- Since:
- 10.0
-
insertionSort
private void insertionSort(java.util.Comparator<? super T> comparator)
-
isPreviousGreaterThanCurrent
private boolean isPreviousGreaterThanCurrent(java.util.Comparator<? super T> comparator, int index)
-
toReversed
public FixedSizeList<T> toReversed()
Description copied from interface:MutableList
Returns a new MutableList in reverse order.- Specified by:
toReversed
in interfaceFixedSizeList<T>
- Specified by:
toReversed
in interfaceListIterable<T>
- Specified by:
toReversed
in interfaceMutableList<T>
- Specified by:
toReversed
in interfaceReversibleIterable<T>
-
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)
-
without
public MutableList<T> without(T element)
Description copied from interface:MutableCollection
This method allows mutable and fixed size collections the ability to remove elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling remove. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:MutableCollection<String> list = list.without("1"); list = list.without("2"); return list;
In the case ofFixedSizeCollection
a new instance of MutableCollection will be returned by without, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling remove on itself.- Specified by:
without
in interfaceFixedSizeCollection<T>
- Specified by:
without
in interfaceFixedSizeList<T>
- Specified by:
without
in interfaceMutableCollection<T>
- Specified by:
without
in interfaceMutableList<T>
- See Also:
Collection.remove(Object)
-
withAll
public MutableList<T> withAll(java.lang.Iterable<? extends T> elements)
Description copied from interface:MutableCollection
This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new elements to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:MutableCollection<String> list = list.withAll(FastList.newListWith("1", "2"));
In the case ofFixedSizeCollection
a new instance of MutableCollection will be returned by withAll, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling addAll on itself.- Specified by:
withAll
in interfaceFixedSizeCollection<T>
- Specified by:
withAll
in interfaceFixedSizeList<T>
- Specified by:
withAll
in interfaceMutableCollection<T>
- Specified by:
withAll
in interfaceMutableList<T>
- See Also:
Collection.addAll(Collection)
-
withoutAll
public MutableList<T> withoutAll(java.lang.Iterable<? extends T> elements)
Description copied from interface:MutableCollection
This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling removeAll. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:MutableCollection<String> list = list.withoutAll(FastList.newListWith("1", "2"));
In the case ofFixedSizeCollection
a new instance of MutableCollection will be returned by withoutAll, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling removeAll on itself.- Specified by:
withoutAll
in interfaceFixedSizeCollection<T>
- Specified by:
withoutAll
in interfaceFixedSizeList<T>
- Specified by:
withoutAll
in interfaceMutableCollection<T>
- Specified by:
withoutAll
in interfaceMutableList<T>
- See Also:
Collection.removeAll(Collection)
-
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)
-
listIterator
public java.util.ListIterator<T> listIterator()
- Specified by:
listIterator
in interfacejava.util.List<T>
- Specified by:
listIterator
in interfaceListIterable<T>
- Overrides:
listIterator
in classAbstractMutableList<T>
- See Also:
List.listIterator()
-
-