public interface MutableCharIndexable extends CharIndexable, Copyable<MutableCharIndexable>
char[]
as it eg allows
read-only views or transparent views of subsets of the array.Modifier and Type | Interface and Description |
---|---|
static class |
MutableCharIndexable.Base
Abstract base class which provides useful implementations
for
Object.equals(Object) , Object.hashCode() ,
Object.toString() . |
Modifier and Type | Field and Description |
---|---|
static MutableCharIndexable.Base |
EMPTY
Empty mutable indexable.
|
EMPTY_CHAR_ITERATOR
Modifier and Type | Method and Description |
---|---|
default java.util.List<java.lang.Character> |
asList()
View this indexable as a standard list.
|
static MutableCharIndexable.Base |
based(MutableCharIndexable indexable)
View any mutable char indexable as a base char indexable.
|
static <IN> MutableCharIndexable.Base |
copy(java.util.Collection<IN> collection,
java.util.function.Function<IN,java.lang.Character> copier)
Create a mutable indexable which is initialized from copied elements of
a given collection.
|
default void |
copyInternally(int fromIndex,
int toIndex,
int numElements)
Copy elements inside this indexable.
|
static MutableCharIndexable.Base |
copyOf(java.util.Collection<? extends java.lang.Character> collection)
Create a mutable indexable which is initialized from a
given collection.
|
static MutableCharIndexable.Base |
empty() |
default void |
fillFrom(IntToCharFunction1 provider)
Fill this indexable from a provider.
|
static MutableCharIndexable.Base |
fromArray(char... elements)
Create a mutable indexable which is initialized from elements
of the given array.
|
static MutableCharIndexable.Base |
fromArray(char[] elements,
int startIndex,
int length)
Create a mutable indexable which is initialized from elements
of the given array.
|
static MutableCharIndexable.Base |
fromCharIndexable(CharIndexable indexable)
Return a mutable char indexable initialized with the content of a
standard char indexable.
|
static MutableCharIndexable.Base |
fromIndexable(Indexable<? extends java.lang.Character> indexable)
Create a mutable indexable which is the copy of a standard indexable.
|
static <B> MutableCharIndexable.Base |
fromIndexable(Indexable<B> indexable,
java.util.function.Function<? super B,? extends java.lang.Character> converter)
Create a mutable indexable which is the copy of a standard indexable.
|
static MutableCharIndexable.Base |
fromIterable(int size,
java.lang.Iterable<? extends java.lang.Character> iter)
Create a mutable indexable from an iterable or a part of it.
|
default MutableCharIndexable |
getCopy()
Get a copy of this object.
|
default MutableCharIndexable.Base |
headSet(int toIndex)
Create an indexable subset from the last elements of this indexable set.
|
static MutableCharIndexable.Base |
init(int size,
char value)
Create a mutable
|
static MutableCharIndexable.Base |
init(int size,
java.util.function.Supplier<java.lang.Character> creator)
Initialize a mutable indexable to a given size.
|
static MutableCharIndexable.Base |
initByIndex(int size,
IntToCharFunction1 producer)
Get a mutable char indexable of a given size which contains elements created by index.
|
default void |
initByIndex(IntToCharFunction1 setter)
Deprecated.
use
fillFrom(IntToCharFunction1) instead |
default void |
order()
Sort the elements in this indexable in their natural order.
|
default void |
order(CharOrdering ordering)
Sort the elements in this indexable according to the given order.
|
default MutableCharIndexable.Base |
reverse()
Get this indexable but with inverted order.
|
default void |
revert()
Revert the elements in this indexable.
|
default void |
revert(int from,
int to)
Revert the order of all elements in the given range.
|
void |
set(int index,
char value)
Set the element at the given index.
|
default int |
setFrom(java.lang.Iterable<? extends java.lang.Character> iterable)
Set the values of this mutable char indexable one after
the other from the given Number iterable until either the
iterable is emptied or
Sizeable.size() elements are set. |
default int |
setFrom(java.lang.Iterable<? extends java.lang.Character> iterable,
int startIndex,
int numElements)
Set the values of this mutable char indexable one after
the other from the given iterable until either the
iterable is emptied or
numElements elements are set. |
default void |
setFromArray(char[] array,
int arrayIndex,
int startIndex,
int numElements)
Set consecutive entries from an array.
|
default void |
setMulti(int from,
int len,
char value)
Set multiple elements to the same value.
|
default void |
setRange(int startIndex,
int length,
char value)
Set a range to the same value.
|
default void |
shuffle(java.util.Random random)
Randomize the content of this mutable indexable.
|
default MutableCharIndexable.Base |
subSet(int fromIndex,
int toIndex)
Get an indexable subset.
|
default void |
swap(int idx1,
int idx2)
Swap the values at two indices.
|
default void |
swyp(int idx1,
int idx2)
Swap the values at two indices using Pythonesque indices.
|
default MutableCharIndexable.Base |
sybSet(int fromIndex,
int toIndex)
Get an indexable subset.
|
default void |
syt(int index,
char value)
Pythonesque set.
|
default MutableCharIndexable.Base |
tailSet(int fromIndex)
Create an indexable subset from the last elements of this indexable set.
|
default MutableIntIndexable.Base |
toMutableIntIndexable()
Convert this mutable short array into an integer array.
|
static MutableCharIndexable.Base |
viewArray(char[] array)
Mutable indexable view which operates on the given array.
|
static MutableCharIndexable.Base |
viewArray(char[] array,
int start,
int length)
Mutable indexable view which operates on a part of the given array.
|
static <T> MutableCharIndexable.Base |
viewIndexable(Indexable<T> indexable,
ToCharFunction<? super T> getter,
CharSetter<? super T> setter)
View a generic indexable as a mutable char indexable by accessing
a char property of the elements of the underlying generic indexable.
|
static MutableCharIndexable.Base |
viewList(java.util.List<java.lang.Character> list)
Mutable indexable view which operates on the given array.
|
static MutableCharIndexable.Base |
zeroed(int size)
Create a mutable char indexable with
size
(char)0) elements. |
addAllTo, addToArray, addToArray, addToArray, addToArray, asBase, asCharSequence, asCollection, asIndexable, asIntIndexable, binarySearch, binarySearch, charIterator, charIterator, compare, emptyIndexable, equal, equal, firstMatch, foldLeft, frozen, get, getMod, gyt, hash, indexes, intIndexes, intIterator, isEmpty, isOrdered, isOrdered, isStrictlyOrdered, isStrictlyOrdered, iterator, lastMatch, listIterator, makeString, nextMatch, ordered, previousMatch, rotated, singleton, toArray, toIntArray, toList, toString, toText, view, viewArray, viewAsBoolean, viewAsCharSequence, viewByIndex, viewChars, viewIndexable, viewIndexable, viewIndexable, viewList, viewList, viewList, viewOp, viewString, withAppendedValue, withExchangedValueAt, withInsertedValueAt, withRemovedValueAt, withSwappedValuesAt
asIntIterable, asLongIterable, containsChar, forEachChar, forEachCharFragile
static final MutableCharIndexable.Base EMPTY
empty()
instead.void set(int index, char value)
index
- index between 0
and size() - 1
value
- value to put to the given indexdefault void syt(int index, char value)
-1
references the last element, -2
its predecessor, and so on.index
- index between -size()
and size() - 1
value
- value to put to the given indexdefault void setRange(int startIndex, int length, char value)
startIndex
- start index (Pythonesque)length
- length (non-negative)value
- value to set for the given rangedefault int setFrom(@NotNull java.lang.Iterable<? extends java.lang.Character> iterable)
Sizeable.size()
elements are set.iterable
- iterable from which this indexable is filleddefault int setFrom(@NotNull java.lang.Iterable<? extends java.lang.Character> iterable, int startIndex, int numElements)
numElements
elements are set.iterable
- iterable from which this indexable is filledstartIndex
- start index where the setting beginsnumElements
- number of elements to setdefault void setFromArray(@NotNull char[] array, int arrayIndex, int startIndex, int numElements)
array
- array with elements to set fromarrayIndex
- start index in the arraystartIndex
- start index in this mutable indexablenumElements
- number of elements to copyjava.lang.IndexOutOfBoundsException
- if this mutable indexable would overflow by this operationjava.lang.ArrayIndexOutOfBoundsException
- if array overflows by this operationdefault void setMulti(int from, int len, char value)
from
- first index to be set (Pythonesque)len
- number of elements to be set (non-negative)value
- value to be setdefault void copyInternally(int fromIndex, int toIndex, int numElements)
fromIndex
- start index from where elements are copied (Pythonesque)toIndex
- start index to where elements are copied (Pythonesque)numElements
- number of elements to copydefault void fillFrom(@NotNull IntToCharFunction1 provider)
provider
- provider which is called for each index and provides the element for that indexdefault void swap(int idx1, int idx2)
idx1
- first indexidx2
- second indexdefault void swyp(int idx1, int idx2)
idx1
- first index (Pythonesque
)idx2
- second index (Pythonesque
)@NotNull default MutableCharIndexable.Base subSet(int fromIndex, int toIndex)
CharIndexable
fromIndex
to toIndex - 1
.subSet
in interface CharIndexable
fromIndex
- start index of sub settoIndex
- index after last index@NotNull default MutableCharIndexable.Base sybSet(int fromIndex, int toIndex)
CharIndexable
sybSet
in interface CharIndexable
fromIndex
- start index of sub settoIndex
- end index of sub set@NotNull default MutableCharIndexable.Base tailSet(int fromIndex)
CharIndexable
tailSet
in interface CharIndexable
fromIndex
- index to start with, negative counts from the back@NotNull default MutableCharIndexable.Base headSet(int toIndex)
CharIndexable
headSet
in interface CharIndexable
toIndex
- index one after the end (equal to the length of the returned set),
negative counts from the back@NotNull default MutableCharIndexable.Base reverse()
CharIndexable
reverse
in interface CharIndexable
default void revert(int from, int to)
to
element is also included in the reversion to allow easy
reversion at the end by using -1
.from
- start element of reversion (Pythonesque), includedto
- end element of reversion (Pythonesque), includeddefault void revert()
default void order()
default void order(@NotNull CharOrdering ordering)
ordering
- sort orderdefault void shuffle(@NotNull java.util.Random random)
random
- random number generator@Deprecated default void initByIndex(@NotNull IntToCharFunction1 setter)
fillFrom(IntToCharFunction1)
insteadsetter
- setter which provides the value to be set for a given index@NotNull default java.util.List<java.lang.Character> asList()
List.set(int, Object)
method,
but neither any adding nor deleting methods. Standard sorting algorithms will work
on the returned list as a sorting algorithm is expected to neither move nor add
elements.asList
in interface CharIndexable
CharIndexable.toList()
@NotNull default MutableCharIndexable getCopy()
Copyable
getCopy
in interface Copyable<MutableCharIndexable>
@NotNull static MutableCharIndexable.Base based(@NotNull MutableCharIndexable indexable)
indexable
- mutqable char indexable to view as a MutableCharIndexable.Base
mutable char indexable@NotNull static MutableCharIndexable.Base init(int size, @NotNull java.util.function.Supplier<java.lang.Character> creator)
size
- size of indexablecreator
- creator for the initial eleeentsinit(int, char)
,
zeroed(int)
@NotNull static MutableCharIndexable.Base initByIndex(int size, @NotNull IntToCharFunction1 producer)
initByIndex
in interface CharIndexable
size
- size of the returned indexableproducer
- producer which is called with an index and expected to return the associated valueproducer
CharIndexable.viewByIndex(int, IntToCharFunction1)
@NotNull static MutableCharIndexable.Base copyOf(@NotNull java.util.Collection<? extends java.lang.Character> collection)
collection
- collection@NotNull static <IN> MutableCharIndexable.Base copy(@NotNull java.util.Collection<IN> collection, @NotNull java.util.function.Function<IN,java.lang.Character> copier)
IN
- incoming element typecollection
- collectioncopier
- element copier@NotNull static MutableCharIndexable.Base empty()
@NotNull static MutableCharIndexable.Base fromArray(@NotNull char... elements)
elements
- elementselements
@NotNull static MutableCharIndexable.Base fromArray(@NotNull char[] elements, int startIndex, int length)
elements
- array of elementsstartIndex
- index of first element used in the returned indxablelength
- length number of elements used in the returned indexableeleements
@NotNull static MutableCharIndexable.Base viewArray(@NotNull char[] array)
viewArray
in interface CharIndexable
array
- array@NotNull static MutableCharIndexable.Base viewArray(@NotNull char[] array, int start, int length)
viewArray
in interface CharIndexable
array
- arraystart
- start position in arraylength
- length of returned indexable@NotNull default MutableIntIndexable.Base toMutableIntIndexable()
It is recommended to do this when this indexable is heavily used.
@NotNull static MutableCharIndexable.Base viewList(@NotNull java.util.List<java.lang.Character> list)
list
- list@NotNull static MutableCharIndexable.Base fromIndexable(@NotNull Indexable<? extends java.lang.Character> indexable)
indexable
- standard indexable@NotNull static <B> MutableCharIndexable.Base fromIndexable(@NotNull Indexable<B> indexable, @NotNull java.util.function.Function<? super B,? extends java.lang.Character> converter)
B
- element type of incoming idexableindexable
- base indexableconverter
- converter from base indexable type to result element type,@NotNull static MutableCharIndexable.Base fromCharIndexable(@NotNull CharIndexable indexable)
indexable
- char indexable@NotNull static <T> MutableCharIndexable.Base viewIndexable(@NotNull Indexable<T> indexable, @NotNull ToCharFunction<? super T> getter, @NotNull CharSetter<? super T> setter)
This is useful if you have complex items, but are interested into only one (char) property of each item.
T
- element type of the underlying indexableindexable
- underlying generic indexablegetter
- function used to extract the property of interestsetter
- procedure used to set the property of interest@NotNull static MutableCharIndexable.Base fromIterable(int size, @NotNull java.lang.Iterable<? extends java.lang.Character> iter)
size
- maximum size of returned indexableiter
- iterable used for initializing the indexable@NotNull static MutableCharIndexable.Base zeroed(int size)
size
(char)0)
elements.size
- required size of returned mutable char indexable(char)0)
init(int, char)
,
init(int, Supplier)
@NotNull static MutableCharIndexable.Base init(int size, char value)
init
in interface CharIndexable
size
- required size of returned mutable char indexablevalue
- initial value of all elementsvalue
init(int, Supplier)
,
zeroed(int)