Class CharArrayList
- java.lang.Object
-
- org.eclipse.collections.impl.primitive.AbstractCharIterable
-
- org.eclipse.collections.impl.list.mutable.primitive.CharArrayList
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,CharIterable,MutableCharCollection,CharList,MutableCharList,OrderedCharIterable,ReversibleCharIterable,PrimitiveIterable
public class CharArrayList extends AbstractCharIterable implements MutableCharList, java.io.Externalizable
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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classCharArrayList.InternalCharIterator
-
Field Summary
Fields Modifier and Type Field Description private static char[]DEFAULT_SIZED_EMPTY_ARRAYprotected char[]itemsprivate static intMAXIMUM_ARRAY_SIZEprivate static longserialVersionUIDprotected intsizeprivate static char[]ZERO_SIZED_ARRAY
-
Constructor Summary
Constructors Constructor Description CharArrayList()CharArrayList(char... array)CharArrayList(int initialCapacity)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(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(java.lang.Appendable appendable, java.lang.String start, java.lang.String separator, java.lang.String end)Prints a string representation of this collection onto the givenAppendable.LazyCharIterableasReversed()MutableCharListasSynchronized()MutableCharListasUnmodifiable()intbinarySearch(char value)MutableList<java.lang.Character>boxed()MutableCharIteratorcharIterator()Returns a primitive iterator that can be used to iterate over the CharIterable in an imperative style.private voidcheckEmpty()RichIterable<CharIterable>chunk(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 java.util.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)MutableCharListdistinct()longdotProduct(CharList list)voideach(CharProcedure procedure)A synonym for forEach.voidensureCapacity(int minCapacity)private voidensureCapacityForAdd()booleanequals(java.lang.Object otherList)Follows 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()CharArrayListnewEmpty()Creates a new empty CharArrayList.private java.lang.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)voidreadExternal(java.io.ObjectInput in)CharArrayListreject(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)CharArrayListreverseThis()CharArrayListselect(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)CharArrayListsortThis()Sorts this list mutating its contents and returns the same mutable list (this).CharArrayListsortThis(CharComparator comparator)Sorts the internal data structure of this list and returns the list itself as a convenience.MutableCharListsubList(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.ImmutableCharListtoImmutable()Returns an immutable copy of this list.CharArrayListtoReversed()MutableCharStacktoStack()Converts the collection to a CharStack.private voidtransferItemsToNewArrayWithCapacity(int newCapacity)voidtrimToSize()private voidwipeAndResetTheEnd(int newCurrentFilledIndex)CharArrayListwith(char element)CharArrayListwith(char element1, char element2)CharArrayListwith(char element1, char element2, char element3)CharArrayListwith(char element1, char element2, char element3, char... elements)CharArrayListwithAll(CharIterable elements)private CharArrayListwithArrayCopy(char[] elements, int begin, int length)CharArrayListwithout(char element)CharArrayListwithoutAll(CharIterable elements)static CharArrayListwrapCopy(char... array)Creates a new list by first copying the array passed in.voidwriteExternal(java.io.ObjectOutput out)<T> MutableList<CharObjectPair<T>>zip(java.lang.Iterable<T> iterable)Returns aMutableListformed from thisMutableCharListand aListIterableby combining corresponding elements in pairs.MutableList<CharCharPair>zipChar(CharIterable iterable)Returns aMutableListformed from thisMutableCharListand anotherCharListby combining corresponding elements in pairs.-
Methods inherited from class org.eclipse.collections.impl.primitive.AbstractCharIterable
asLazy, average, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.collections.api.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, toSortedListBy
-
Methods inherited from interface org.eclipse.collections.api.list.primitive.CharList
forEachInBoth
-
Methods inherited from interface org.eclipse.collections.api.list.primitive.MutableCharList
collectWithIndex, rejectWithIndex, selectWithIndex, shuffleThis, shuffleThis, sortThisBy, sortThisBy, tap
-
Methods inherited from interface org.eclipse.collections.api.ordered.primitive.OrderedCharIterable
collectWithIndex, rejectWithIndex, selectWithIndex
-
Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
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:
- Constant Field Values
-
size
protected int size
-
items
protected transient char[] items
-
-
Method Detail
-
newListWith
public static CharArrayList newListWith(char... elements)
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
public static CharArrayList newList(CharIterable source)
-
newWithNValues
public static CharArrayList newWithNValues(int size, char value)
-
wrapCopy
public static CharArrayList wrapCopy(char... array)
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
-
newIndexOutOfBoundsException
private java.lang.IndexOutOfBoundsException newIndexOutOfBoundsException(int index)
-
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
public boolean addAll(CharIterable source)
- 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
public boolean addAllAtIndex(int index, CharIterable source)- Specified by:
addAllAtIndexin interfaceMutableCharList
-
shiftElementsAtIndex
private void shiftElementsAtIndex(int index, int sourceSize)
-
remove
public boolean remove(char value)
- Specified by:
removein interfaceMutableCharCollection
-
removeIf
public boolean removeIf(CharPredicate predicate)
- Specified by:
removeIfin interfaceMutableCharCollection
-
wipeAndResetTheEnd
private void wipeAndResetTheEnd(int newCurrentFilledIndex)
-
removeAll
public boolean removeAll(CharIterable source)
- Specified by:
removeAllin interfaceMutableCharCollection
-
removeAll
public boolean removeAll(char... source)
- Specified by:
removeAllin interfaceMutableCharCollection
-
retainAll
public boolean retainAll(CharIterable source)
- Specified by:
retainAllin interfaceMutableCharCollection- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(char... source)
- Specified by:
retainAllin interfaceMutableCharCollection- See Also:
Collection.retainAll(Collection)
-
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
public CharArrayList with(char element)
- Specified by:
within interfaceMutableCharCollection- Specified by:
within interfaceMutableCharList
-
without
public CharArrayList without(char element)
- Specified by:
withoutin interfaceMutableCharCollection- Specified by:
withoutin interfaceMutableCharList
-
withAll
public CharArrayList withAll(CharIterable elements)
- Specified by:
withAllin interfaceMutableCharCollection- Specified by:
withAllin interfaceMutableCharList
-
withoutAll
public CharArrayList withoutAll(CharIterable elements)
- Specified by:
withoutAllin interfaceMutableCharCollection- Specified by:
withoutAllin interfaceMutableCharList
-
with
public CharArrayList with(char element1, char element2)
-
with
public CharArrayList with(char element1, char element2, char element3)
-
with
public CharArrayList with(char element1, char element2, char element3, char... elements)
-
withArrayCopy
private CharArrayList withArrayCopy(char[] elements, int begin, int length)
-
charIterator
public MutableCharIterator 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
public void each(CharProcedure procedure)
Description copied from interface:CharIterableA synonym for forEach.- Specified by:
eachin interfaceCharIterable- Since:
- 7.0.
-
forEachWithIndex
public void forEachWithIndex(CharIntProcedure procedure)
- 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
public RichIterable<CharIterable> chunk(int size)
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
public int count(CharPredicate predicate)
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
public boolean anySatisfy(CharPredicate predicate)
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
public boolean allSatisfy(CharPredicate predicate)
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
public CharArrayList select(CharPredicate predicate)
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
public <R extends MutableCharCollection> R select(CharPredicate predicate, R target)
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
public CharArrayList reject(CharPredicate predicate)
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
public <R extends MutableCharCollection> R reject(CharPredicate predicate, R target)
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
public char detectIfNone(CharPredicate predicate, char ifNone)
- Specified by:
detectIfNonein interfaceCharIterable
-
collect
public <V> MutableList<V> collect(CharToObjectFunction<? extends V> function)
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
public <V,R extends java.util.Collection<V>> R collect(CharToObjectFunction<? extends V> function, R target)
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
public long dotProduct(CharList list)
- 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
public boolean equals(java.lang.Object otherList)
Description copied from interface:CharListFollows the same general contract asList.equals(Object).
-
hashCode
public int hashCode()
Description copied from interface:CharListFollows the same general contract asList.hashCode().
-
appendString
public void appendString(java.lang.Appendable appendable, java.lang.String start, java.lang.String separator, java.lang.String end)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
public MutableCharList asUnmodifiable()
- Specified by:
asUnmodifiablein interfaceMutableCharCollection- Specified by:
asUnmodifiablein interfaceMutableCharList
-
asSynchronized
public MutableCharList asSynchronized()
- Specified by:
asSynchronizedin interfaceMutableCharCollection- Specified by:
asSynchronizedin interfaceMutableCharList
-
toImmutable
public ImmutableCharList 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
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException- Specified by:
readExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
asReversed
public LazyCharIterable asReversed()
- Specified by:
asReversedin interfaceReversibleCharIterable
-
reverseThis
public CharArrayList reverseThis()
- Specified by:
reverseThisin interfaceMutableCharList
-
sortThis
public CharArrayList sortThis()
Description copied from interface:MutableCharListSorts this list mutating its contents and returns the same mutable list (this).- Specified by:
sortThisin interfaceMutableCharList
-
sortThis
public CharArrayList sortThis(CharComparator comparator)
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
public CharArrayList toReversed()
- Specified by:
toReversedin interfaceCharList- Specified by:
toReversedin interfaceMutableCharList- Specified by:
toReversedin interfaceReversibleCharIterable
-
binarySearch
public int binarySearch(char value)
- Specified by:
binarySearchin interfaceCharList
-
distinct
public MutableCharList distinct()
- Specified by:
distinctin interfaceCharList- Specified by:
distinctin interfaceMutableCharList- Specified by:
distinctin interfaceReversibleCharIterable
-
subList
public MutableCharList subList(int fromIndex, int toIndex)
- Specified by:
subListin interfaceCharList- Specified by:
subListin interfaceMutableCharList- See Also:
List.subList(int fromIndex, int toIndex)
-
zipChar
public MutableList<CharCharPair> zipChar(CharIterable iterable)
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
public CharArrayList newEmpty()
Creates a new empty CharArrayList.- Specified by:
newEmptyin interfaceMutableCharCollection- Specified by:
newEmptyin interfaceMutableCharList- Since:
- 9.2.
-
zip
public <T> MutableList<CharObjectPair<T>> zip(java.lang.Iterable<T> iterable)
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
public MutableList<java.lang.Character> boxed()
- Specified by:
boxedin interfaceMutableCharList
-
toStack
public MutableCharStack toStack()
Description copied from interface:OrderedCharIterableConverts the collection to a CharStack.- Specified by:
toStackin interfaceOrderedCharIterable
-
-