Generate *Raw methods.

This commit is contained in:
Ilya Gorbunov
2015-10-15 19:59:54 +03:00
parent 8aed39d9bb
commit 683bc4bd01
4 changed files with 120 additions and 0 deletions
+24
View File
@@ -435,6 +435,14 @@ public operator fun ShortArray.contains(element: Short): Boolean {
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.
*/
@@ -1514,6 +1522,14 @@ public inline fun ShortArray.indexOfLast(predicate: (Short) -> Boolean): Int {
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.
* @throws [NoSuchElementException] if the collection is empty.
@@ -1828,6 +1844,14 @@ public fun ShortArray.lastIndexOf(element: Short): Int {
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.
*/
@@ -61,6 +61,14 @@ public operator fun <T> Iterable<T>.contains(element: T): Boolean {
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.
*/
@@ -302,6 +310,22 @@ public inline fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int {
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.
* @throws [NoSuchElementException] if the collection is empty.
@@ -382,6 +406,22 @@ public fun <T> Iterable<T>.lastIndexOf(element: T): Int {
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.
*/
@@ -19,6 +19,14 @@ public operator fun <T> Sequence<T>.contains(element: T): Boolean {
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.
*/
@@ -150,6 +158,14 @@ public inline fun <T> Sequence<T>.indexOfLast(predicate: (T) -> Boolean): Int {
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.
* @throws [NoSuchElementException] if the collection is empty.
@@ -195,6 +211,14 @@ public fun <T> Sequence<T>.lastIndexOf(element: T): Int {
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.
*/