Generate *Raw methods.
This commit is contained in:
@@ -435,6 +435,14 @@ public operator fun ShortArray.contains(element: Short): Boolean {
|
|||||||
return indexOf(element) >= 0
|
return indexOf(element) >= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns `true` if [element] is found in the collection.
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
public inline fun <T> Array<out T>.containsRaw(element: Any?): Boolean {
|
||||||
|
return contains<Any?>(element)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this collection.
|
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this collection.
|
||||||
*/
|
*/
|
||||||
@@ -1514,6 +1522,14 @@ public inline fun ShortArray.indexOfLast(predicate: (Short) -> Boolean): Int {
|
|||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns first index of [element], or -1 if the collection does not contain element.
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
public inline fun <T> Array<out T>.indexOfRaw(element: Any?): Int {
|
||||||
|
return indexOf<Any?>(element)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the last element.
|
* Returns the last element.
|
||||||
* @throws [NoSuchElementException] if the collection is empty.
|
* @throws [NoSuchElementException] if the collection is empty.
|
||||||
@@ -1828,6 +1844,14 @@ public fun ShortArray.lastIndexOf(element: Short): Int {
|
|||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns last index of [element], or -1 if the collection does not contain element.
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
public inline fun <T> Array<out T>.lastIndexOfRaw(element: Any?): Int {
|
||||||
|
return lastIndexOf<Any?>(element)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the last element, or `null` if the collection is empty.
|
* Returns the last element, or `null` if the collection is empty.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -61,6 +61,14 @@ public operator fun <T> Iterable<T>.contains(element: T): Boolean {
|
|||||||
return indexOf(element) >= 0
|
return indexOf(element) >= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns `true` if [element] is found in the collection.
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
public inline fun Iterable<*>.containsRaw(element: Any?): Boolean {
|
||||||
|
return contains<Any?>(element)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this collection.
|
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this collection.
|
||||||
*/
|
*/
|
||||||
@@ -302,6 +310,22 @@ public inline fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int {
|
|||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns first index of [element], or -1 if the collection does not contain element.
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
public inline fun Iterable<*>.indexOfRaw(element: Any?): Int {
|
||||||
|
return indexOf<Any?>(element)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns first index of [element], or -1 if the collection does not contain element.
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
public inline fun <T> List<T>.indexOfRaw(element: Any?): Int {
|
||||||
|
return (this as List<Any?>).indexOf(element)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the last element.
|
* Returns the last element.
|
||||||
* @throws [NoSuchElementException] if the collection is empty.
|
* @throws [NoSuchElementException] if the collection is empty.
|
||||||
@@ -382,6 +406,22 @@ public fun <T> Iterable<T>.lastIndexOf(element: T): Int {
|
|||||||
return lastIndex
|
return lastIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns last index of [element], or -1 if the collection does not contain element.
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
public inline fun Iterable<*>.lastIndexOfRaw(element: Any?): Int {
|
||||||
|
return lastIndexOf<Any?>(element)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns last index of [element], or -1 if the collection does not contain element.
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
public inline fun <T> List<T>.lastIndexOfRaw(element: Any?): Int {
|
||||||
|
return (this as List<Any?>).lastIndexOf(element)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the last element, or `null` if the collection is empty.
|
* Returns the last element, or `null` if the collection is empty.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -19,6 +19,14 @@ public operator fun <T> Sequence<T>.contains(element: T): Boolean {
|
|||||||
return indexOf(element) >= 0
|
return indexOf(element) >= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns `true` if [element] is found in the collection.
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
public inline fun Sequence<*>.containsRaw(element: Any?): Boolean {
|
||||||
|
return contains<Any?>(element)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this collection.
|
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this collection.
|
||||||
*/
|
*/
|
||||||
@@ -150,6 +158,14 @@ public inline fun <T> Sequence<T>.indexOfLast(predicate: (T) -> Boolean): Int {
|
|||||||
return lastIndex
|
return lastIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns first index of [element], or -1 if the collection does not contain element.
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
public inline fun Sequence<*>.indexOfRaw(element: Any?): Int {
|
||||||
|
return indexOf<Any?>(element)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the last element.
|
* Returns the last element.
|
||||||
* @throws [NoSuchElementException] if the collection is empty.
|
* @throws [NoSuchElementException] if the collection is empty.
|
||||||
@@ -195,6 +211,14 @@ public fun <T> Sequence<T>.lastIndexOf(element: T): Int {
|
|||||||
return lastIndex
|
return lastIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns last index of [element], or -1 if the collection does not contain element.
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
public inline fun Sequence<*>.lastIndexOfRaw(element: Any?): Int {
|
||||||
|
return lastIndexOf<Any?>(element)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the last element, or `null` if the collection is empty.
|
* Returns the last element, or `null` if the collection is empty.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -25,6 +25,16 @@ fun elements(): List<GenericFunction> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
templates add f("containsRaw(element: Any?)") {
|
||||||
|
only(Iterables, Sequences, ArraysOfObjects)
|
||||||
|
doc { "Returns `true` if [element] is found in the collection." }
|
||||||
|
receiverAsterisk(Iterables, Sequences) { true }
|
||||||
|
inline(true)
|
||||||
|
annotations("""@Suppress("NOTHING_TO_INLINE")""")
|
||||||
|
returns("Boolean")
|
||||||
|
body { "return contains<Any?>(element)" }
|
||||||
|
}
|
||||||
|
|
||||||
templates add f("indexOf(element: T)") {
|
templates add f("indexOf(element: T)") {
|
||||||
exclude(Strings, Lists) // has native implementation
|
exclude(Strings, Lists) // has native implementation
|
||||||
doc { "Returns first index of [element], or -1 if the collection does not contain element." }
|
doc { "Returns first index of [element], or -1 if the collection does not contain element." }
|
||||||
@@ -72,6 +82,17 @@ fun elements(): List<GenericFunction> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
templates add f("indexOfRaw(element: Any?)") {
|
||||||
|
only(Iterables, Sequences, ArraysOfObjects, Lists)
|
||||||
|
doc { "Returns first index of [element], or -1 if the collection does not contain element." }
|
||||||
|
receiverAsterisk(Iterables, Sequences) { true }
|
||||||
|
inline(true)
|
||||||
|
annotations("""@Suppress("NOTHING_TO_INLINE")""")
|
||||||
|
returns("Int")
|
||||||
|
body { "return indexOf<Any?>(element)" }
|
||||||
|
body(Lists) { "return (this as List<Any?>).indexOf(element)" }
|
||||||
|
}
|
||||||
|
|
||||||
templates add f("lastIndexOf(element: T)") {
|
templates add f("lastIndexOf(element: T)") {
|
||||||
exclude(Strings, Lists) // has native implementation
|
exclude(Strings, Lists) // has native implementation
|
||||||
doc { "Returns last index of [element], or -1 if the collection does not contain element." }
|
doc { "Returns last index of [element], or -1 if the collection does not contain element." }
|
||||||
@@ -120,6 +141,17 @@ fun elements(): List<GenericFunction> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
templates add f("lastIndexOfRaw(element: Any?)") {
|
||||||
|
only(Iterables, Sequences, ArraysOfObjects, Lists)
|
||||||
|
doc { "Returns last index of [element], or -1 if the collection does not contain element." }
|
||||||
|
receiverAsterisk(Iterables, Sequences) { true }
|
||||||
|
inline(true)
|
||||||
|
annotations("""@Suppress("NOTHING_TO_INLINE")""")
|
||||||
|
returns("Int")
|
||||||
|
body { "return lastIndexOf<Any?>(element)" }
|
||||||
|
body(Lists) { "return (this as List<Any?>).lastIndexOf(element)" }
|
||||||
|
}
|
||||||
|
|
||||||
templates add f("indexOfFirst(predicate: (T) -> Boolean)") {
|
templates add f("indexOfFirst(predicate: (T) -> Boolean)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user