public interface MutableByteIndexable extends ByteIndexable, Copyable<MutableByteIndexable>
byte[]
as it e.g. allows
read-only views or transparent views of subsets of the array.Modifier and Type | Interface and Description |
---|---|
static class |
MutableByteIndexable.Base
Abstract base class which provides useful implementations
for
Object.equals(Object) , Object.hashCode() ,
Object.toString() . |
Modifier and Type | Field and Description |
---|---|
static MutableByteIndexable.Base |
EMPTY
Empty mutable indexable.
|
LOWERCASE_2DIGIT_HEXCODES, SINGLE_0, UPPERCASE_2DIGIT_HEXCODES
EMPTY_BYTE_ITERATOR
Modifier and Type | Method and Description |
---|---|
default java.util.List<java.lang.Byte> |
asList()
View this indexable as a standard list.
|
static MutableByteIndexable.Base |
based(MutableByteIndexable indexable)
View any mutable byte indexable as a base byte indexable.
|
static <IN> MutableByteIndexable.Base |
copy(java.util.Collection<IN> collection,
java.util.function.Function<IN,java.lang.Number> 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 MutableByteIndexable.Base |
copyOf(java.util.Collection<? extends java.lang.Number> collection)
Create a mutable byte indexable which is initialized from a
given collection.
|
static MutableByteIndexable.Base |
empty() |
default void |
fillFrom(IntToByteFunction1 provider)
Fill this indexable from a provider.
|
static MutableByteIndexable.Base |
fromArray(byte... elements)
Create a mutable indexable which is initialized from elements
of the given array.
|
static MutableByteIndexable.Base |
fromArray(byte[] elements,
int startIndex,
int length)
Create a mutable indexable which is initialized from elements
of the given array.
|
static MutableByteIndexable.Base |
fromByteIndexable(ByteIndexable indexable)
Return a mutable short indexable initialized with the content of a
standard byte indexable.
|
static MutableByteIndexable.Base |
fromDoubleIndexable(DoubleIndexable indexable)
Return a mutable byte indexable initialized with the content of a
standard double indexable.
|
static MutableByteIndexable.Base |
fromFloatIndexable(FloatIndexable indexable)
Return a mutable byte indexable initialized with the content of a
standard float indexable.
|
static MutableByteIndexable.Base |
fromIndexable(Indexable<? extends java.lang.Number> indexable)
Create a mutable indexable which is the copy of a standard indexable.
|
static <B> MutableByteIndexable.Base |
fromIndexable(Indexable<B> indexable,
java.util.function.Function<? super B,? extends java.lang.Number> converter)
Create a mutable indexable which is the copy of a standard indexable.
|
static MutableByteIndexable.Base |
fromIntIndexable(IntIndexable indexable)
Return a mutable byte indexable initialized with the content of a
standard int indexable.
|
static MutableByteIndexable.Base |
fromIterable(int size,
java.lang.Iterable<? extends java.lang.Number> iter)
Create a mutable indexable from an iterable or a part of it.
|
static MutableByteIndexable.Base |
fromLongIndexable(LongIndexable indexable)
Return a mutable byte indexable initialized with the content of a
standard long indexable.
|
static MutableByteIndexable.Base |
fromShortIndexable(ShortIndexable indexable)
Return a mutable short indexable initialized with the content of a
standard short indexable.
|
default MutableByteIndexable |
getCopy()
Get a copy of this object.
|
default MutableByteIndexable.Base |
headSet(int toIndex)
Create an indexable subset from the last elements of this indexable set.
|
static MutableByteIndexable.Base |
init(int size,
byte value)
Create a mutable
|
static MutableByteIndexable.Base |
init(int size,
java.util.function.Supplier<java.lang.Number> creator)
Initialize a mutable indexable to a given size.
|
static MutableByteIndexable.Base |
initByIndex(int size,
IntToByteFunction1 producer)
Get a mutable byte indexable of a given size which contains elements created by index.
|
default void |
initByIndex(IntToByteFunction1 setter)
Deprecated.
use
fillFrom(IntToByteFunction1) instead |
default void |
order()
Sort the elements in this indexable in their natural order.
|
default void |
order(ByteOrdering ordering)
Sort the elements in this indexable according to the given ordering.
|
default MutableByteIndexable.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,
byte value)
Set the element at the given index.
|
default int |
setFrom(java.lang.Iterable<? extends java.lang.Number> iterable)
Set the values of this mutable byte 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.Number> iterable,
int startIndex,
int numElements)
Set the values of this mutable byte indexable one after
the other from the given iterable until either the
iterable is emptied or
numElements elements are set. |
default void |
setFromArray(byte[] array,
int arrayIndex,
int startIndex,
int numElements)
Set consecutive entries from an array.
|
default void |
setMulti(int from,
int len,
byte value)
Set multiple elements to the same value.
|
default void |
setRange(int startIndex,
int length,
byte value)
Set a range to the same value.
|
default void |
shuffle(java.util.Random random)
Randomize the content of this mutable indexable.
|
default MutableByteIndexable.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 MutableByteIndexable.Base |
sybSet(int fromIndex,
int toIndex)
Get an indexable subset.
|
default void |
syt(int index,
byte value)
Pythonesque set.
|
default MutableByteIndexable.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 MutableByteIndexable.Base |
viewArray(byte[] array)
Mutable indexable view which operates on the given array.
|
static MutableByteIndexable.Base |
viewArray(byte[] array,
int start,
int length)
Mutable indexable view which operates on a part of the given array.
|
static <T> MutableByteIndexable.Base |
viewIndexable(Indexable<T> indexable,
ToByteFunction<? super T> getter,
ByteSetter<? super T> setter)
View a generic indexable as a mutable byte indexable by accessing
a byte property of the elements of the underlying generic indexable.
|
static MutableByteIndexable.Base |
viewList(java.util.List<java.lang.Byte> list)
Mutable indexable view which operates on the given array.
|
static MutableByteIndexable.Base |
zeroed(int size)
Create a mutable byte indexable with
size
0.0 elements. |
addAllTo, addToArray, addToArray, addToArray, addToArray, asBase, asCollection, asIndexable, asIntIndexable, asUnsignedIndexable, binarySearch, binarySearch, byteIterator, byteIterator, bytesFromHexString, compare, compareUnsigned, copyTo, copyTo, emptyIndexable, equal, equal, firstMatch, foldLeft, fromHexString, frozen, get, getMod, gyt, hash, indexes, intIndexes, intIterator, isEmpty, isOrdered, isOrdered, isStrictlyOrdered, isStrictlyOrdered, iterator, lastMatch, listIterator, nextMatch, ordered, previousMatch, rotated, singleton, toArray, toByteArray, toHexString, toHexString, toIntArray, toList, toString, view, viewArray, viewAsBoolean, viewAsDouble, viewAsFloat, viewAsInt, viewAsLong, viewAsShort, viewAsUnsignedInt, viewAsUnsignedLong, viewAsUnsignedShort, viewByIndex, viewIndexable, viewIndexable, viewIndexable, viewList, viewList, viewList, viewNumberArray, viewOp, withAppendedValue, withCachedHash, withExchangedValueAt, withInsertedValueAt, withRemovedValueAt, withSwappedValuesAt
asIntIterable, asLongIterable, asShortIterable, asUnsignedIntIterable, asUnsignedLongIterable, containsByte, forEachByte, forEachByteFragile
static final MutableByteIndexable.Base EMPTY
empty()
instead.void set(int index, byte value)
index
- index between 0
and size() - 1
value
- value to put to the given indexdefault void syt(int index, byte 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, byte 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.Number> iterable)
Sizeable.size()
elements are set.iterable
- iterable from which this indexable is filleddefault int setFrom(@NotNull java.lang.Iterable<? extends java.lang.Number> 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 byte[] 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, byte 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 IntToByteFunction1 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 MutableByteIndexable.Base subSet(int fromIndex, int toIndex)
ByteIndexable
fromIndex
to toIndex - 1
.subSet
in interface ByteIndexable
fromIndex
- start index of sub settoIndex
- index after last index@NotNull default MutableByteIndexable.Base sybSet(int fromIndex, int toIndex)
ByteIndexable
sybSet
in interface ByteIndexable
fromIndex
- start index of sub settoIndex
- end index of sub set@NotNull default MutableByteIndexable.Base tailSet(int fromIndex)
ByteIndexable
tailSet
in interface ByteIndexable
fromIndex
- index to start with, negative counts from the back@NotNull default MutableByteIndexable.Base headSet(int toIndex)
ByteIndexable
headSet
in interface ByteIndexable
toIndex
- index one after the end (equal to the length of the returned set),
negative counts from the back@NotNull default MutableByteIndexable.Base reverse()
ByteIndexable
reverse
in interface ByteIndexable
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 ByteOrdering ordering)
ordering
- sort orderdefault void shuffle(@NotNull java.util.Random random)
random
- random number generator@NotNull default MutableIntIndexable.Base toMutableIntIndexable()
It is recommended to do this when this indexable is heavily used.
@Deprecated default void initByIndex(@NotNull IntToByteFunction1 setter)
fillFrom(IntToByteFunction1)
insteadsetter
- setter which provides the value to be set for a given index@NotNull default java.util.List<java.lang.Byte> 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 ByteIndexable
ByteIndexable.toList()
@NotNull default MutableByteIndexable getCopy()
Copyable
getCopy
in interface Copyable<MutableByteIndexable>
@NotNull static MutableByteIndexable.Base based(@NotNull MutableByteIndexable indexable)
indexable
- mutqable byte indexable to view as a MutableByteIndexable.Base
mutable byte indexable@NotNull static MutableByteIndexable.Base init(int size, @NotNull java.util.function.Supplier<java.lang.Number> creator)
size
- size of indexablecreator
- creator for the initial elementszeroed(int)
,
init(int, byte)
@NotNull static MutableByteIndexable.Base copyOf(@NotNull java.util.Collection<? extends java.lang.Number> collection)
collection
- collection@NotNull static <IN> MutableByteIndexable.Base copy(@NotNull java.util.Collection<IN> collection, @NotNull java.util.function.Function<IN,java.lang.Number> copier)
IN
- incoming element typecollection
- collectioncopier
- element copier@NotNull static MutableByteIndexable.Base empty()
@NotNull static MutableByteIndexable.Base fromArray(@NotNull byte... elements)
elements
- elementselements
@NotNull static MutableByteIndexable.Base fromArray(@NotNull byte[] 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 indexableelements
@NotNull static MutableByteIndexable.Base viewArray(@NotNull byte[] array)
viewArray
in interface ByteIndexable
array
- array@NotNull static MutableByteIndexable.Base viewArray(@NotNull byte[] array, int start, int length)
viewArray
in interface ByteIndexable
array
- arraystart
- start position in arraylength
- length of returned indexable@NotNull static MutableByteIndexable.Base viewList(@NotNull java.util.List<java.lang.Byte> list)
list
- list@NotNull static MutableByteIndexable.Base fromIndexable(@NotNull Indexable<? extends java.lang.Number> indexable)
indexable
- standard indexable@NotNull static <B> MutableByteIndexable.Base fromIndexable(@NotNull Indexable<B> indexable, @NotNull java.util.function.Function<? super B,? extends java.lang.Number> converter)
B
- element type of incoming idexableindexable
- base indexableconverter
- converter from base indexable type to result element type,@NotNull static <T> MutableByteIndexable.Base viewIndexable(@NotNull Indexable<T> indexable, @NotNull ToByteFunction<? super T> getter, @NotNull ByteSetter<? super T> setter)
This is useful if you have complex items, but are interested into only one (byte) 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 MutableByteIndexable.Base fromDoubleIndexable(@NotNull DoubleIndexable indexable)
indexable
- double indexable@NotNull static MutableByteIndexable.Base fromFloatIndexable(@NotNull FloatIndexable indexable)
indexable
- float indexable@NotNull static MutableByteIndexable.Base fromLongIndexable(@NotNull LongIndexable indexable)
indexable
- long indexable@NotNull static MutableByteIndexable.Base fromIntIndexable(@NotNull IntIndexable indexable)
indexable
- int indexable@NotNull static MutableByteIndexable.Base fromShortIndexable(@NotNull ShortIndexable indexable)
indexable
- short indexable@NotNull static MutableByteIndexable.Base fromByteIndexable(@NotNull ByteIndexable indexable)
indexable
- long indexable@NotNull static MutableByteIndexable.Base fromIterable(int size, @NotNull java.lang.Iterable<? extends java.lang.Number> iter)
size
- maximum size of returned indexableiter
- iterable used for initializing the indexable@NotNull static MutableByteIndexable.Base zeroed(int size)
size
0.0
elements.size
- required size of returned mutable byte indexable0.0
init(int, byte)
,
init(int, Supplier)
@NotNull static MutableByteIndexable.Base init(int size, byte value)
init
in interface ByteIndexable
size
- required size of returned mutable byte indexablevalue
- initial value of all elementsvalue
init(int, Supplier)
,
zeroed(int)
@NotNull static MutableByteIndexable.Base initByIndex(int size, @NotNull IntToByteFunction1 producer)
initByIndex
in interface ByteIndexable
size
- size of the returned indexableproducer
- producer which is called with an index and expected to return the associated valueproducer
ByteIndexable.viewByIndex(int, IntToByteFunction1)