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 class
CharArrayList.InternalCharIterator
-
Field Summary
Fields Modifier and Type Field Description private static char[]
DEFAULT_SIZED_EMPTY_ARRAY
protected char[]
items
private static int
MAXIMUM_ARRAY_SIZE
private static long
serialVersionUID
protected int
size
private 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 boolean
add(char newItem)
boolean
addAll(char... source)
boolean
addAll(CharIterable source)
boolean
addAllAtIndex(int index, char... source)
boolean
addAllAtIndex(int index, CharIterable source)
void
addAtIndex(int index, char element)
private void
addAtIndexLessThanSize(int index, char element)
boolean
allSatisfy(CharPredicate predicate)
Returns true if all of the elements in the CharIterable return true for the specified predicate, otherwise returns false.boolean
anySatisfy(CharPredicate predicate)
Returns true if any of the elements in the CharIterable return true for the specified predicate, otherwise returns false.void
appendString(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
.LazyCharIterable
asReversed()
MutableCharList
asSynchronized()
MutableCharList
asUnmodifiable()
int
binarySearch(char value)
MutableCharIterator
charIterator()
Returns a primitive iterator that can be used to iterate over the CharIterable in an imperative style.private void
checkEmpty()
RichIterable<CharIterable>
chunk(int size)
Partitions elements in fixed size chunks.void
clear()
<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.boolean
contains(char value)
Returns true if the value is contained in the CharIterable, and false if it is not.private void
copyItems(int sourceSize, char[] source)
private char[]
copyItemsWithNewCapacity(int newCapacity)
int
count(CharPredicate predicate)
Returns a count of the number of elements in the CharIterable that return true for the specified predicate.char
detectIfNone(CharPredicate predicate, char ifNone)
MutableCharList
distinct()
long
dotProduct(CharList list)
void
each(CharProcedure procedure)
A synonym for forEach.void
ensureCapacity(int minCapacity)
private void
ensureCapacityForAdd()
boolean
equals(java.lang.Object otherList)
Follows the same general contract asList.equals(Object)
.void
forEachWithIndex(CharIntProcedure procedure)
char
get(int index)
char
getFirst()
char
getLast()
int
hashCode()
Follows the same general contract asList.hashCode()
.int
indexOf(char value)
<T> T
injectInto(T injectedValue, ObjectCharToObjectFunction<? super T,? extends T> function)
<T> T
injectIntoWithIndex(T injectedValue, ObjectCharIntToObjectFunction<? super T,? extends T> function)
int
lastIndexOf(char value)
char
max()
char
min()
CharArrayList
newEmpty()
Creates a new empty CharArrayList.private java.lang.IndexOutOfBoundsException
newIndexOutOfBoundsException(int index)
static CharArrayList
newList(CharIterable source)
static CharArrayList
newListWith(char... elements)
Creates a new list using the passedelements
argument as the backing store.static CharArrayList
newWithNValues(int size, char value)
void
readExternal(java.io.ObjectInput in)
CharArrayList
reject(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.boolean
remove(char value)
boolean
removeAll(char... source)
boolean
removeAll(CharIterable source)
char
removeAtIndex(int index)
boolean
removeIf(CharPredicate predicate)
boolean
retainAll(char... source)
boolean
retainAll(CharIterable source)
CharArrayList
reverseThis()
CharArrayList
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.char
set(int index, char element)
private void
shiftElementsAtIndex(int index, int sourceSize)
int
size()
Returns the number of items in this iterable.private int
sizePlusFiftyPercent(int oldSize)
CharArrayList
sortThis()
Sorts this list mutating its contents and returns the same mutable list (this).CharArrayList
sortThis(CharComparator comparator)
Sorts the internal data structure of this list and returns the list itself as a convenience.MutableCharList
subList(int fromIndex, int toIndex)
long
sum()
void
swap(int index1, int index2)
private void
throwOutOfBounds(int index)
char[]
toArray()
Converts the CharIterable to a primitive char array.char[]
toArray(char[] target)
Converts the CharIterable to a primitive char array.ImmutableCharList
toImmutable()
Returns an immutable copy of this list.CharArrayList
toReversed()
private void
transferItemsToNewArrayWithCapacity(int newCapacity)
void
trimToSize()
private void
wipeAndResetTheEnd(int newCurrentFilledIndex)
CharArrayList
with(char element)
CharArrayList
with(char element1, char element2)
CharArrayList
with(char element1, char element2, char element3)
CharArrayList
with(char element1, char element2, char element3, char... elements)
CharArrayList
withAll(CharIterable elements)
private CharArrayList
withArrayCopy(char[] elements, int begin, int length)
CharArrayList
without(char element)
CharArrayList
withoutAll(CharIterable elements)
static CharArrayList
wrapCopy(char... array)
Creates a new list by first copying the array passed in.void
writeExternal(java.io.ObjectOutput out)
<T> MutableList<CharObjectPair<T>>
zip(java.lang.Iterable<T> iterable)
Returns aMutableList
formed from thisMutableCharList
and aListIterable
by combining corresponding elements in pairs.MutableList<CharCharPair>
zipChar(CharIterable iterable)
Returns aMutableList
formed from thisMutableCharList
and anotherCharList
by 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 passedelements
argument 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:PrimitiveIterable
Returns the number of items in this iterable.- Specified by:
size
in interfacePrimitiveIterable
-
clear
public void clear()
- Specified by:
clear
in interfaceMutableCharCollection
-
contains
public boolean contains(char value)
Description copied from interface:CharIterable
Returns true if the value is contained in the CharIterable, and false if it is not.- Specified by:
contains
in interfaceCharIterable
-
newIndexOutOfBoundsException
private java.lang.IndexOutOfBoundsException newIndexOutOfBoundsException(int index)
-
getFirst
public char getFirst()
- Specified by:
getFirst
in interfaceOrderedCharIterable
-
getLast
public char getLast()
- Specified by:
getLast
in interfaceReversibleCharIterable
-
checkEmpty
private void checkEmpty()
-
indexOf
public int indexOf(char value)
- Specified by:
indexOf
in interfaceOrderedCharIterable
-
lastIndexOf
public int lastIndexOf(char value)
- Specified by:
lastIndexOf
in 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:
add
in interfaceMutableCharCollection
-
addAll
public boolean addAll(char... source)
- Specified by:
addAll
in interfaceMutableCharCollection
-
addAll
public boolean addAll(CharIterable source)
- Specified by:
addAll
in 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:
addAtIndex
in interfaceMutableCharList
-
addAtIndexLessThanSize
private void addAtIndexLessThanSize(int index, char element)
-
addAllAtIndex
public boolean addAllAtIndex(int index, char... source)
- Specified by:
addAllAtIndex
in interfaceMutableCharList
-
addAllAtIndex
public boolean addAllAtIndex(int index, CharIterable source)
- Specified by:
addAllAtIndex
in interfaceMutableCharList
-
shiftElementsAtIndex
private void shiftElementsAtIndex(int index, int sourceSize)
-
remove
public boolean remove(char value)
- Specified by:
remove
in interfaceMutableCharCollection
-
removeIf
public boolean removeIf(CharPredicate predicate)
- Specified by:
removeIf
in interfaceMutableCharCollection
-
wipeAndResetTheEnd
private void wipeAndResetTheEnd(int newCurrentFilledIndex)
-
removeAll
public boolean removeAll(CharIterable source)
- Specified by:
removeAll
in interfaceMutableCharCollection
-
removeAll
public boolean removeAll(char... source)
- Specified by:
removeAll
in interfaceMutableCharCollection
-
retainAll
public boolean retainAll(CharIterable source)
- Specified by:
retainAll
in interfaceMutableCharCollection
- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(char... source)
- Specified by:
retainAll
in interfaceMutableCharCollection
- See Also:
Collection.retainAll(Collection)
-
removeAtIndex
public char removeAtIndex(int index)
- Specified by:
removeAtIndex
in interfaceMutableCharList
-
set
public char set(int index, char element)
- Specified by:
set
in interfaceMutableCharList
-
swap
public void swap(int index1, int index2)
- Specified by:
swap
in interfaceMutableCharList
-
with
public CharArrayList with(char element)
- Specified by:
with
in interfaceMutableCharCollection
- Specified by:
with
in interfaceMutableCharList
-
without
public CharArrayList without(char element)
- Specified by:
without
in interfaceMutableCharCollection
- Specified by:
without
in interfaceMutableCharList
-
withAll
public CharArrayList withAll(CharIterable elements)
- Specified by:
withAll
in interfaceMutableCharCollection
- Specified by:
withAll
in interfaceMutableCharList
-
withoutAll
public CharArrayList withoutAll(CharIterable elements)
- Specified by:
withoutAll
in interfaceMutableCharCollection
- Specified by:
withoutAll
in 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:CharIterable
Returns a primitive iterator that can be used to iterate over the CharIterable in an imperative style.- Specified by:
charIterator
in interfaceCharIterable
- Specified by:
charIterator
in interfaceMutableCharCollection
-
each
public void each(CharProcedure procedure)
Description copied from interface:CharIterable
A synonym for forEach.- Specified by:
each
in interfaceCharIterable
- Since:
- 7.0.
-
forEachWithIndex
public void forEachWithIndex(CharIntProcedure procedure)
- Specified by:
forEachWithIndex
in interfaceOrderedCharIterable
-
injectInto
public <T> T injectInto(T injectedValue, ObjectCharToObjectFunction<? super T,? extends T> function)
- Specified by:
injectInto
in interfaceCharIterable
-
injectIntoWithIndex
public <T> T injectIntoWithIndex(T injectedValue, ObjectCharIntToObjectFunction<? super T,? extends T> function)
- Specified by:
injectIntoWithIndex
in interfaceOrderedCharIterable
- Specified by:
injectIntoWithIndex
in interfaceReversibleCharIterable
-
chunk
public RichIterable<CharIterable> chunk(int size)
Description copied from interface:CharIterable
Partitions elements in fixed size chunks.- Specified by:
chunk
in interfaceCharIterable
- Parameters:
size
- the number of elements per chunk- Returns:
- A
RichIterable
containingCharIterable
s 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:CharIterable
Returns a count of the number of elements in the CharIterable that return true for the specified predicate.- Specified by:
count
in interfaceCharIterable
-
anySatisfy
public boolean anySatisfy(CharPredicate predicate)
Description copied from interface:CharIterable
Returns true if any of the elements in the CharIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfy
in interfaceCharIterable
-
allSatisfy
public boolean allSatisfy(CharPredicate predicate)
Description copied from interface:CharIterable
Returns true if all of the elements in the CharIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfy
in interfaceCharIterable
-
select
public CharArrayList select(CharPredicate predicate)
Description copied from interface:CharIterable
Returns a new CharIterable with all of the elements in the CharIterable that return true for the specified predicate.- Specified by:
select
in interfaceCharIterable
- Specified by:
select
in interfaceCharList
- Specified by:
select
in interfaceMutableCharCollection
- Specified by:
select
in interfaceMutableCharList
- Specified by:
select
in interfaceOrderedCharIterable
- Specified by:
select
in interfaceReversibleCharIterable
-
select
public <R extends MutableCharCollection> R select(CharPredicate predicate, R target)
Description copied from interface:CharIterable
Same asCharIterable.select(CharPredicate)
, only the results are added to the target MutableCharCollection.- Specified by:
select
in interfaceCharIterable
- Since:
- 8.1.
-
reject
public CharArrayList reject(CharPredicate predicate)
Description copied from interface:CharIterable
Returns a new CharIterable with all of the elements in the CharIterable that return false for the specified predicate.- Specified by:
reject
in interfaceCharIterable
- Specified by:
reject
in interfaceCharList
- Specified by:
reject
in interfaceMutableCharCollection
- Specified by:
reject
in interfaceMutableCharList
- Specified by:
reject
in interfaceOrderedCharIterable
- Specified by:
reject
in interfaceReversibleCharIterable
-
reject
public <R extends MutableCharCollection> R reject(CharPredicate predicate, R target)
Description copied from interface:CharIterable
Same asCharIterable.reject(CharPredicate)
, only the results are added to the target MutableCharCollection.- Specified by:
reject
in interfaceCharIterable
- Since:
- 8.1.
-
detectIfNone
public char detectIfNone(CharPredicate predicate, char ifNone)
- Specified by:
detectIfNone
in interfaceCharIterable
-
collect
public <V> MutableList<V> collect(CharToObjectFunction<? extends V> function)
Description copied from interface:CharIterable
Returns 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:
collect
in interfaceCharIterable
- Specified by:
collect
in interfaceCharList
- Specified by:
collect
in interfaceMutableCharCollection
- Specified by:
collect
in interfaceMutableCharList
- Specified by:
collect
in interfaceOrderedCharIterable
- Specified by:
collect
in interfaceReversibleCharIterable
-
collect
public <V,R extends java.util.Collection<V>> R collect(CharToObjectFunction<? extends V> function, R target)
Description copied from interface:CharIterable
Same asCharIterable.collect(CharToObjectFunction)
, only the results are added to the target Collection.- Specified by:
collect
in interfaceCharIterable
- Since:
- 8.1.
-
max
public char max()
- Specified by:
max
in interfaceCharIterable
-
min
public char min()
- Specified by:
min
in interfaceCharIterable
-
sum
public long sum()
- Specified by:
sum
in interfaceCharIterable
-
dotProduct
public long dotProduct(CharList list)
- Specified by:
dotProduct
in interfaceCharList
-
toArray
public char[] toArray()
Description copied from interface:CharIterable
Converts the CharIterable to a primitive char array.- Specified by:
toArray
in interfaceCharIterable
-
toArray
public char[] toArray(char[] target)
Description copied from interface:CharIterable
Converts 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:
toArray
in interfaceCharIterable
-
equals
public boolean equals(java.lang.Object otherList)
Description copied from interface:CharList
Follows the same general contract asList.equals(Object)
.
-
hashCode
public int hashCode()
Description copied from interface:CharList
Follows 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:PrimitiveIterable
Prints a string representation of this collection onto the givenAppendable
. Prints the string returned byPrimitiveIterable.makeString(String, String, String)
.- Specified by:
appendString
in interfacePrimitiveIterable
-
asUnmodifiable
public MutableCharList asUnmodifiable()
- Specified by:
asUnmodifiable
in interfaceMutableCharCollection
- Specified by:
asUnmodifiable
in interfaceMutableCharList
-
asSynchronized
public MutableCharList asSynchronized()
- Specified by:
asSynchronized
in interfaceMutableCharCollection
- Specified by:
asSynchronized
in interfaceMutableCharList
-
toImmutable
public ImmutableCharList toImmutable()
Description copied from interface:MutableCharList
Returns an immutable copy of this list.- Specified by:
toImmutable
in interfaceCharList
- Specified by:
toImmutable
in interfaceMutableCharCollection
- Specified by:
toImmutable
in interfaceMutableCharList
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Specified by:
writeExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException
- Specified by:
readExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
asReversed
public LazyCharIterable asReversed()
- Specified by:
asReversed
in interfaceReversibleCharIterable
-
reverseThis
public CharArrayList reverseThis()
- Specified by:
reverseThis
in interfaceMutableCharList
-
sortThis
public CharArrayList sortThis()
Description copied from interface:MutableCharList
Sorts this list mutating its contents and returns the same mutable list (this).- Specified by:
sortThis
in interfaceMutableCharList
-
sortThis
public CharArrayList sortThis(CharComparator comparator)
Description copied from interface:MutableCharList
Sorts the internal data structure of this list and returns the list itself as a convenience.- Specified by:
sortThis
in interfaceMutableCharList
-
toReversed
public CharArrayList toReversed()
- Specified by:
toReversed
in interfaceCharList
- Specified by:
toReversed
in interfaceMutableCharList
- Specified by:
toReversed
in interfaceReversibleCharIterable
-
binarySearch
public int binarySearch(char value)
- Specified by:
binarySearch
in interfaceCharList
-
distinct
public MutableCharList distinct()
- Specified by:
distinct
in interfaceCharList
- Specified by:
distinct
in interfaceMutableCharList
- Specified by:
distinct
in interfaceReversibleCharIterable
-
subList
public MutableCharList subList(int fromIndex, int toIndex)
- Specified by:
subList
in interfaceCharList
- Specified by:
subList
in interfaceMutableCharList
- See Also:
List.subList(int fromIndex, int toIndex)
-
zipChar
public MutableList<CharCharPair> zipChar(CharIterable iterable)
Description copied from interface:MutableCharList
Returns aMutableList
formed from thisMutableCharList
and anotherCharList
by combining corresponding elements in pairs. If one of the twoCharList
s is longer than the other, its remaining elements are ignored.- Specified by:
zipChar
in interfaceCharList
- Specified by:
zipChar
in interfaceMutableCharList
- Since:
- 9.1.
-
newEmpty
public CharArrayList newEmpty()
Creates a new empty CharArrayList.- Specified by:
newEmpty
in interfaceMutableCharCollection
- Specified by:
newEmpty
in interfaceMutableCharList
- Since:
- 9.2.
-
zip
public <T> MutableList<CharObjectPair<T>> zip(java.lang.Iterable<T> iterable)
Description copied from interface:MutableCharList
Returns aMutableList
formed from thisMutableCharList
and aListIterable
by combining corresponding elements in pairs. If one of the two Lists is longer than the other, its remaining elements are ignored.- Specified by:
zip
in interfaceCharList
- Specified by:
zip
in interfaceMutableCharList
- Since:
- 9.1.
-
-