public interface IntIndexable extends PrimitiveIntIterable, Sizeable
The EMPTY
constant or emptyIndexable()
method provide the same
useful return value to indicate emptiness.
Simple implementations should extend IntIndexable.Base
because
that provides useful implementations for standard Object methods and implements
Comparable
.
FastIntSequenceSearch
Modifier and Type | Interface and Description |
---|---|
static class |
IntIndexable.Base
Abstract base class which provides useful implementations
for
Object.equals(Object) , Object.hashCode() ,
Object.toString() . |
static interface |
IntIndexable.EntryConsumer
Consumer for index-value pairs with
int values. |
static class |
IntIndexable.IntIndexableSpliterator
Spliterator for int indexables.
|
Modifier and Type | Field and Description |
---|---|
static IntIndexable.Base |
EMPTY
An empty indexable.
|
static IntIndexable.Base |
SINGLE_0
Singleton integer indexable which has only
0 as its single element. |
EMPTY_INT_ITERATOR
Modifier and Type | Method and Description |
---|---|
default void |
addAllTo(java.util.Collection<? super java.lang.Integer> collection)
Add all elements of this indexable to the given collection.
|
default int |
addToArray(int[] array,
int pos)
Add the content of this indexable to the given array.
|
default int |
addToArray(int[] array,
int arrayPos,
int index,
int length)
Add a part of the content of this indexable to the given array.
|
default IntIndexable.Base |
asBase()
Make this integer indexable usable as a class with defined standard Object methods.
|
default java.util.Collection<java.lang.Integer> |
asCollection()
Get a view on this indexable as an unmodifiable collection.
|
default Indexable<java.lang.Integer> |
asIndexable()
Get a view of this indexable as a standard object-based indexable.
|
default java.util.List<java.lang.Integer> |
asList()
Get a view on this indexable as an unmodifiable list.
|
default LongIndexable.Base |
asLongIndexable()
View this integer indexable as a long indexable.
|
default LongIndexable.Base |
asUnsignedIndexable()
View this integer indexable as a long indexable using unsigned values.
|
default int |
binarySearch(int value)
Do a binary search in an indexable ordered in natural ascending order.
|
default int |
binarySearch(int value,
IntOrdering order)
Do a binary search in an ordered indexable.
|
static int |
compare(IntIndexable indexable1,
IntIndexable indexable2)
Compare two int indexables.
|
static int |
compareUnsigned(IntIndexable indexable1,
IntIndexable indexable2)
Compare two int indexables as if they contain unsigned int values.
|
static IntIndexable.Base |
emptyIndexable()
Get an empty indexable set.
|
static boolean |
equal(IntIndexable indexable1,
IntIndexable indexable2)
Are two int indexables equal?
|
static boolean |
equal(IntIndexable indexable1,
java.lang.Object indexable2)
Are two int indexables equal?
|
default int |
firstMatch(java.util.function.IntPredicate check)
Get the first index for which the given check is fulfilled.
|
default int |
foldLeft(int initialValue,
java.util.function.IntBinaryOperator foldOperation)
Go over all values and do a cumulative calculation.
|
default void |
forEachIntEntry(IntIndexable.EntryConsumer consumer)
Call an entry consumer foreach entry in this indexable.
|
default IntIndexable |
frozen()
Get a frozen version of this indexable.
|
default java.util.Spliterator.OfInt |
frozenIntSpliterator()
Get an immutable spliterator on a frozen copy of this indexable.
|
int |
get(int index)
Get the element at the given index.
|
default int |
gyt(int index)
Pythonesque get.
|
static int |
hash(IntIndexable indexable)
Calculate a hashcode for a int indexable.
|
default IntIndexable.Base |
headSet(int toIndex)
Create an indexable subset from the last elements of this indexable set.
|
default java.lang.Iterable<java.lang.Integer> |
indexes()
Get the indexes of this indexable as an iterable range.
|
static IntIndexable.Base |
init(int size,
int value)
Get an integer indexable of a given size which always returns the same value.
|
static IntIndexable |
initByIndex(int size,
java.util.function.IntUnaryOperator producer)
Get an integer indexable of a given size which returns elements created by index.
|
default IntIndexable |
intIndexes()
Get the indexes of this indexable as an integer indexable.
|
default java.util.PrimitiveIterator.OfInt |
intIterator()
Get an primitive int iterator.
|
default java.util.PrimitiveIterator.OfInt |
intIterator(int from,
int to)
Get an int iterator from the given sub set.
|
default java.util.Spliterator.OfInt |
intSpliterator()
Get a spliterator on this indexable.
|
default boolean |
isEmpty()
Is this indexable empty?
|
default boolean |
isOrdered(IntOrdering order)
Is this indexable sorted according to the given ordering?
|
default boolean |
isStrictlyOrdered(IntOrdering order)
Is this indexable strictly sorted according to the given ordering?
|
default java.util.Iterator<java.lang.Integer> |
iterator()
Returns an iterator over elements of type
T . |
default int |
lastMatch(java.util.function.IntPredicate check)
Get the last index for which the given check is fulfilled.
|
default java.util.ListIterator<java.lang.Integer> |
listIterator()
Returns a list iterator over elements of type
T . |
default int |
nextMatch(int startIndex,
java.util.function.IntPredicate check)
Get the next index for which the given check is fulfilled.
|
default MutableIntIndexable |
ordered()
Create a (mutable) int indexable from the values of this indexable
which is ordered in natural order.
|
default MutableIntIndexable |
ordered(IntOrdering order)
Create a (mutable) int indexable from the values of this indexable
which is ordered as defined by the given ordering.
|
default int |
previousMatch(int startIndex,
java.util.function.IntPredicate check)
Get the previous index for which the given check is fulfilled.
|
static IntIndexable |
range(int startValue,
int endValue)
Create an integer indexable which represents a range with step size 1.
|
static IntIndexable |
range(int startValue,
int maxValue,
int stepSize)
Create an integer indexable which is defined by a given range.
|
static IntIndexable |
rangeFromSize(int size)
Create an integer range from
0 with the given size. |
default IntIndexable.Base |
reverse()
Get this indexable but with inverted order.
|
default IntIndexable |
rotated(int steps)
Get a rotated view of this int indexable.
|
static IntIndexable.Base |
singleton(int value)
View a single int value as a int indexable of size 1.
|
default IntIndexable.Base |
subSet(int fromIndex,
int toIndex)
Get an indexable subset.
|
default IntIndexable.Base |
sybSet(int fromIndex,
int toIndex)
Get an indexable subset.
|
default IntIndexable.Base |
tailSet(int fromIndex)
Create an indexable subset from the last elements of this indexable set.
|
default int[] |
toArray()
Convert this into an integer array.
|
default java.util.ArrayList<java.lang.Integer> |
toList()
Create a list from this integer indexable.
|
static java.lang.String |
toString(IntIndexable indexable)
Create a string representation of the given indexable.
|
default <T> Indexable<T> |
view(java.util.function.IntFunction<? extends T> mapper)
Return a mapped view on this integer indexable.
|
static IntIndexable.Base |
viewArray(int... array)
View an int array as an Indexable.
|
static IntIndexable.Base |
viewArray(int[] array,
int start,
int length)
View part of an integer array as an Indexable.
|
static <T> IntIndexable.Base |
viewArray(T[] array,
java.util.function.ToIntFunction<? super T> valueExtract)
View an object array as an integer indexable.
|
default BooleanIndexable |
viewAsBoolean(java.util.function.IntPredicate convert)
View this indexable as a boolean indexable while using a conversion for
each value.
|
default ByteIndexable |
viewAsByte()
View this integer indexable as a byte integer indexable.
|
default CharIndexable |
viewAsChar(IntToCharFunction1 convert)
View this int indexable as a char indexable.
|
default DoubleIndexable |
viewAsDouble()
View this integer indexable as a double indexable.
|
default DoubleIndexable |
viewAsDouble(java.util.function.IntToDoubleFunction convert)
View this indexable as a double indexable while using a conversion for
each value.
|
default FloatIndexable |
viewAsFloat()
View this integer indexable as a float indexable.
|
default LongIndexable |
viewAsLong()
View this integer indexable as a long integer indexable.
|
default LongIndexable |
viewAsLong(java.util.function.IntToLongFunction convert)
View this indexable as a long integer indexable while using a conversion for
each value.
|
default ShortIndexable |
viewAsShort()
View this integer indexable as a short integer indexable.
|
default LongIndexable |
viewAsUnsignedLong()
View this integer indexable as an unsigned long integer indexable.
|
static IntIndexable.Base |
viewByIndex(int size,
java.util.function.IntUnaryOperator producer)
Get an integer indexable of a given size which returns elements created by index.
|
static IntIndexable.Base |
viewIndexable(Indexable<? extends java.lang.Number> indexable)
View a generic Number indexable as integer indexable.
|
static IntIndexable.Base |
viewIndexable(Indexable<? extends java.lang.Number> indexable,
int nullFallback)
View a generic Number indexable as integer indexable.
|
static <T> IntIndexable.Base |
viewIndexable(Indexable<T> indexable,
java.util.function.ToIntFunction<? super T> extractor)
View a generic indexable as an int indexable.
|
static IntIndexable.Base |
viewList(java.util.List<? extends java.lang.Number> list)
View a list as an Indexable.
|
static IntIndexable.Base |
viewList(java.util.List<? extends java.lang.Number> list,
int nullFallback)
View a list as an Indexable.
|
static <T> IntIndexable.Base |
viewList(java.util.List<T> list,
java.util.function.ToIntFunction<? super T> extractor)
View a generic list as a int indexable.
|
static IntIndexable.Base |
viewNumberArray(java.lang.Number... array)
View a Number array as an Indexable.
|
default IntIndexable |
viewOp(java.util.function.IntUnaryOperator op)
View this int indexable transformed by an operator.
|
default IntIndexable.Base |
with(int index,
int value)
Return a new integer indexable where the given index is changed.
|
default IntIndexable |
withAppendedValue(int value)
Create a view with of this indexable with another value added at the end.
|
static IntIndexable.Base |
withCachedHash(IntIndexable indexable)
Wrap an indexable with one which caches the hash value.
|
default IntIndexable |
withExchangedValueAt(int index,
int value)
Create a view of this int indexable with an exchanged value.
|
default IntIndexable |
withInsertedValueAt(int index,
int value)
Create a view of this int indexable with an inserted value.
|
default IntIndexable |
withRemovedValueAt(int index)
Create a view of this indexable with one value removed.
|
default IntIndexable |
withSwappedValuesAt(int index1,
int index2)
Create a view of this int indexable with two values swapped.
|
default IntIndexable.Base |
wyth(int index,
int value)
Return a new integer indexable where the given index is changed
(Pythonesque version)
This allows to index elements from the end by using negative indexes.
|
average, containsInt, forEachInt, forEachIntFragile, longSum, longSumX, spliterator, stream, sum, sumX
@NotNull static final IntIndexable.Base EMPTY
@NotNull static final IntIndexable.Base SINGLE_0
0
as its single element.int get(int index)
index
- index between 0
and size() - 1
default int gyt(int index)
-1
references the last element, -2
its predecessor, and so on.index
- index between -size()
and size() - 1
@NotNull default IntIndexable.Base with(int index, int value)
index
- index between 0
and size() - 1
value
- value to be set@NotNull default IntIndexable.Base wyth(int index, int value)
with(int, int)
which by default copies all values, so this
should be used for small arrays preferably.index
- index between -size()
and size() - 1
value
- value to be set@NotNull default IntIndexable.Base reverse()
default boolean isEmpty()
true
: there are no elements in this indexablefalse
: this indexable has elements@NotNull default java.util.PrimitiveIterator.OfInt intIterator()
intIterator
in interface PrimitiveIntIterable
@NotNull default java.util.PrimitiveIterator.OfInt intIterator(int from, int to)
from
- first index of iteratorto
- one past last index of iteratordefault void forEachIntEntry(@NotNull IntIndexable.EntryConsumer consumer)
consumer
- consumer to be called@NotNull default java.util.Iterator<java.lang.Integer> iterator()
T
.iterator
in interface java.lang.Iterable<java.lang.Integer>
iterator
in interface PrimitiveIntIterable
@NotNull default java.util.ListIterator<java.lang.Integer> listIterator()
T
.@NotNull default IntIndexable.Base subSet(int fromIndex, int toIndex)
fromIndex
to toIndex - 1
.fromIndex
- start index of sub settoIndex
- index after last index@NotNull default IntIndexable.Base sybSet(int fromIndex, int toIndex)
fromIndex
- start index of sub settoIndex
- end index of sub set@NotNull default IntIndexable.Base tailSet(int fromIndex)
fromIndex
- index to start with, negative counts from the back@NotNull default IntIndexable.Base headSet(int toIndex)
toIndex
- index one after the end (equal to the length of the returned set),
negative counts from the back@NotNull default int[] toArray()
default int addToArray(@NotNull int[] array, int pos)
array
- array where the content is addedpos
- position in the array where the content of this indexable is addeddefault int addToArray(@NotNull int[] array, int arrayPos, int index, int length)
array
- array where the content is addedarrayPos
- position in hte array where the content is addedindex
- start index of this indexable which is added firstlength
- number of entries of this indexable added to the array@NotNull default java.util.Collection<java.lang.Integer> asCollection()
Collection.addAll(Collection)
.@NotNull default java.util.List<java.lang.Integer> asList()
Collection.addAll(Collection)
.toList()
@NotNull default java.util.ArrayList<java.lang.Integer> toList()
asList()
default void addAllTo(@NotNull java.util.Collection<? super java.lang.Integer> collection)
collection
- collection to add to@NotNull default Indexable<java.lang.Integer> asIndexable()
Integer
values@NotNull default java.lang.Iterable<java.lang.Integer> indexes()
intIndexes()
,
Range.indexes(int)
@NotNull default IntIndexable intIndexes()
indexes()
,
rangeFromSize(int)
@NotNull default LongIndexable.Base asLongIndexable()
@NotNull default <T> Indexable<T> view(@NotNull java.util.function.IntFunction<? extends T> mapper)
T
- result type pf mappermapper
- mapper@NotNull default LongIndexable.Base asUnsignedIndexable()
default int foldLeft(int initialValue, @NotNull java.util.function.IntBinaryOperator foldOperation)
Eg calculate the maximum of this indexable use
int max = indexable.foldLeft(Pythonesque.UNMAPPABLE, Math::max);
initialValue
- start value for the operation, will be returned if this iterable is emptyfoldOperation
- operation applied to each value, will get the accumulated value as its
first and the current element value as its second argumentdefault int nextMatch(int startIndex, @NotNull java.util.function.IntPredicate check)
startIndex
- start index for checking, Pythonesque
indexing supportedcheck
- check to perform on elements of this indexable until true
startIndex
for which the check returns true
,
Pythonesque.UNMAPPABLE
if nonedefault int firstMatch(@NotNull java.util.function.IntPredicate check)
check
- check to perform on elements of this indexable until true
true
,
-1
if nonedefault int previousMatch(int startIndex, @NotNull java.util.function.IntPredicate check)
startIndex
- start index for checking, Pythonesque
indexing supportedcheck
- check to perform on elements of this indexable until true
startIndex
for which the check returns true
,
Pythonesque.UNMAPPABLE
if nonedefault int lastMatch(@NotNull java.util.function.IntPredicate check)
check
- check to perform on elements of this indexable until true
true
,
-1
if none@NotNull default IntIndexable frozen()
Often Indexables are used as a view to underlying collections. Although this interface is immutable, the underlying colelction might nevertheless change. This copies the current state of this indexable into an unmodifiable state, and returns an Indexable which is stable in size and will return always the same element for a given index. Beware: it is still possible that any element itself changes when the elements are mutable.
Calling frozen()
again on the returned object will just return
the object itself, so you can safely call this method more than once.
@NotNull default java.util.Spliterator.OfInt intSpliterator()
Spliterator.IMMUTABLE
flag set,
see frozenIntSpliterator()
for an alternative.@NotNull default java.util.Spliterator.OfInt frozenIntSpliterator()
frozen()
returns this
)
then this is the same as PrimitiveIntIterable.spliterator()
with the difference that the spliterator
returned here will have its Spliterator.IMMUTABLE
flag set. If this is not immutable
a frozen copy will be created, and the spliterator will be operating on that. Please refer to
frozen()
to understand what level of immutabiliy it will provide.@NotNull default IntIndexable withInsertedValueAt(int index, int value)
ExpandableIntIndexable
if you want to carry out more
stuff like this.
As this creates a view of this indexable, changes to this indexable might result in a disaster when using the returned indexable!
index
- index where the value is inserted before the current index
(not Pythonesque, because it is possible to add an value at index == size()
,
and it is expected that most insertion will happen at 0 or at the end)value
- inserted value at that indexwithAppendedValue(int)
@NotNull default IntIndexable withAppendedValue(int value)
value
- value to addwithInsertedValueAt(int, int)
@NotNull default IntIndexable withExchangedValueAt(int index, int value)
ExpandableIntIndexable
if you want to carry out more
stuff like this.
As this creates a view of this indexable, changes to this indexable could lead to unexpected results when using the returned indexable!
index
- index where the element is exchanged, hiding the current element.
(Pythonesque)value
- exchanged value at that index@NotNull default IntIndexable withRemovedValueAt(int index)
index
- index of the removed value (Pythonesque)@NotNull default IntIndexable withSwappedValuesAt(int index1, int index2)
index1
- index of the first value (Pythonesque)index2
- index of the second value (Pythonesque)@NotNull default IntIndexable rotated(int steps)
steps
will rotate left, i.e. any index will be accessed
as if the number of steps is added before extraction (modulo length).
E.g. a rotation of -1
will return the last element when index 0
is
requested, and the first element for index 1
.steps
- steps to rotatefrozen()
to create an indexable which no longer depends on this one@NotNull default IntIndexable viewOp(@NotNull java.util.function.IntUnaryOperator op)
op
- transforming operator@NotNull default DoubleIndexable viewAsDouble()
frozen()
on the result to create an independent copy
if this seems like a problem to you.@NotNull default DoubleIndexable viewAsDouble(@NotNull java.util.function.IntToDoubleFunction convert)
Use frozen()
on the result to decouple it from this indexable.
convert
- converter applied to each value of this indexable before
it is returned from the resulting indexable@NotNull default FloatIndexable viewAsFloat()
frozen()
on the result to create an independent copy
if this seems like a problem to you.@NotNull default LongIndexable viewAsLong()
frozen()
on the result to create an independent copy
if this seems like a problem to you.@NotNull default LongIndexable viewAsUnsignedLong()
frozen()
on the result to create an independent copy
if this seems like a problem to you.@NotNull default LongIndexable viewAsLong(@NotNull java.util.function.IntToLongFunction convert)
Use frozen()
on the result to decouple it from this indexable.
convert
- converter applied to each value of this indexable before
it is returned from the resulting indexable@NotNull default ShortIndexable viewAsShort()
frozen()
on the result to create an independent copy
if this seems like a problem to you.@NotNull default ByteIndexable viewAsByte()
frozen()
on the result to create an independent copy
if this seems like a problem to you.@NotNull default BooleanIndexable viewAsBoolean(@NotNull java.util.function.IntPredicate convert)
Use frozen()
on the result to decouple it from this indexable.
convert
- converter applied to each value of this indexable before
it is returned from the resulting indexable@NotNull default CharIndexable viewAsChar(@NotNull IntToCharFunction1 convert)
convert
- conversion function which turns the values of this indexable into characters@NotNull static IntIndexable.Base viewList(@NotNull java.util.List<? extends java.lang.Number> list)
list
- list used as a base, required to have only non-null elements@NotNull static IntIndexable.Base viewList(@NotNull java.util.List<? extends java.lang.Number> list, int nullFallback)
list
- list used as a base, required to have only non-null elementsnullFallback
- value returned for null
elements in the list@NotNull static <T> IntIndexable.Base viewList(@NotNull java.util.List<T> list, @NotNull java.util.function.ToIntFunction<? super T> extractor)
T
- element type of listlist
- generic listextractor
- extractor function which extracts a int from the elements of list
list
@NotNull static IntIndexable.Base viewIndexable(@NotNull Indexable<? extends java.lang.Number> indexable)
indexable
- generic indexable with Number elements, required to have only non-null elements@NotNull static IntIndexable.Base viewIndexable(@NotNull Indexable<? extends java.lang.Number> indexable, int nullFallback)
indexable
- generic indexable with Number elementsnullFallback
- fallback for null
elements@NotNull static <T> IntIndexable.Base viewIndexable(@NotNull Indexable<T> indexable, @NotNull java.util.function.ToIntFunction<? super T> extractor)
T
- element type of indexableindexable
- generic indexableextractor
- extractor function which extracts an int from the elements of indexable
indexable
@NotNull static IntIndexable.Base viewNumberArray(@NotNull java.lang.Number... array)
subSet(int, int)
.array
- array used as base, required to hold only non-null values@NotNull static IntIndexable.Base viewArray(@NotNull int... array)
viewArray(int[], int, int)
.array
- array used as base@NotNull static IntIndexable.Base viewArray(@NotNull int[] array, int start, int length)
array
- array used as basestart
- index of first byte to use from the arraylength
- number of elements to use from the array@NotNull static <T> IntIndexable.Base viewArray(@NotNull T[] array, @NotNull java.util.function.ToIntFunction<? super T> valueExtract)
T
- array element typearray
- viewed arrayvalueExtract
- converter from array elements to the integer values of this indexable@NotNull static IntIndexable.Base init(int size, int value)
size
- size of the returned indexablevalue
- value returned for each elementsize
with always the same element@NotNull static IntIndexable.Base viewByIndex(int size, @NotNull java.util.function.IntUnaryOperator producer)
producer
when an element is requested.
Use frozen()
on the result to create an indexable which avoids this.size
- size of the returned indexableproducer
- producer which is called with an index and expected to return the associated valueproducer
with the given index when an element is requestedinitByIndex(int, IntUnaryOperator)
@NotNull static IntIndexable initByIndex(int size, @NotNull java.util.function.IntUnaryOperator producer)
size
- size of the returned indexableproducer
- producer which is called with an index and expected to return the associated valueproducer
viewByIndex(int, IntUnaryOperator)
@NotNull static IntIndexable.Base singleton(int value)
value
- single value@NotNull static IntIndexable.Base emptyIndexable()
@NotNull static java.lang.String toString(@NotNull IntIndexable indexable)
indexable
- indexablestatic boolean equal(@NotNull IntIndexable indexable1, @NotNull IntIndexable indexable2)
indexable1
- first indexableindexable2
- second indexabletrue
if both indexables contain the same values in the same sequencefalse
if sizes or values differstatic boolean equal(@NotNull IntIndexable indexable1, @Nullable java.lang.Object indexable2)
Object.equals(Object)
method.indexable1
- first indexableindexable2
- object expected to be an indexable itselftrue
if both indexables contain the same values in the same sequencefalse
if the second object is not an indexable, of if sizes or values differstatic int compare(@NotNull IntIndexable indexable1, @NotNull IntIndexable indexable2)
indexable1
- first indexableindexable2
- second indexable< 0>
if indexable1 < indxable2
,
0
if indexable1 == indexable2
, or
> 0
if indexable1 > indexable2
static int compareUnsigned(@NotNull IntIndexable indexable1, @NotNull IntIndexable indexable2)
indexable1
- first indexableindexable2
- second indexable< 0>
if indexable1 < indxable2
,
0
if indexable1 == indexable2
, or
> 0
if indexable1 > indexable2
static int hash(@NotNull IntIndexable indexable)
indexable
- indexable for which the hash code is required@NotNull static IntIndexable.Base withCachedHash(@NotNull IntIndexable indexable)
The wrapped indexable must not change after it is wrapped, otherwise strange things are expected to happen.
indexable
- wrapped indexable, must not changeindexable
, but also provides
useful implementations for Object.hashCode()
, Object.equals(Object)
,
and Object.toString()
@NotNull static IntIndexable range(int startValue, int maxValue, int stepSize)
IllegalArgumentException
if the parameters require a range
of a larger size. If such larger size is required, but indexing is not,
see Range.of(int, int, int)
.startValue
- start value of range (included)maxValue
- end value of range (included if stepped on)stepSize
- step size, not 0
, may be negative if startValue < endValue
@NotNull static IntIndexable range(int startValue, int endValue)
IllegalArgumentException
. If in need of such large ranges
but not of indexing see Range.of(int, int)
.startValue
- start value of range (included)endValue
- end value of range (included)startValue
to endValue
with step size
1
or -1
(if startValue > endValue
)@NotNull static IntIndexable rangeFromSize(int size)
0
with the given size.
As zero is included last index of the range is size - 1
size
- range sizedefault boolean isOrdered(@NotNull IntOrdering order)
order
- expected orderingtrue
if this indexable is sorted as defined by order
false
if notdefault boolean isStrictlyOrdered(@NotNull IntOrdering order)
order
- expected orderingtrue
if this indexable is sorted as defined by order
false
if notdefault int binarySearch(int value)
natural ascending order
,
i.e. isOrdered(IntOrdering) has to return true
to make this method work.
For efficiency this prerequisite is not checked, but not fulfilling
it will make this method return bogus results. If this indexable is only ordered,
but not strictly ordered
it is not defined
which index is returned when the looked up value appears in a sequence of equal values.
value
- value to look up-(insertIndex + 1)
.default int binarySearch(int value, @NotNull IntOrdering order)
order
,
i.e. isOrdered(IntOrdering) has to return true
for this order.
For efficiency this prerequisite is not checked, but not fulfilling
it will make this method return bogus results. If this indexable is only ordered,
but not strictly ordered
it is not defined
which index is returned when the looked up value appears in a sequence of equal values.
value
- value to look uporder
- sort order-(insertIndex + 1)
.@NotNull default MutableIntIndexable ordered(@NotNull IntOrdering order)
If natural ordering is required prefer calling ordered()
because that typically runs 1.5 times faster.
order
- sort order@NotNull default MutableIntIndexable ordered()
This can be some 1.5x faster than using ordered(IntOrdering)
with natural order
.
@NotNull default IntIndexable.Base asBase()