public interface ByteIndexable extends PrimitiveByteIterable, Sizeable
The EMPTY
constant or emptyIndexable()
method provide the same
useful return value to indicate emptiness.
Simple implementations should extend ByteIndexable.Base
because
that provides useful implementations for standard Object methods and implements
Comparable
.
FastByteSequenceSearch
Modifier and Type | Interface and Description |
---|---|
static class |
ByteIndexable.Base
Abstract base class which provides useful implementations
for
Object.equals(Object) , Object.hashCode() ,
Object.toString() . |
Modifier and Type | Field and Description |
---|---|
static ByteIndexable.Base |
EMPTY
An empty indexable.
|
static Indexable<java.lang.String> |
LOWERCASE_2DIGIT_HEXCODES
Indexable with the 256 hexadecimal 2-digit codes for the (unsigned) byte values defined by the index (lowercase).
|
static ByteIndexable |
SINGLE_0
Byte indexable with only one element with value 0.
|
static Indexable<java.lang.String> |
UPPERCASE_2DIGIT_HEXCODES
Indexable with the 256 hexadecimal 2-digit codes for the (unsigned) byte values defined by the index (uppercase).
|
EMPTY_BYTE_ITERATOR
Modifier and Type | Method and Description |
---|---|
default void |
addAllTo(java.util.Collection<? super java.lang.Byte> collection)
Add all elements of this indexable to the given collection.
|
default int |
addToArray(byte[] array,
int pos)
Add the content of this indexable to the given array.
|
default int |
addToArray(byte[] array,
int arrayPos,
int index,
int length)
Add a part of the content of this indexable to the given array.
|
default int |
addToArray(int[] array,
int pos)
Add the content of this indexable to the given int array.
|
default int |
addToArray(int[] array,
int arrayPos,
int index,
int length)
Add a part of the content of this indexable to the given intarray.
|
default ByteIndexable.Base |
asBase()
Make this byte indexable usable as a class with defined standard Object methods.
|
default java.util.Collection<java.lang.Byte> |
asCollection()
Get a view on this indexable as an unmodifiable collection.
|
default Indexable<java.lang.Byte> |
asIndexable()
Get a view of this indexable as a standard object-based indexable.
|
default IntIndexable.Base |
asIntIndexable()
View this byte indexable as an integer indexable.
|
default java.util.List<java.lang.Byte> |
asList()
Get a view on this indexable as an unmodifiable list.
|
default IntIndexable.Base |
asUnsignedIndexable()
View this byte indexable as an integer indexable using unsigned values.
|
default int |
binarySearch(byte value)
Do a binary search in an indexable ordered in natural ascending order.
|
default int |
binarySearch(byte value,
ByteOrdering order)
Do a binary search in an ordered indexable.
|
default PrimitiveByteIterator |
byteIterator()
Get an primitive byte iterator.
|
default PrimitiveByteIterator |
byteIterator(int from,
int to)
Get a byte iterator from the given sub set.
|
static byte[] |
bytesFromHexString(java.lang.String hexString)
Get a byte array from a string of hexcoded bytes.
|
static int |
compare(ByteIndexable indexable1,
ByteIndexable indexable2)
Compare two byte indexables.
|
static int |
compareUnsigned(ByteIndexable indexable1,
ByteIndexable indexable2)
Compare two byte indexables as if they contain unsigned byte values.
|
default void |
copyTo(byte[] targetArray,
int targetStart)
Copy the content of this indexable into a byte array.
|
default void |
copyTo(byte[] targetArray,
int targetStart,
int sourceStart,
int length)
Copy the content of this indexable (or a part of it)
into a byte array.
|
static ByteIndexable.Base |
emptyIndexable()
Get an empty indexable set.
|
static boolean |
equal(ByteIndexable indexable1,
ByteIndexable indexable2)
Are two byte indexables equal?
|
static boolean |
equal(ByteIndexable indexable1,
java.lang.Object indexable2)
Are two byte indexables equal?
|
default int |
firstMatch(BytePredicate1 check)
Get the first index for which the given check is fulfilled.
|
default byte |
foldLeft(byte initialValue,
ByteOperator2 foldOperation)
Go over all values and do a cumulative calculation.
|
static ByteIndexable |
fromHexString(java.lang.String hexString)
Get a byte indexable from a string of hexcoded bytes.
|
default ByteIndexable |
frozen()
Get a frozen version of this indexable.
|
byte |
get(int index)
Get the element at the given index.
|
default byte |
gyt(int index)
Pythonesque get.
|
static int |
hash(ByteIndexable indexable)
Calculate a hashcode for a byte indexable.
|
default ByteIndexable.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 ByteIndexable.Base |
init(int size,
byte value)
Get a byte indexable of a given size which always returns the same value.
|
static ByteIndexable |
initByIndex(int size,
IntToByteFunction1 producer)
Get a byte 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 a primitive int iterator.
|
default boolean |
isEmpty()
Is this indexable empty?
|
default boolean |
isOrdered()
Is this indexable sorted naturally?
|
default boolean |
isOrdered(ByteOrdering order)
Is this indexable sorted according to the given ordering?
|
default boolean |
isStrictlyOrdered()
Is this indexable strictly sorted naturally?
|
default boolean |
isStrictlyOrdered(ByteOrdering order)
Is this indexable strictly sorted according to the given ordering?
|
default java.util.Iterator<java.lang.Byte> |
iterator()
Returns an iterator over elements of type
T . |
default int |
lastMatch(BytePredicate1 check)
Get the last index for which the given check is fulfilled.
|
default java.util.ListIterator<java.lang.Byte> |
listIterator()
Returns a list iterator over elements of type
T . |
default int |
nextMatch(int startIndex,
BytePredicate1 check)
Get the next index for which the given check is fulfilled.
|
default MutableByteIndexable |
ordered(ByteOrdering order)
Create a (mutable) byte indexable from the values of this indexable
which is ordered as defined by the given ordering.
|
default int |
previousMatch(int startIndex,
BytePredicate1 check)
Get the previous index for which the given check is fulfilled.
|
default ByteIndexable.Base |
reverse()
Get this indexable but with inverted order.
|
default ByteIndexable |
rotated(int steps)
Get a rotated view of this byte indexable.
|
static ByteIndexable.Base |
singleton(byte value)
View a single byte value as a byte indexable of size 1.
|
default ByteIndexable.Base |
subSet(int fromIndex,
int toIndex)
Get an indexable subset.
|
default ByteIndexable.Base |
sybSet(int fromIndex,
int toIndex)
Get an indexable subset.
|
default ByteIndexable.Base |
tailSet(int fromIndex)
Create an indexable subset from the last elements of this indexable set.
|
default byte[] |
toArray()
Convert this indexable into a Java array.
|
default byte[] |
toByteArray()
Get a byte array copy of this byte indexable.
|
default java.lang.String |
toHexString()
Convert this byte indexable into a string of hexadecimal numbers, 2 per byte, using uppercase.
|
default java.lang.String |
toHexString(boolean uppercase)
Convert this byte indexable into a string of hexadecimal numbers, 2 per byte.
|
default int[] |
toIntArray()
Convert this indexable into an int array.
|
default java.util.ArrayList<java.lang.Byte> |
toList()
Create a list from this bye indexable.
|
static java.lang.String |
toString(ByteIndexable indexable)
Create a string representation of the given indexable.
|
default <T> Indexable<T> |
view(ByteFunction1<? extends T> mapper)
Return a mapped view on this BYTE indexable.
|
static ByteIndexable.Base |
viewArray(byte... array)
View a byte array as an Indexable.
|
static ByteIndexable.Base |
viewArray(byte[] array,
int start,
int length)
View part of a byte array as an Indexable.
|
static <T> ByteIndexable.Base |
viewArray(T[] array,
ToByteFunction<? super T> valueExtract)
View an object array as a byte indexable.
|
default BooleanIndexable |
viewAsBoolean(BytePredicate1 convert)
View this indexable as a boolean indexable while using a conversion for
each value.
|
default DoubleIndexable |
viewAsDouble()
View this byte integer indexable as a double indexable.
|
default FloatIndexable |
viewAsFloat()
View this byte integer indexable as a float indexable.
|
default IntIndexable |
viewAsInt()
View this byte integer indexable as an integer indexable.
|
default LongIndexable |
viewAsLong()
View this byte integer indexable as a long integer indexable.
|
default ShortIndexable |
viewAsShort()
View this byte integer indexable as a short integer indexable.
|
default IntIndexable |
viewAsUnsignedInt()
View this byte integer indexable as an unsigned integer indexable.
|
default LongIndexable |
viewAsUnsignedLong()
View this byte integer indexable as an unsigned long integer indexable.
|
default ShortIndexable |
viewAsUnsignedShort()
View this byte integer indexable as an unsigned short integer indexable.
|
static ByteIndexable.Base |
viewByIndex(int size,
IntToByteFunction1 producer)
Get a byte indexable of a given size which returns elements created by index.
|
static ByteIndexable.Base |
viewIndexable(Indexable<? extends java.lang.Number> indexable)
View a generic Number indexable as byte indexable.
|
static ByteIndexable.Base |
viewIndexable(Indexable<? extends java.lang.Number> indexable,
byte nullFallback)
View a generic Number indexable as byte indexable.
|
static <T> ByteIndexable.Base |
viewIndexable(Indexable<T> indexable,
ToByteFunction<? super T> extractor)
View a generic indexable as a byte indexable.
|
static ByteIndexable.Base |
viewList(java.util.List<? extends java.lang.Number> list)
View a list as an Indexable.
|
static ByteIndexable.Base |
viewList(java.util.List<? extends java.lang.Number> list,
byte nullValue)
View a list as an Indexable.
|
static <T> ByteIndexable.Base |
viewList(java.util.List<T> list,
ToByteFunction<? super T> extractor)
View a generic list as a double indexable.
|
static ByteIndexable.Base |
viewNumberArray(java.lang.Number... array)
View a Number array as an Indexable.
|
default ByteIndexable |
viewOp(ByteOperator1 op)
View this byte indexable transformed by an operator.
|
default ByteIndexable |
withAppendedValue(byte value)
Create a view with of this indexable with another value added at the end.
|
static ByteIndexable.Base |
withCachedHash(ByteIndexable indexable)
Wrap an indexable with one which caches the hash value.
|
default ByteIndexable |
withExchangedValueAt(int index,
byte value)
Create a view of this byte indexable with an exchanged value.
|
default ByteIndexable |
withInsertedValueAt(int index,
byte value)
Create a view of this byte indexable with an inserted value.
|
default ByteIndexable |
withRemovedValueAt(int index)
Create a view of this indexable with one value removed.
|
default ByteIndexable |
withSwappedValuesAt(int index1,
int index2)
Create a view of this byte indexable with two values swapped.
|
asIntIterable, asLongIterable, asShortIterable, asUnsignedIntIterable, asUnsignedLongIterable, containsByte, forEachByte, forEachByteFragile
static final ByteIndexable SINGLE_0
static final Indexable<java.lang.String> UPPERCASE_2DIGIT_HEXCODES
static final Indexable<java.lang.String> LOWERCASE_2DIGIT_HEXCODES
static final ByteIndexable.Base EMPTY
byte get(int index)
index
- index between 0
and size() - 1
default byte gyt(int index)
-1
references the last element, -2
its predecessor, and so on.index
- index between -size()
and size() - 1
@NotNull default ByteIndexable.Base reverse()
default boolean isEmpty()
true
: there are no elements in this indexablefalse
: this indexable has elements@NotNull default java.util.PrimitiveIterator.OfInt intIterator()
int
iterator which iterates over this indexable@NotNull default PrimitiveByteIterator byteIterator()
byteIterator
in interface PrimitiveByteIterable
byte
iterator which iterates over this indexable@NotNull default PrimitiveByteIterator byteIterator(int from, int to)
from
- first index of iteratorto
- one past last index of iterator@NotNull default java.util.Iterator<java.lang.Byte> iterator()
T
.iterator
in interface java.lang.Iterable<java.lang.Byte>
iterator
in interface PrimitiveByteIterable
@NotNull default java.util.ListIterator<java.lang.Byte> listIterator()
T
.@NotNull default ByteIndexable.Base subSet(int fromIndex, int toIndex)
fromIndex
to toIndex - 1
.fromIndex
- start index of sub settoIndex
- index after last index@NotNull default ByteIndexable.Base sybSet(int fromIndex, int toIndex)
fromIndex
- start index of sub settoIndex
- end index of sub set@NotNull default ByteIndexable.Base tailSet(int fromIndex)
fromIndex
- index to start with, negative counts from the back@NotNull default ByteIndexable.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 <T> Indexable<T> view(@NotNull ByteFunction1<? extends T> mapper)
T
- result type pf mappermapper
- mapper@NotNull default java.util.Collection<java.lang.Byte> asCollection()
Collection.addAll(Collection)
.@NotNull default java.util.List<java.lang.Byte> asList()
Collection.addAll(Collection)
.toList()
@NotNull default java.util.ArrayList<java.lang.Byte> toList()
asList()
default void addAllTo(@NotNull java.util.Collection<? super java.lang.Byte> collection)
collection
- collection to add to@NotNull default Indexable<java.lang.Byte> asIndexable()
Byte
values@NotNull default byte[] toArray()
default int addToArray(@NotNull byte[] 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 byte[] 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 int[] toIntArray()
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.lang.Iterable<java.lang.Integer> indexes()
intIndexes()
,
Range.indexes(int)
@NotNull default IntIndexable intIndexes()
indexes()
,
IntIndexable.rangeFromSize(int)
@NotNull default IntIndexable.Base asIntIndexable()
@NotNull default IntIndexable.Base asUnsignedIndexable()
@NotNull default byte[] toByteArray()
default void copyTo(@NotNull byte[] targetArray, int targetStart)
targetArray
- target byte arraytargetStart
- start index in targetdefault void copyTo(@NotNull byte[] targetArray, int targetStart, int sourceStart, int length)
targetArray
- target byte arraytargetStart
- start index in targetsourceStart
- start index in this indexablelength
- number of bytes to be copieddefault byte foldLeft(byte initialValue, @NotNull ByteOperator2 foldOperation)
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 argument@NotNull default java.lang.String toHexString()
toHexString(boolean)
@NotNull default java.lang.String toHexString(boolean uppercase)
uppercase
- if true
the returned string will use uppercase letters for non-decimal digitsfalse
it will use lowercase letters@NotNull default ByteIndexable withInsertedValueAt(int index, byte 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(byte)
@NotNull default ByteIndexable withAppendedValue(byte value)
value
- value to addwithInsertedValueAt(int, byte)
@NotNull default ByteIndexable withExchangedValueAt(int index, byte 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 ByteIndexable withRemovedValueAt(int index)
index
- index of the removed value (Pythonesque)@NotNull default ByteIndexable viewOp(@NotNull ByteOperator1 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 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 IntIndexable viewAsInt()
frozen()
on the result to create an independent copy
if this seems like a problem to you.@NotNull default IntIndexable viewAsUnsignedInt()
frozen()
on the result to create an independent copy
if this seems like a problem to you.@NotNull default ShortIndexable viewAsShort()
frozen()
on the result to create an independent copy
if this seems like a problem to you.@NotNull default ShortIndexable viewAsUnsignedShort()
frozen()
on the result to create an independent copy
if this seems like a problem to you.@NotNull default ByteIndexable withSwappedValuesAt(int index1, int index2)
index1
- index of the first value (Pythonesque)index2
- index of the second value (Pythonesque)@NotNull default ByteIndexable 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 BooleanIndexable viewAsBoolean(@NotNull BytePredicate1 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 static ByteIndexable.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 ByteIndexable.Base viewList(@NotNull java.util.List<? extends java.lang.Number> list, byte nullValue)
list
- list used as a base, required to have only non-null elementsnullValue
- value returned for null
elements in the list@NotNull static <T> ByteIndexable.Base viewList(@NotNull java.util.List<T> list, @NotNull ToByteFunction<? super T> extractor)
T
- element type of listlist
- generic listextractor
- extractor function which extracts a double from the elements of list
list
@NotNull static ByteIndexable.Base viewIndexable(@NotNull Indexable<? extends java.lang.Number> indexable)
indexable
- generic indexable with Number elements, required to have only non-null elements@NotNull static ByteIndexable.Base viewIndexable(@NotNull Indexable<? extends java.lang.Number> indexable, byte nullFallback)
indexable
- generic indexable with Number elementsnullFallback
- fallback for null
elements@NotNull static <T> ByteIndexable.Base viewIndexable(@NotNull Indexable<T> indexable, @NotNull ToByteFunction<? super T> extractor)
T
- element type of indexableindexable
- generic indexableextractor
- extractor function which extracts a byte from the elements of indexable
indexable
@NotNull static ByteIndexable.Base viewNumberArray(@NotNull java.lang.Number... array)
subSet(int, int)
.array
- array used as base, required to hold only non-null values@NotNull static ByteIndexable.Base viewArray(@NotNull byte... array)
viewArray(byte[], int, int)
.array
- array used as base@NotNull static ByteIndexable.Base viewArray(@NotNull byte[] 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> ByteIndexable.Base viewArray(@NotNull T[] array, @NotNull ToByteFunction<? super T> valueExtract)
T
- array element typearray
- viewed arrayvalueExtract
- converter from array elements to the byte values of this indexable@NotNull static ByteIndexable.Base singleton(byte value)
value
- single value@NotNull static ByteIndexable.Base init(int size, byte value)
size
- size of the returned indexablevalue
- value returned for each elementsize
with always the same element@NotNull static ByteIndexable.Base viewByIndex(int size, @NotNull IntToByteFunction1 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
@NotNull static ByteIndexable initByIndex(int size, @NotNull IntToByteFunction1 producer)
size
- size of the returned indexableproducer
- producer which is called with an index and expected to return the associated valueproducer
viewByIndex(int, IntToByteFunction1)
@NotNull static ByteIndexable.Base emptyIndexable()
@NotNull static java.lang.String toString(@NotNull ByteIndexable indexable)
indexable
- indexablestatic boolean equal(@NotNull ByteIndexable indexable1, @NotNull ByteIndexable 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 ByteIndexable 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 ByteIndexable indexable1, @NotNull ByteIndexable indexable2)
indexable1
- first indexableindexable2
- second indexable< 0>
if indexable1 < indxable2
,
0
if indexable1 == indexable2
, or
> 0
if indexable1 > indexable2
static int compareUnsigned(@NotNull ByteIndexable indexable1, @NotNull ByteIndexable indexable2)
indexable1
- first indexableindexable2
- second indexable< 0>
if indexable1 < indxable2
,
0
if indexable1 == indexable2
, or
> 0
if indexable1 > indexable2
static int hash(@NotNull ByteIndexable indexable)
indexable
- indexable for which the hash code is required@NotNull static ByteIndexable.Base withCachedHash(@NotNull ByteIndexable 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 ByteIndexable fromHexString(@NotNull java.lang.String hexString)
"cafebabe"
to
a byte indexable with the 4 bytes 0xCA, 0xFE, 0xBA, and 0cBE.hexString
- string with hexadecimal digits, 2 per bytejava.lang.IllegalArgumentException
- if the string has odd sizejava.lang.NumberFormatException
- if the string contains characters which doe't appear in hexcadecimal digitsbytesFromHexString(String)
@NotNull static byte[] bytesFromHexString(@NotNull java.lang.String hexString)
"cafebabe"
to
a byte array with the 4 bytes 0xCA, 0xFE, 0xBA, and 0cBE.hexString
- string with hexadecimal digits, 2 per bytejava.lang.IllegalArgumentException
- if the string has odd sizejava.lang.NumberFormatException
- if the string contains characters which doe't appear in hexcadecimal digitsdefault int nextMatch(int startIndex, @NotNull BytePredicate1 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 BytePredicate1 check)
check
- check to perform on elements of this indexable until true
true
,
-1
if nonedefault int previousMatch(int startIndex, @NotNull BytePredicate1 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 BytePredicate1 check)
check
- check to perform on elements of this indexable until true
true
,
-1
if none@NotNull default ByteIndexable 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.
default boolean isOrdered(@NotNull ByteOrdering order)
See isStrictlyOrdered(ByteOrdering) for a stricter alternative.
Prefer isOrdered() to check for natural ordering because it is faster.
order
- expected orderingtrue
if this indexable is sorted as defined by order
false
if notdefault boolean isOrdered()
See isStrictlyOrdered() for a stricter alternative.
true
if this indexable is sorted naturallyfalse
if notdefault boolean isStrictlyOrdered(@NotNull ByteOrdering order)
order
- expected orderingtrue
if this indexable is sorted as defined by order
false
if notdefault boolean isStrictlyOrdered()
true
if this indexable is sorted naturallyfalse
if notdefault int binarySearch(byte value)
natural ascending order
,
i.e. isOrdered(ByteOrdering) has to return true
for this ordering.
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(byte value, @NotNull ByteOrdering order)
order
,
i.e. isOrdered(ByteOrdering) 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 MutableByteIndexable ordered(@NotNull ByteOrdering order)
order
- sort order@NotNull default ByteIndexable.Base asBase()