public interface MutableBooleanIndexable extends BooleanIndexable, Copyable<MutableBooleanIndexable>
boolean[]
as it eg allows
read-only views or transparent views of subsets of the array.Modifier and Type | Interface and Description |
---|---|
static class |
MutableBooleanIndexable.Base
Abstract base class which provides useful implementations
for
Object.equals(Object) , Object.hashCode() ,
Object.toString() . |
Modifier and Type | Field and Description |
---|---|
static MutableBooleanIndexable.Base |
EMPTY
Empty mutable indexable.
|
SINGLE_FALSE, SINGLE_TRUE
EMPTY_BOOLEAN_ITERATOR
Modifier and Type | Method and Description |
---|---|
default java.util.List<java.lang.Boolean> |
asList()
View this indexable as a standard list.
|
static MutableBooleanIndexable.Base |
based(MutableBooleanIndexable indexable)
View any mutable boolean indexable as a base boolean indexable.
|
static <IN> MutableBooleanIndexable.Base |
copy(java.util.Collection<IN> collection,
java.util.function.Predicate<IN> copier)
Create a mutable indexable which is initialized from copied elements of
a given collection.
|
static MutableBooleanIndexable.Base |
copyOf(java.util.Collection<? extends java.lang.Boolean> collection)
Create a mutable indexable which is initialized from a
given collection.
|
static MutableBooleanIndexable.Base |
empty() |
static MutableBooleanIndexable.Base |
fromArray(boolean... elements)
Create a mutable indexable which is initialized from elements
of the given array.
|
static MutableBooleanIndexable.Base |
fromArray(boolean[] elements,
int startIndex,
int length)
Create a mutable indexable which is initialized from elements
of the given array.
|
static MutableBooleanIndexable.Base |
fromBooleanIndexable(BooleanIndexable indexable)
Return a mutable boolean indexable initialized with the content of a
standard boolean indexable.
|
static MutableBooleanIndexable.Base |
fromIndexable(Indexable<? extends java.lang.Boolean> indexable)
Create a mutable indexable which is the copy of a standard indexable.
|
static <B> MutableBooleanIndexable.Base |
fromIndexable(Indexable<B> indexable,
java.util.function.Predicate<? super B> converter)
Create a mutable indexable which is the copy of a standard indexable.
|
static MutableBooleanIndexable.Base |
fromIterable(int size,
java.lang.Iterable<? extends java.lang.Boolean> iter)
Create a mutable indexable from an iterable or a part of it.
|
default MutableBooleanIndexable |
getCopy()
Get a copy of this object.
|
default MutableBooleanIndexable.Base |
headSet(int toIndex)
Create an indexable subset from the last elements of this indexable set.
|
static MutableBooleanIndexable.Base |
init(int size,
boolean value)
Create a mutable
|
static MutableBooleanIndexable.Base |
init(int size,
java.util.function.BooleanSupplier creator)
Initialize a mutable indexable to a given size.
|
static MutableBooleanIndexable.Base |
initByIndex(int size,
java.util.function.IntPredicate producer)
Get a mutable boolean indexable of a given size which contains elements created by index.
|
default void |
initByIndex(IntPredicate1 setter)
Set all values of this boolean indexable by index.
|
default MutableBooleanIndexable.Base |
reverse()
Get this indexable but with inverted order.
|
void |
set(int index,
boolean value)
Set the element at the given index.
|
default int |
setFrom(java.lang.Iterable<? extends java.lang.Boolean> iterable)
Set the values of this mutable boolean 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.Boolean> iterable,
int startIndex,
int numElements)
Set the values of this mutable boolean indexable one after
the other from the given iterable until either the
iterable is emptied or
numElements elements are set. |
default void |
setMulti(int from,
int len,
boolean value)
Set multiple elements to the same value.
|
default void |
shuffle(java.util.Random random)
Randomize the content of this mutable indexable.
|
default MutableBooleanIndexable.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 MutableBooleanIndexable.Base |
sybSet(int fromIndex,
int toIndex)
Get an indexable subset.
|
default void |
syt(int index,
boolean value)
Pythonesque set.
|
default MutableBooleanIndexable.Base |
tailSet(int fromIndex)
Create an indexable subset from the last elements of this indexable set.
|
static MutableBooleanIndexable.Base |
viewArray(boolean[] array)
Mutable indexable view which operates on the given array.
|
static <T> MutableBooleanIndexable.Base |
viewIndexable(Indexable<T> indexable,
java.util.function.Predicate<? super T> getter,
BooleanSetter<? super T> setter)
View a generic indexable as a mutable boolean indexable by accessing
a boolean property of the elements of the underlying generic indexable.
|
static MutableBooleanIndexable.Base |
viewList(java.util.List<java.lang.Boolean> list)
Mutable indexable view which operates on the given array.
|
addAllTo, addToArray, addToArray, asBase, asCollection, asIndexable, booleanIterator, booleanIterator, compare, emptyIndexable, equal, equal, firstMatch, foldLeft, frozen, get, gyt, hash, indexes, initByIndex, intIndexes, isEmpty, iterator, lastMatch, listIterator, nextMatch, previousMatch, rotated, singleton, toArray, toList, toString, view, viewArray, viewArray, viewByIndex, viewIndexable, viewIndexable, viewIndexable, viewList, viewList, viewList, withAppendedValue, withCachedHash, withExchangedValueAt, withInsertedValueAt, withRemovedValueAt, withSwappedValuesAt
and, containsBool, containsFalse, containsTrue, forEachBool, forEachBooleanFragile, forEachBoolFragile, or, xor
static final MutableBooleanIndexable.Base EMPTY
empty()
instead.void set(int index, boolean value)
index
- index between 0
and size() - 1
value
- value to put to the given indexdefault void syt(int index, boolean 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.Boolean> iterable)
Sizeable.size()
elements are set.iterable
- iterable from which this indexable is filleddefault int setFrom(@NotNull java.lang.Iterable<? extends java.lang.Boolean> 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 setMulti(int from, int len, boolean value)
from
- first index to be set (Pythonesque)len
- number of elements to be set (non-negative)value
- value to be setdefault 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
)default void shuffle(@NotNull java.util.Random random)
random
- random number generator@NotNull default MutableBooleanIndexable.Base subSet(int fromIndex, int toIndex)
BooleanIndexable
fromIndex
to toIndex - 1
.subSet
in interface BooleanIndexable
fromIndex
- start index of sub settoIndex
- index after last index@NotNull default MutableBooleanIndexable.Base sybSet(int fromIndex, int toIndex)
BooleanIndexable
sybSet
in interface BooleanIndexable
fromIndex
- start index of sub settoIndex
- end index of sub set@NotNull default MutableBooleanIndexable.Base tailSet(int fromIndex)
BooleanIndexable
tailSet
in interface BooleanIndexable
fromIndex
- index to start with, negative counts from the back@NotNull default MutableBooleanIndexable.Base headSet(int toIndex)
BooleanIndexable
headSet
in interface BooleanIndexable
toIndex
- index one after the end (equal to the length of the returned set),
negative counts from the back@NotNull default MutableBooleanIndexable.Base reverse()
BooleanIndexable
reverse
in interface BooleanIndexable
default void initByIndex(@NotNull IntPredicate1 setter)
setter
- setter which provides the value to be set for a given index@NotNull default java.util.List<java.lang.Boolean> 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 BooleanIndexable
BooleanIndexable.toList()
@NotNull default MutableBooleanIndexable getCopy()
Copyable
getCopy
in interface Copyable<MutableBooleanIndexable>
@NotNull static MutableBooleanIndexable.Base based(@NotNull MutableBooleanIndexable indexable)
indexable
- mutqable boolean indexable to view as a MutableBooleanIndexable.Base
mutable boolean indexable@NotNull static MutableBooleanIndexable.Base init(int size, @NotNull java.util.function.BooleanSupplier creator)
size
- size of indexablecreator
- creator for the initial elementsinit(int, boolean)
,
init(int, BooleanSupplier)
@NotNull static MutableBooleanIndexable.Base copyOf(@NotNull java.util.Collection<? extends java.lang.Boolean> collection)
collection
- collection@NotNull static <IN> MutableBooleanIndexable.Base copy(@NotNull java.util.Collection<IN> collection, @NotNull java.util.function.Predicate<IN> copier)
IN
- incoming element typecollection
- collectioncopier
- element copier@NotNull static MutableBooleanIndexable.Base empty()
@NotNull static MutableBooleanIndexable.Base fromArray(@NotNull boolean... elements)
elements
- elementselements
@NotNull static MutableBooleanIndexable.Base fromArray(@NotNull boolean[] 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 MutableBooleanIndexable.Base viewArray(@NotNull boolean[] array)
viewArray
in interface BooleanIndexable
array
- array@NotNull static MutableBooleanIndexable.Base viewList(@NotNull java.util.List<java.lang.Boolean> list)
list
- list@NotNull static MutableBooleanIndexable.Base fromIndexable(@NotNull Indexable<? extends java.lang.Boolean> indexable)
indexable
- standard indexable@NotNull static <B> MutableBooleanIndexable.Base fromIndexable(@NotNull Indexable<B> indexable, @NotNull java.util.function.Predicate<? super B> converter)
B
- element type of incoming idexableindexable
- base indexableconverter
- converter from base indexable type to result element type,@NotNull static <T> MutableBooleanIndexable.Base viewIndexable(@NotNull Indexable<T> indexable, @NotNull java.util.function.Predicate<? super T> getter, @NotNull BooleanSetter<? super T> setter)
This is useful if you have complex items, but are interested into only one (boolean) 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 MutableBooleanIndexable.Base fromBooleanIndexable(@NotNull BooleanIndexable indexable)
indexable
- boolean indexable@NotNull static MutableBooleanIndexable.Base fromIterable(int size, @NotNull java.lang.Iterable<? extends java.lang.Boolean> iter)
size
- maximum size of returned indexableiter
- iterable used for initializing the indexable@NotNull static MutableBooleanIndexable.Base init(int size, boolean value)
init
in interface BooleanIndexable
size
- required size of returned mutable boolean indexablevalue
- initial value of all elementsvalue
init(int, BooleanSupplier)
@NotNull static MutableBooleanIndexable.Base initByIndex(int size, @NotNull java.util.function.IntPredicate producer)
size
- size of the returned indexableproducer
- producer which is called with an index and expected to return the associated valueproducer