Class CharArrayList
java.lang.Object
org.eclipse.collections.impl.primitive.AbstractCharIterable
org.eclipse.collections.impl.list.mutable.primitive.CharArrayList
- All Implemented Interfaces:
Externalizable, Serializable, CharIterable, MutableCharCollection, CharList, MutableCharList, OrderedCharIterable, ReversibleCharIterable, PrimitiveIterable
CharArrayList is similar to FastList, and is memory-optimized for char primitives.
This file was automatically generated from template file primitiveArrayList.stg.
- Since:
- 3.0.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final char[]protected char[]private static final intprivate static final longprotected intprivate static final char[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(char newItem) booleanaddAll(char... source) booleanaddAll(CharIterable source) booleanaddAllAtIndex(int index, char... source) booleanaddAllAtIndex(int index, CharIterable source) voidaddAtIndex(int index, char element) private voidaddAtIndexLessThanSize(int index, char element) booleanallSatisfy(CharPredicate predicate) Returns true if all of the elements in the CharIterable return true for the specified predicate, otherwise returns false.booleananySatisfy(CharPredicate predicate) Returns true if any of the elements in the CharIterable return true for the specified predicate, otherwise returns false.voidappendString(Appendable appendable, String start, String separator, String end) Prints a string representation of this collection onto the givenAppendable.intbinarySearch(char value) boxed()Returns a primitive iterator that can be used to iterate over the CharIterable in an imperative style.private voidchunk(int size) Partitions elements in fixed size chunks.voidclear()<V> MutableList<V> collect(CharToObjectFunction<? extends V> function) Returns a new collection with the results of applying the specified function on each element of the source collection.<V, R extends Collection<V>>
Rcollect(CharToObjectFunction<? extends V> function, R target) Same asCharIterable.collect(CharToObjectFunction), only the results are added to the target Collection.booleancontains(char value) Returns true if the value is contained in the CharIterable, and false if it is not.private voidcopyItems(int sourceSize, char[] source) private char[]copyItemsWithNewCapacity(int newCapacity) intcount(CharPredicate predicate) Returns a count of the number of elements in the CharIterable that return true for the specified predicate.chardetectIfNone(CharPredicate predicate, char ifNone) distinct()longdotProduct(CharList list) voideach(CharProcedure procedure) A synonym for forEach.voidensureCapacity(int minCapacity) private voidbooleanFollows the same general contract asList.equals(Object).voidforEachWithIndex(CharIntProcedure procedure) charget(int index) chargetFirst()chargetLast()inthashCode()Follows the same general contract asList.hashCode().intindexOf(char value) <T> TinjectInto(T injectedValue, ObjectCharToObjectFunction<? super T, ? extends T> function) <T> TinjectIntoWithIndex(T injectedValue, ObjectCharIntToObjectFunction<? super T, ? extends T> function) intlastIndexOf(char value) charmax()charmin()newEmpty()Creates a new empty CharArrayList.private IndexOutOfBoundsExceptionnewIndexOutOfBoundsException(int index) static CharArrayListnewList(CharIterable source) static CharArrayListnewListWith(char... elements) Creates a new list using the passedelementsargument as the backing store.static CharArrayListnewWithNValues(int size, char value) voidreject(CharPredicate predicate) Returns a new CharIterable with all of the elements in the CharIterable that return false for the specified predicate.<R extends MutableCharCollection>
Rreject(CharPredicate predicate, R target) Same asCharIterable.reject(CharPredicate), only the results are added to the target MutableCharCollection.booleanremove(char value) booleanremoveAll(char... source) booleanremoveAll(CharIterable source) charremoveAtIndex(int index) booleanremoveIf(CharPredicate predicate) booleanretainAll(char... source) booleanretainAll(CharIterable source) select(CharPredicate predicate) Returns a new CharIterable with all of the elements in the CharIterable that return true for the specified predicate.<R extends MutableCharCollection>
Rselect(CharPredicate predicate, R target) Same asCharIterable.select(CharPredicate), only the results are added to the target MutableCharCollection.charset(int index, char element) private voidshiftElementsAtIndex(int index, int sourceSize) intsize()Returns the number of items in this iterable.private intsizePlusFiftyPercent(int oldSize) sortThis()Sorts this list mutating its contents and returns the same mutable list (this).sortThis(CharComparator comparator) Sorts the internal data structure of this list and returns the list itself as a convenience.subList(int fromIndex, int toIndex) longsum()voidswap(int index1, int index2) private voidthrowOutOfBounds(int index) char[]toArray()Converts the CharIterable to a primitive char array.char[]toArray(char[] target) Converts the CharIterable to a primitive char array.Returns an immutable copy of this list.toStack()Converts the collection to a CharStack.private voidtransferItemsToNewArrayWithCapacity(int newCapacity) voidprivate voidwipeAndResetTheEnd(int newCurrentFilledIndex) with(char element) with(char element1, char element2) with(char element1, char element2, char element3) with(char element1, char element2, char element3, char... elements) withAll(CharIterable elements) private CharArrayListwithArrayCopy(char[] elements, int begin, int length) without(char element) withoutAll(CharIterable elements) static CharArrayListwrapCopy(char... array) Creates a new list by first copying the array passed in.void<T> MutableList<CharObjectPair<T>> Returns aMutableListformed from thisMutableCharListand aListIterableby combining corresponding elements in pairs.zipChar(CharIterable iterable) Returns aMutableListformed from thisMutableCharListand anotherCharListby combining corresponding elements in pairs.Methods inherited from class AbstractCharIterable
asLazy, average, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toStringMethods inherited from interface CharIterable
asLazy, average, averageIfEmpty, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, containsAll, containsAll, containsAny, containsAny, containsNone, containsNone, flatCollect, forEach, injectIntoBoolean, injectIntoByte, injectIntoChar, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, injectIntoShort, maxIfEmpty, median, medianIfEmpty, minIfEmpty, noneSatisfy, reduce, reduceIfEmpty, summaryStatistics, toBag, toList, toSet, toSortedArray, toSortedList, toSortedList, toSortedListBy, toSortedListByMethods inherited from interface CharList
forEachInBothMethods inherited from interface MutableCharList
collectWithIndex, rejectWithIndex, selectWithIndex, shuffleThis, shuffleThis, sortThisBy, sortThisBy, tapMethods inherited from interface OrderedCharIterable
collectWithIndex, rejectWithIndex, selectWithIndexMethods inherited from interface PrimitiveIterable
appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
DEFAULT_SIZED_EMPTY_ARRAY
private static final char[] DEFAULT_SIZED_EMPTY_ARRAY -
ZERO_SIZED_ARRAY
private static final char[] ZERO_SIZED_ARRAY -
MAXIMUM_ARRAY_SIZE
private static final int MAXIMUM_ARRAY_SIZE- See Also:
-
size
protected int size -
items
protected transient char[] items
-
-
Constructor Details
-
CharArrayList
public CharArrayList() -
CharArrayList
public CharArrayList(int initialCapacity) -
CharArrayList
public CharArrayList(char... array)
-
-
Method Details
-
newListWith
Creates a new list using the passedelementsargument as the backing store.!!! WARNING: This method uses the passed in array, so can be very unsafe if the original array is held onto anywhere else. !!!
-
newList
-
newWithNValues
-
wrapCopy
Creates a new list by first copying the array passed in. -
size
public int size()Description copied from interface:PrimitiveIterableReturns the number of items in this iterable.- Specified by:
sizein interfacePrimitiveIterable
-
clear
public void clear()- Specified by:
clearin interfaceMutableCharCollection
-
contains
public boolean contains(char value) Description copied from interface:CharIterableReturns true if the value is contained in the CharIterable, and false if it is not.- Specified by:
containsin interfaceCharIterable
-
get
-
newIndexOutOfBoundsException
-
getFirst
public char getFirst()- Specified by:
getFirstin interfaceOrderedCharIterable
-
getLast
public char getLast()- Specified by:
getLastin interfaceReversibleCharIterable
-
checkEmpty
private void checkEmpty() -
indexOf
public int indexOf(char value) - Specified by:
indexOfin interfaceOrderedCharIterable
-
lastIndexOf
public int lastIndexOf(char value) - Specified by:
lastIndexOfin interfaceCharList
-
trimToSize
public void trimToSize() -
transferItemsToNewArrayWithCapacity
private void transferItemsToNewArrayWithCapacity(int newCapacity) -
copyItemsWithNewCapacity
private char[] copyItemsWithNewCapacity(int newCapacity) -
sizePlusFiftyPercent
private int sizePlusFiftyPercent(int oldSize) -
ensureCapacity
public void ensureCapacity(int minCapacity) -
ensureCapacityForAdd
private void ensureCapacityForAdd() -
add
public boolean add(char newItem) - Specified by:
addin interfaceMutableCharCollection
-
addAll
public boolean addAll(char... source) - Specified by:
addAllin interfaceMutableCharCollection
-
addAll
- Specified by:
addAllin interfaceMutableCharCollection
-
copyItems
private void copyItems(int sourceSize, char[] source) -
throwOutOfBounds
private void throwOutOfBounds(int index) -
addAtIndex
public void addAtIndex(int index, char element) - Specified by:
addAtIndexin interfaceMutableCharList
-
addAtIndexLessThanSize
private void addAtIndexLessThanSize(int index, char element) -
addAllAtIndex
public boolean addAllAtIndex(int index, char... source) - Specified by:
addAllAtIndexin interfaceMutableCharList
-
addAllAtIndex
- Specified by:
addAllAtIndexin interfaceMutableCharList
-
shiftElementsAtIndex
private void shiftElementsAtIndex(int index, int sourceSize) -
remove
public boolean remove(char value) - Specified by:
removein interfaceMutableCharCollection
-
removeIf
- Specified by:
removeIfin interfaceMutableCharCollection
-
wipeAndResetTheEnd
private void wipeAndResetTheEnd(int newCurrentFilledIndex) -
removeAll
- Specified by:
removeAllin interfaceMutableCharCollection
-
removeAll
public boolean removeAll(char... source) - Specified by:
removeAllin interfaceMutableCharCollection
-
retainAll
- Specified by:
retainAllin interfaceMutableCharCollection- See Also:
-
retainAll
public boolean retainAll(char... source) - Specified by:
retainAllin interfaceMutableCharCollection- See Also:
-
removeAtIndex
public char removeAtIndex(int index) - Specified by:
removeAtIndexin interfaceMutableCharList
-
set
public char set(int index, char element) - Specified by:
setin interfaceMutableCharList
-
swap
public void swap(int index1, int index2) - Specified by:
swapin interfaceMutableCharList
-
with
- Specified by:
within interfaceMutableCharCollection- Specified by:
within interfaceMutableCharList
-
without
- Specified by:
withoutin interfaceMutableCharCollection- Specified by:
withoutin interfaceMutableCharList
-
withAll
- Specified by:
withAllin interfaceMutableCharCollection- Specified by:
withAllin interfaceMutableCharList
-
withoutAll
- Specified by:
withoutAllin interfaceMutableCharCollection- Specified by:
withoutAllin interfaceMutableCharList
-
with
-
with
-
with
-
withArrayCopy
-
charIterator
Description copied from interface:CharIterableReturns a primitive iterator that can be used to iterate over the CharIterable in an imperative style.- Specified by:
charIteratorin interfaceCharIterable- Specified by:
charIteratorin interfaceMutableCharCollection
-
each
Description copied from interface:CharIterableA synonym for forEach.- Specified by:
eachin interfaceCharIterable- Since:
- 7.0.
-
forEachWithIndex
- Specified by:
forEachWithIndexin interfaceOrderedCharIterable
-
injectInto
public <T> T injectInto(T injectedValue, ObjectCharToObjectFunction<? super T, ? extends T> function) - Specified by:
injectIntoin interfaceCharIterable
-
injectIntoWithIndex
public <T> T injectIntoWithIndex(T injectedValue, ObjectCharIntToObjectFunction<? super T, ? extends T> function) - Specified by:
injectIntoWithIndexin interfaceOrderedCharIterable- Specified by:
injectIntoWithIndexin interfaceReversibleCharIterable
-
chunk
Description copied from interface:CharIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceCharIterable- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingCharIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-
count
Description copied from interface:CharIterableReturns a count of the number of elements in the CharIterable that return true for the specified predicate.- Specified by:
countin interfaceCharIterable
-
anySatisfy
Description copied from interface:CharIterableReturns true if any of the elements in the CharIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfyin interfaceCharIterable
-
allSatisfy
Description copied from interface:CharIterableReturns true if all of the elements in the CharIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfyin interfaceCharIterable
-
select
Description copied from interface:CharIterableReturns a new CharIterable with all of the elements in the CharIterable that return true for the specified predicate.- Specified by:
selectin interfaceCharIterable- Specified by:
selectin interfaceCharList- Specified by:
selectin interfaceMutableCharCollection- Specified by:
selectin interfaceMutableCharList- Specified by:
selectin interfaceOrderedCharIterable- Specified by:
selectin interfaceReversibleCharIterable
-
select
Description copied from interface:CharIterableSame asCharIterable.select(CharPredicate), only the results are added to the target MutableCharCollection.- Specified by:
selectin interfaceCharIterable- Since:
- 8.1.
-
reject
Description copied from interface:CharIterableReturns a new CharIterable with all of the elements in the CharIterable that return false for the specified predicate.- Specified by:
rejectin interfaceCharIterable- Specified by:
rejectin interfaceCharList- Specified by:
rejectin interfaceMutableCharCollection- Specified by:
rejectin interfaceMutableCharList- Specified by:
rejectin interfaceOrderedCharIterable- Specified by:
rejectin interfaceReversibleCharIterable
-
reject
Description copied from interface:CharIterableSame asCharIterable.reject(CharPredicate), only the results are added to the target MutableCharCollection.- Specified by:
rejectin interfaceCharIterable- Since:
- 8.1.
-
detectIfNone
- Specified by:
detectIfNonein interfaceCharIterable
-
collect
Description copied from interface:CharIterableReturns a new collection with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.- Specified by:
collectin interfaceCharIterable- Specified by:
collectin interfaceCharList- Specified by:
collectin interfaceMutableCharCollection- Specified by:
collectin interfaceMutableCharList- Specified by:
collectin interfaceOrderedCharIterable- Specified by:
collectin interfaceReversibleCharIterable
-
collect
Description copied from interface:CharIterableSame asCharIterable.collect(CharToObjectFunction), only the results are added to the target Collection.- Specified by:
collectin interfaceCharIterable- Since:
- 8.1.
-
max
public char max()- Specified by:
maxin interfaceCharIterable
-
min
public char min()- Specified by:
minin interfaceCharIterable
-
sum
public long sum()- Specified by:
sumin interfaceCharIterable
-
dotProduct
- Specified by:
dotProductin interfaceCharList
-
toArray
public char[] toArray()Description copied from interface:CharIterableConverts the CharIterable to a primitive char array.- Specified by:
toArrayin interfaceCharIterable
-
toArray
public char[] toArray(char[] target) Description copied from interface:CharIterableConverts the CharIterable to a primitive char array. If the collection fits into the provided array it is used to store its elements and is returned from the method, otherwise a new array of the appropriate size is allocated and returned. If the iterable is empty, the target array is returned unchanged.- Specified by:
toArrayin interfaceCharIterable
-
equals
-
hashCode
-
appendString
Description copied from interface:PrimitiveIterablePrints a string representation of this collection onto the givenAppendable. Prints the string returned byPrimitiveIterable.makeString(String, String, String).- Specified by:
appendStringin interfacePrimitiveIterable
-
asUnmodifiable
- Specified by:
asUnmodifiablein interfaceMutableCharCollection- Specified by:
asUnmodifiablein interfaceMutableCharList
-
asSynchronized
- Specified by:
asSynchronizedin interfaceMutableCharCollection- Specified by:
asSynchronizedin interfaceMutableCharList
-
toImmutable
Description copied from interface:MutableCharListReturns an immutable copy of this list.- Specified by:
toImmutablein interfaceCharList- Specified by:
toImmutablein interfaceMutableCharCollection- Specified by:
toImmutablein interfaceMutableCharList
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOException
-
asReversed
- Specified by:
asReversedin interfaceReversibleCharIterable
-
reverseThis
- Specified by:
reverseThisin interfaceMutableCharList
-
sortThis
Description copied from interface:MutableCharListSorts this list mutating its contents and returns the same mutable list (this).- Specified by:
sortThisin interfaceMutableCharList
-
sortThis
Description copied from interface:MutableCharListSorts the internal data structure of this list and returns the list itself as a convenience.- Specified by:
sortThisin interfaceMutableCharList
-
toReversed
- Specified by:
toReversedin interfaceCharList- Specified by:
toReversedin interfaceMutableCharList- Specified by:
toReversedin interfaceReversibleCharIterable
-
binarySearch
public int binarySearch(char value) - Specified by:
binarySearchin interfaceCharList
-
distinct
- Specified by:
distinctin interfaceCharList- Specified by:
distinctin interfaceMutableCharList- Specified by:
distinctin interfaceReversibleCharIterable
-
subList
- Specified by:
subListin interfaceCharList- Specified by:
subListin interfaceMutableCharList- See Also:
-
zipChar
Description copied from interface:MutableCharListReturns aMutableListformed from thisMutableCharListand anotherCharListby combining corresponding elements in pairs. If one of the twoCharLists is longer than the other, its remaining elements are ignored.- Specified by:
zipCharin interfaceCharList- Specified by:
zipCharin interfaceMutableCharList- Since:
- 9.1.
-
newEmpty
Creates a new empty CharArrayList.- Specified by:
newEmptyin interfaceMutableCharCollection- Specified by:
newEmptyin interfaceMutableCharList- Since:
- 9.2.
-
zip
Description copied from interface:MutableCharListReturns aMutableListformed from thisMutableCharListand aListIterableby combining corresponding elements in pairs. If one of the two Lists is longer than the other, its remaining elements are ignored.- Specified by:
zipin interfaceCharList- Specified by:
zipin interfaceMutableCharList- Since:
- 9.1.
-
boxed
- Specified by:
boxedin interfaceMutableCharList
-
toStack
Description copied from interface:OrderedCharIterableConverts the collection to a CharStack.- Specified by:
toStackin interfaceOrderedCharIterable
-