Implement first, last & single extension functions for UArrays
This commit is contained in:
committed by
Ilya Gorbunov
parent
299fac8e2d
commit
92cd84682c
@@ -17,9 +17,9 @@ package kotlin.collections
|
||||
/**
|
||||
* Searches the array or the range of the array for the provided [element] using the binary search algorithm.
|
||||
* The array is expected to be sorted, otherwise the result is undefined.
|
||||
*
|
||||
*
|
||||
* If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
|
||||
*
|
||||
*
|
||||
* @return the index of the element, if it is contained in the array within the specified range;
|
||||
* otherwise, the inverted insertion point `(-insertion point - 1)`.
|
||||
* The insertion point is defined as the index at which the element should be inserted,
|
||||
@@ -49,9 +49,9 @@ public fun UIntArray.binarySearch(element: UInt, fromIndex: Int = 0, toIndex: In
|
||||
/**
|
||||
* Searches the array or the range of the array for the provided [element] using the binary search algorithm.
|
||||
* The array is expected to be sorted, otherwise the result is undefined.
|
||||
*
|
||||
*
|
||||
* If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
|
||||
*
|
||||
*
|
||||
* @return the index of the element, if it is contained in the array within the specified range;
|
||||
* otherwise, the inverted insertion point `(-insertion point - 1)`.
|
||||
* The insertion point is defined as the index at which the element should be inserted,
|
||||
@@ -81,9 +81,9 @@ public fun ULongArray.binarySearch(element: ULong, fromIndex: Int = 0, toIndex:
|
||||
/**
|
||||
* Searches the array or the range of the array for the provided [element] using the binary search algorithm.
|
||||
* The array is expected to be sorted, otherwise the result is undefined.
|
||||
*
|
||||
*
|
||||
* If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
|
||||
*
|
||||
*
|
||||
* @return the index of the element, if it is contained in the array within the specified range;
|
||||
* otherwise, the inverted insertion point `(-insertion point - 1)`.
|
||||
* The insertion point is defined as the index at which the element should be inserted,
|
||||
@@ -113,9 +113,9 @@ public fun UByteArray.binarySearch(element: UByte, fromIndex: Int = 0, toIndex:
|
||||
/**
|
||||
* Searches the array or the range of the array for the provided [element] using the binary search algorithm.
|
||||
* The array is expected to be sorted, otherwise the result is undefined.
|
||||
*
|
||||
*
|
||||
* If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
|
||||
*
|
||||
*
|
||||
* @return the index of the element, if it is contained in the array within the specified range;
|
||||
* otherwise, the inverted insertion point `(-insertion point - 1)`.
|
||||
* The insertion point is defined as the index at which the element should be inserted,
|
||||
@@ -176,4 +176,5 @@ public fun UByteArray.fill(element: UByte, fromIndex: Int = 0, toIndex: Int = si
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun UShortArray.fill(element: UShort, fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
storage.fill(element.toShort(), fromIndex, toIndex)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user