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