public interface ExpandableIndexable<T> extends Indexable<T>
This interface defines an indexable which allows to change (set, add, remove) its values but is immutable nevertheless. All changing methods return copies, thus guaranteeing immutability.
The immutablility guarantee is only valid for the indexable implementation, mutable elements which are changed will lead to strange effects, eg they are changed in all copies.
The internal implementation tries to keep copying a cheap operation, but some access patterns may result in performance degration. It is therefore recommended not to use this in time-critical code.
Initial creation is done by using the following methods:
Indexable.Base<TT>, Indexable.IndexableSpliterator<TElem>, Indexable.ListView<T>
EMPTY, EMPTY_INDEXABLE_STRING
Modifier and Type | Method and Description |
---|---|
ExpandableIndexable<T> |
add(int index,
T value)
Return an expandable indexable where the the given value
was inserted at the given index.
|
default ExpandableIndexable<T> |
add(T value)
Return an expandable int indexable where the given
value was added to the end of this indexable.
|
default ExpandableIndexable<T> |
addAll(java.lang.Iterable<? extends T> elements)
Add all elements to this indexable and return the result.
|
static <E> ExpandableIndexable<E> |
empty()
Convenience method to create an empty expandable int indexable.
|
static <E> ExpandableIndexable<E> |
from(java.util.Collection<? extends E> values)
Deprecated.
overlaps with other
from() methods, use fromCollection(Collection) instead |
static <E> ExpandableIndexable<E> |
from(E... values)
Deprecated.
overlaps with other
from() methods, use fromArray(Object[]) instead |
static <E> ExpandableIndexable<E> |
from(E[] array,
int start,
int length)
Deprecated.
overlaps with other
from() methods, use fromArray(Object[], int, int) instead |
static <E> ExpandableIndexable<E> |
from(Indexable<E> indexable)
Deprecated.
overlaps with other
from() methods, use fromIndexable(Indexable) instead |
static <E> ExpandableIndexable<E> |
fromArray(E... values)
Create an expandable integer indexable from an initial array of values.
|
static <E> ExpandableIndexable<E> |
fromArray(E[] array,
int start,
int length)
Create an expandable integer indexable from part of an int array.
|
static <E> ExpandableIndexable<E> |
fromCollection(java.util.Collection<? extends E> values)
Create an expandable integer indexable from a collection of numbers.
|
static <E> ExpandableIndexable<E> |
fromIndexable(Indexable<E> indexable)
Get an expandable integer indexable from a normal
integer indexable.
|
static <E> ExpandableIndexable<E> |
initByIndex(int size,
java.util.function.IntFunction<? extends E> producer)
Create an expandable indexable with a given size, and initialize its elements by index.
|
default java.util.Iterator<T> |
iterator()
Returns an iterator over elements of type
T . |
static <E> ExpandableIndexable<E> |
nulled(int size)
Create an expandable indexable with a given size, and initialize all its elements to
null . |
ExpandableIndexable<T> |
remove(int index)
Return an expandable int indexable where the value at the given index
was removed.
|
default ExpandableIndexable<T> |
remyve(int index)
Pythonesque remove allowing negative indexes to remove from the end.
|
ExpandableIndexable<T> |
set(int index,
T value)
Set the value at the given index.
|
default ExpandableIndexable<T> |
syt(int index,
T value)
Pythonesque set the value at the given index.
|
default ExpandableIndexable<T> |
ydd(int index,
T value)
Pythonesque insertion allowing negative indexes to insert from the end.
|
addToArray, addToArray, addToCollection, asBase, asCollection, asList, binarySearch, checkIndex, combine, compare, downCast, emptyIndexable, equal, findAll, findFirst, findFirst, findFirst, findLast, findLast, findLast, findNext, findNext, findNext, findPrevious, findPrevious, findPrevious, first, firstMatch, firstMatch, forEachEntry, forEachEntryFragile, fromCollection, fromCountable, fromCountable, fromEnumeration, fromEnumeration, fromIterable, fromIterable, fromIterable, fromIterable, fromIterator, fromList, fromOptional, frozenSpliterator, get, getMod, gyt, hash, headSet, indexedView, indexes, init, initByIndex, intIndexes, isEmpty, isOrdered, isStrictlyOrdered, iterator, last, listIterator, mapArray, optional, ordered, reverse, rotated, singleton, spliterator, subSet, sybSet, tailSet, toString, view, view, viewArray, viewArray, viewAsBooleanIndexable, viewAsByteIndexable, viewAsCharIndexable, viewAsDoubleIndexable, viewAsFloatIndexable, viewAsIntIndexable, viewAsLongIndexable, viewAsShortIndexable, viewByIndex, viewFragile, viewList, viewList, viewListN, viewListN, viewTuple, viewTuple, viewTuple, viewTuple, viewTuple, viewTuple, viewTuple, viewTuple, withAppendedItem, withCachedHash, withExchangedItemAt, withInsertedItemAt, withRemovedItemAt, withSwappedItemsAt
addAllTo, combined, combined, containsEq, containsRef, downCast, equal, equals, filtered, filteredToIndexable, filterToCountable, firstOrNull, foldLeft, forEachFragile, freeze, frozen, frozen, groupingBy, groupingBy, hasAll, hasAny, isSorted, isStrictlySorted, lastOrNull, mappingBy, mappingBy, optFirst, optLast, orderedCombination, sorted, toArray, toArray, toList, toString, uniform, viewCollection, viewCollection, viewCollectionN, viewCollectionN
@NotNull ExpandableIndexable<T> add(int index, T value)
index
- index in the range 0
(insert at first position)
to size()
(insert after last position)value
- value to insert at the given position@NotNull ExpandableIndexable<T> remove(int index)
index
- index to remove, in the range 0
to
size() - 1
@NotNull ExpandableIndexable<T> set(int index, T value)
index
- indexvalue
- new value@NotNull default ExpandableIndexable<T> syt(int index, T value)
index
- index, negative to count from the backvalue
- value to set@NotNull default ExpandableIndexable<T> add(T value)
value
- value to add@NotNull default ExpandableIndexable<T> ydd(int index, T value)
index
- positive values behave the same way as add(int, Object)
,
but negative values count from the back, so -1
will insert before the last elementvalue
- value to insert@NotNull default ExpandableIndexable<T> remyve(int index)
index
- positive values behave the same as remove(int)
,
while negative indexes count from the back, so -1
will remove the last element@NotNull default ExpandableIndexable<T> addAll(@NotNull java.lang.Iterable<? extends T> elements)
elements
- elements to add@NotNull default java.util.Iterator<T> iterator()
Indexable
T
.@NotNull static <E> ExpandableIndexable<E> empty()
@NotNull static <E> ExpandableIndexable<E> initByIndex(int size, @NotNull java.util.function.IntFunction<? extends E> producer)
E
- element typesize
- size of the indexableproducer
- element producer which will be called for each indexIndexable.viewByIndex(int, IntFunction)
@NotNull static <E> ExpandableIndexable<E> nulled(int size)
null
.E
- element typesize
- size of the returned indexablenull
elements@NotNull @SafeVarargs @Deprecated static <E> ExpandableIndexable<E> from(@NotNull E... values)
from()
methods, use fromArray(Object[])
insteadE
- element typevalues
- array of values@NotNull @SafeVarargs static <E> ExpandableIndexable<E> fromArray(@NotNull E... values)
@NotNull @Deprecated static <E> ExpandableIndexable<E> from(@NotNull E[] array, int start, int length)
from()
methods, use fromArray(Object[], int, int)
insteadE
- element typearray
- integer arraystart
- start position in arraylength
- number of byte in array@NotNull static <E> ExpandableIndexable<E> fromArray(@NotNull E[] array, int start, int length)
E
- element typearray
- integer arraystart
- start position in arraylength
- number of byte in array@NotNull @Deprecated static <E> ExpandableIndexable<E> from(@NotNull Indexable<E> indexable)
from()
methods, use fromIndexable(Indexable)
insteadE
- element typeindexable
- standard integer indexable@NotNull static <E> ExpandableIndexable<E> fromIndexable(@NotNull Indexable<E> indexable)
E
- element typeindexable
- standard integer indexable@NotNull @Deprecated static <E> ExpandableIndexable<E> from(@NotNull java.util.Collection<? extends E> values)
from()
methods, use fromCollection(Collection)
insteadE
- element typevalues
- collection of numbers, List
is strongly
recommended for better performance@NotNull static <E> ExpandableIndexable<E> fromCollection(@NotNull java.util.Collection<? extends E> values)
fromCollection
in interface Indexable<T>
E
- element typevalues
- collection of numbers, List
is strongly
recommended for better performance