renamed @includeFunction to @includeFunctionBody to be more clear that the function definition itself won't be included into the kdocs

This commit is contained in:
James Strachan
2012-04-02 15:25:15 +01:00
parent 4d37672809
commit 3fb74d3e69
15 changed files with 88 additions and 88 deletions
@@ -13,7 +13,7 @@ import java.util.*
/**
* Returns a new List containing the results of applying the given function to each element in this collection
*
* @includeFunction ../../test/CollectionTest.kt map
* @includeFunctionBody ../../test/CollectionTest.kt map
*/
public inline fun <T, R> Array<T>.map(transform : (T) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform)
@@ -8,7 +8,7 @@ import java.util.*
/**
* Returns *true* if any elements match the given *predicate*
*
* @includeFunction ../../test/CollectionTest.kt any
* @includeFunctionBody ../../test/CollectionTest.kt any
*/
public inline fun <T> Array<T>.any(predicate: (T) -> Boolean) : Boolean {
for (element in this) if (predicate(element)) return true
@@ -18,7 +18,7 @@ public inline fun <T> Array<T>.any(predicate: (T) -> Boolean) : Boolean {
/**
* Returns *true* if all elements match the given *predicate*
*
* @includeFunction ../../test/CollectionTest.kt all
* @includeFunctionBody ../../test/CollectionTest.kt all
*/
public inline fun <T> Array<T>.all(predicate: (T) -> Boolean) : Boolean {
for (element in this) if (!predicate(element)) return false
@@ -28,7 +28,7 @@ public inline fun <T> Array<T>.all(predicate: (T) -> Boolean) : Boolean {
/**
* Returns the number of elements which match the given *predicate*
*
* @includeFunction ../../test/CollectionTest.kt count
* @includeFunctionBody ../../test/CollectionTest.kt count
*/
public inline fun <T> Array<T>.count(predicate: (T) -> Boolean) : Int {
var count = 0
@@ -39,7 +39,7 @@ public inline fun <T> Array<T>.count(predicate: (T) -> Boolean) : Int {
/**
* Returns the first element which matches the given *predicate* or *null* if none matched
*
* @includeFunction ../../test/CollectionTest.kt find
* @includeFunctionBody ../../test/CollectionTest.kt find
*/
public inline fun <T> Array<T>.find(predicate: (T) -> Boolean) : T? {
for (element in this) if (predicate(element)) return element
@@ -49,7 +49,7 @@ public inline fun <T> Array<T>.find(predicate: (T) -> Boolean) : T? {
/**
* Filters all elements which match the given predicate into the given list
*
* @includeFunction ../../test/CollectionTest.kt filterIntoLinkedList
* @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList
*/
public inline fun <T, C: Collection<in T>> Array<T>.filterTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element)
@@ -59,7 +59,7 @@ public inline fun <T, C: Collection<in T>> Array<T>.filterTo(result: C, predicat
/**
* Returns a list containing all elements which do not match the given *predicate*
*
* @includeFunction ../../test/CollectionTest.kt filterNotIntoLinkedList
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/
public inline fun <T, L: List<in T>> Array<T>.filterNotTo(result: L, predicate: (T) -> Boolean) : L {
for (element in this) if (!predicate(element)) result.add(element)
@@ -69,7 +69,7 @@ public inline fun <T, L: List<in T>> Array<T>.filterNotTo(result: L, predicate:
/**
* Filters all non-*null* elements into the given list
*
* @includeFunction ../../test/CollectionTest.kt filterNotNullIntoLinkedList
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/
public inline fun <T, L: List<in T>> Array<T?>?.filterNotNullTo(result: L) : L {
if (this != null) {
@@ -81,7 +81,7 @@ public inline fun <T, L: List<in T>> Array<T?>?.filterNotNullTo(result: L) : L {
/**
* Returns the result of transforming each element to one or more values which are concatenated together into a single list
*
* @includeFunction ../../test/CollectionTest.kt flatMap
* @includeFunctionBody ../../test/CollectionTest.kt flatMap
*/
public inline fun <T, R> Array<T>.flatMapTo(result: Collection<R>, transform: (T) -> Collection<R>) : Collection<R> {
for (element in this) {
@@ -96,14 +96,14 @@ public inline fun <T, R> Array<T>.flatMapTo(result: Collection<R>, transform: (T
/**
* Performs the given *operation* on each element
*
* @includeFunction ../../test/CollectionTest.kt forEach
* @includeFunctionBody ../../test/CollectionTest.kt forEach
*/
public inline fun <T> Array<T>.forEach(operation: (T) -> Unit) : Unit = for (element in this) operation(element)
/**
* Folds all elements from from left to right with the *initial* value to perform the operation on sequential pairs of elements
*
* @includeFunction ../../test/CollectionTest.kt fold
* @includeFunctionBody ../../test/CollectionTest.kt fold
*/
public inline fun <T> Array<T>.fold(initial: T, operation: (T, T) -> T): T {
var answer = initial
@@ -114,14 +114,14 @@ public inline fun <T> Array<T>.fold(initial: T, operation: (T, T) -> T): T {
/**
* Folds all elements from right to left with the *initial* value to perform the operation on sequential pairs of elements
*
* @includeFunction ../../test/CollectionTest.kt foldRight
* @includeFunctionBody ../../test/CollectionTest.kt foldRight
*/
public inline fun <T> Array<T>.foldRight(initial: T, operation: (T, T) -> T): T = reverse().fold(initial, operation)
/**
* Transforms each element using the result as the key in a map to group elements by the result
*
* @includeFunction ../../test/CollectionTest.kt groupBy
* @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/
public inline fun <T, K> Array<T>.groupBy(result: Map<K, List<T>> = HashMap<K, List<T>>(), toKey: (T) -> K) : Map<K, List<T>> {
for (element in this) {
@@ -141,7 +141,7 @@ public inline fun <T, L: List<in T>> Array<T>.takeWhileTo(result: L, predicate:
/**
* Reverses the order the elements into a list
*
* @includeFunction ../../test/CollectionTest.kt reverse
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun <T> Array<T>.reverse() : List<T> {
val answer = LinkedList<T>()
@@ -17,35 +17,35 @@ import java.util.List
/**
* Returns a list containing all elements which match the given *predicate*
*
* @includeFunction ../../test/CollectionTest.kt filter
* @includeFunctionBody ../../test/CollectionTest.kt filter
*/
public inline fun <T> Array<T>.filter(predicate: (T) -> Boolean) : List<T> = filterTo(ArrayList<T>(), predicate)
/**
* Returns a list containing all elements which do not match the given predicate
*
* @includeFunction ../../test/CollectionTest.kt filterNot
* @includeFunctionBody ../../test/CollectionTest.kt filterNot
*/
public inline fun <T> Array<T>.filterNot(predicate: (T)-> Boolean) : List<T> = filterNotTo(ArrayList<T>(), predicate)
/**
* Returns a list containing all the non-*null* elements
*
* @includeFunction ../../test/CollectionTest.kt filterNotNull
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNull
*/
public inline fun <T> Array<T?>?.filterNotNull() : List<T> = filterNotNullTo<T, ArrayList<T>>(java.util.ArrayList<T>())
/**
* Returns the result of transforming each element to one or more values which are concatenated together into a single collection
*
* @includeFunction ../../test/CollectionTest.kt flatMap
* @includeFunctionBody ../../test/CollectionTest.kt flatMap
*/
public inline fun <T, R> Array<T>.flatMap(transform: (T)-> Collection<R>) : Collection<R> = flatMapTo(ArrayList<R>(), transform)
/**
* Returns a list containing the first *n* elements
*
* @includeFunction ../../test/CollectionTest.kt take
* @includeFunctionBody ../../test/CollectionTest.kt take
*/
public inline fun <T> Array<T>.take(n: Int): List<T> {
fun countTo(n: Int): (T) -> Boolean {
@@ -58,14 +58,14 @@ public inline fun <T> Array<T>.take(n: Int): List<T> {
/**
* Returns a list containing the first elements that satisfy the given *predicate*
*
* @includeFunction ../../test/CollectionTest.kt takeWhile
* @includeFunctionBody ../../test/CollectionTest.kt takeWhile
*/
public inline fun <T> Array<T>.takeWhile(predicate: (T) -> Boolean): List<T> = takeWhileTo(ArrayList<T>(), predicate)
/**
* Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied
*
* @includeFunction ../../test/CollectionTest.kt join
* @includeFunctionBody ../../test/CollectionTest.kt join
*/
public inline fun <T> Array<T>.join(separator: String = ", ", prefix: String = "", postfix: String = "") : String {
val buffer = StringBuilder(prefix)
@@ -13,7 +13,7 @@ import java.util.*
/**
* Returns a new List containing the results of applying the given function to each element in this collection
*
* @includeFunction ../../test/CollectionTest.kt map
* @includeFunctionBody ../../test/CollectionTest.kt map
*/
public inline fun <T, R> java.lang.Iterable<T>.map(transform : (T) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(), transform)
@@ -6,7 +6,7 @@ import java.util.*
/**
* Returns *true* if any elements match the given *predicate*
*
* @includeFunction ../../test/CollectionTest.kt any
* @includeFunctionBody ../../test/CollectionTest.kt any
*/
public inline fun <T> java.util.Iterator<T>.any(predicate: (T) -> Boolean) : Boolean {
for (element in this) if (predicate(element)) return true
@@ -16,7 +16,7 @@ public inline fun <T> java.util.Iterator<T>.any(predicate: (T) -> Boolean) : Boo
/**
* Returns *true* if all elements match the given *predicate*
*
* @includeFunction ../../test/CollectionTest.kt all
* @includeFunctionBody ../../test/CollectionTest.kt all
*/
public inline fun <T> java.util.Iterator<T>.all(predicate: (T) -> Boolean) : Boolean {
for (element in this) if (!predicate(element)) return false
@@ -26,7 +26,7 @@ public inline fun <T> java.util.Iterator<T>.all(predicate: (T) -> Boolean) : Boo
/**
* Returns the number of elements which match the given *predicate*
*
* @includeFunction ../../test/CollectionTest.kt count
* @includeFunctionBody ../../test/CollectionTest.kt count
*/
public inline fun <T> java.util.Iterator<T>.count(predicate: (T) -> Boolean) : Int {
var count = 0
@@ -37,7 +37,7 @@ public inline fun <T> java.util.Iterator<T>.count(predicate: (T) -> Boolean) : I
/**
* Returns the first element which matches the given *predicate* or *null* if none matched
*
* @includeFunction ../../test/CollectionTest.kt find
* @includeFunctionBody ../../test/CollectionTest.kt find
*/
public inline fun <T> java.util.Iterator<T>.find(predicate: (T) -> Boolean) : T? {
for (element in this) if (predicate(element)) return element
@@ -47,7 +47,7 @@ public inline fun <T> java.util.Iterator<T>.find(predicate: (T) -> Boolean) : T?
/**
* Filters all elements which match the given predicate into the given list
*
* @includeFunction ../../test/CollectionTest.kt filterIntoLinkedList
* @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList
*/
public inline fun <T, C: Collection<in T>> java.util.Iterator<T>.filterTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element)
@@ -57,7 +57,7 @@ public inline fun <T, C: Collection<in T>> java.util.Iterator<T>.filterTo(result
/**
* Returns a list containing all elements which do not match the given *predicate*
*
* @includeFunction ../../test/CollectionTest.kt filterNotIntoLinkedList
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/
public inline fun <T, L: List<in T>> java.util.Iterator<T>.filterNotTo(result: L, predicate: (T) -> Boolean) : L {
for (element in this) if (!predicate(element)) result.add(element)
@@ -67,7 +67,7 @@ public inline fun <T, L: List<in T>> java.util.Iterator<T>.filterNotTo(result: L
/**
* Filters all non-*null* elements into the given list
*
* @includeFunction ../../test/CollectionTest.kt filterNotNullIntoLinkedList
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/
public inline fun <T, L: List<in T>> java.util.Iterator<T?>?.filterNotNullTo(result: L) : L {
if (this != null) {
@@ -79,7 +79,7 @@ public inline fun <T, L: List<in T>> java.util.Iterator<T?>?.filterNotNullTo(res
/**
* Returns the result of transforming each element to one or more values which are concatenated together into a single list
*
* @includeFunction ../../test/CollectionTest.kt flatMap
* @includeFunctionBody ../../test/CollectionTest.kt flatMap
*/
public inline fun <T, R> java.util.Iterator<T>.flatMapTo(result: Collection<R>, transform: (T) -> Collection<R>) : Collection<R> {
for (element in this) {
@@ -94,14 +94,14 @@ public inline fun <T, R> java.util.Iterator<T>.flatMapTo(result: Collection<R>,
/**
* Performs the given *operation* on each element
*
* @includeFunction ../../test/CollectionTest.kt forEach
* @includeFunctionBody ../../test/CollectionTest.kt forEach
*/
public inline fun <T> java.util.Iterator<T>.forEach(operation: (T) -> Unit) : Unit = for (element in this) operation(element)
/**
* Folds all elements from from left to right with the *initial* value to perform the operation on sequential pairs of elements
*
* @includeFunction ../../test/CollectionTest.kt fold
* @includeFunctionBody ../../test/CollectionTest.kt fold
*/
public inline fun <T> java.util.Iterator<T>.fold(initial: T, operation: (T, T) -> T): T {
var answer = initial
@@ -112,14 +112,14 @@ public inline fun <T> java.util.Iterator<T>.fold(initial: T, operation: (T, T) -
/**
* Folds all elements from right to left with the *initial* value to perform the operation on sequential pairs of elements
*
* @includeFunction ../../test/CollectionTest.kt foldRight
* @includeFunctionBody ../../test/CollectionTest.kt foldRight
*/
public inline fun <T> java.util.Iterator<T>.foldRight(initial: T, operation: (T, T) -> T): T = reverse().fold(initial, operation)
/**
* Transforms each element using the result as the key in a map to group elements by the result
*
* @includeFunction ../../test/CollectionTest.kt groupBy
* @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/
public inline fun <T, K> java.util.Iterator<T>.groupBy(result: Map<K, List<T>> = HashMap<K, List<T>>(), toKey: (T) -> K) : Map<K, List<T>> {
for (element in this) {
@@ -139,7 +139,7 @@ public inline fun <T, L: List<in T>> java.util.Iterator<T>.takeWhileTo(result: L
/**
* Reverses the order the elements into a list
*
* @includeFunction ../../test/CollectionTest.kt reverse
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun <T> java.util.Iterator<T>.reverse() : List<T> {
val answer = LinkedList<T>()
@@ -13,7 +13,7 @@ import java.util.*
/**
* Returns a new List containing the results of applying the given function to each element in this collection
*
* @includeFunction ../../test/CollectionTest.kt map
* @includeFunctionBody ../../test/CollectionTest.kt map
*/
public inline fun <T, R> Iterable<T>.map(transform : (T) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(), transform)
@@ -8,7 +8,7 @@ import java.util.*
/**
* Returns *true* if any elements match the given *predicate*
*
* @includeFunction ../../test/CollectionTest.kt any
* @includeFunctionBody ../../test/CollectionTest.kt any
*/
public inline fun <T> Iterable<T>.any(predicate: (T) -> Boolean) : Boolean {
for (element in this) if (predicate(element)) return true
@@ -18,7 +18,7 @@ public inline fun <T> Iterable<T>.any(predicate: (T) -> Boolean) : Boolean {
/**
* Returns *true* if all elements match the given *predicate*
*
* @includeFunction ../../test/CollectionTest.kt all
* @includeFunctionBody ../../test/CollectionTest.kt all
*/
public inline fun <T> Iterable<T>.all(predicate: (T) -> Boolean) : Boolean {
for (element in this) if (!predicate(element)) return false
@@ -28,7 +28,7 @@ public inline fun <T> Iterable<T>.all(predicate: (T) -> Boolean) : Boolean {
/**
* Returns the number of elements which match the given *predicate*
*
* @includeFunction ../../test/CollectionTest.kt count
* @includeFunctionBody ../../test/CollectionTest.kt count
*/
public inline fun <T> Iterable<T>.count(predicate: (T) -> Boolean) : Int {
var count = 0
@@ -39,7 +39,7 @@ public inline fun <T> Iterable<T>.count(predicate: (T) -> Boolean) : Int {
/**
* Returns the first element which matches the given *predicate* or *null* if none matched
*
* @includeFunction ../../test/CollectionTest.kt find
* @includeFunctionBody ../../test/CollectionTest.kt find
*/
public inline fun <T> Iterable<T>.find(predicate: (T) -> Boolean) : T? {
for (element in this) if (predicate(element)) return element
@@ -49,7 +49,7 @@ public inline fun <T> Iterable<T>.find(predicate: (T) -> Boolean) : T? {
/**
* Filters all elements which match the given predicate into the given list
*
* @includeFunction ../../test/CollectionTest.kt filterIntoLinkedList
* @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList
*/
public inline fun <T, C: Collection<in T>> Iterable<T>.filterTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element)
@@ -59,7 +59,7 @@ public inline fun <T, C: Collection<in T>> Iterable<T>.filterTo(result: C, predi
/**
* Returns a list containing all elements which do not match the given *predicate*
*
* @includeFunction ../../test/CollectionTest.kt filterNotIntoLinkedList
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/
public inline fun <T, L: List<in T>> Iterable<T>.filterNotTo(result: L, predicate: (T) -> Boolean) : L {
for (element in this) if (!predicate(element)) result.add(element)
@@ -69,7 +69,7 @@ public inline fun <T, L: List<in T>> Iterable<T>.filterNotTo(result: L, predicat
/**
* Filters all non-*null* elements into the given list
*
* @includeFunction ../../test/CollectionTest.kt filterNotNullIntoLinkedList
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/
public inline fun <T, L: List<in T>> Iterable<T?>?.filterNotNullTo(result: L) : L {
if (this != null) {
@@ -81,7 +81,7 @@ public inline fun <T, L: List<in T>> Iterable<T?>?.filterNotNullTo(result: L) :
/**
* Returns the result of transforming each element to one or more values which are concatenated together into a single list
*
* @includeFunction ../../test/CollectionTest.kt flatMap
* @includeFunctionBody ../../test/CollectionTest.kt flatMap
*/
public inline fun <T, R> Iterable<T>.flatMapTo(result: Collection<R>, transform: (T) -> Collection<R>) : Collection<R> {
for (element in this) {
@@ -96,14 +96,14 @@ public inline fun <T, R> Iterable<T>.flatMapTo(result: Collection<R>, transform:
/**
* Performs the given *operation* on each element
*
* @includeFunction ../../test/CollectionTest.kt forEach
* @includeFunctionBody ../../test/CollectionTest.kt forEach
*/
public inline fun <T> Iterable<T>.forEach(operation: (T) -> Unit) : Unit = for (element in this) operation(element)
/**
* Folds all elements from from left to right with the *initial* value to perform the operation on sequential pairs of elements
*
* @includeFunction ../../test/CollectionTest.kt fold
* @includeFunctionBody ../../test/CollectionTest.kt fold
*/
public inline fun <T> Iterable<T>.fold(initial: T, operation: (T, T) -> T): T {
var answer = initial
@@ -114,14 +114,14 @@ public inline fun <T> Iterable<T>.fold(initial: T, operation: (T, T) -> T): T {
/**
* Folds all elements from right to left with the *initial* value to perform the operation on sequential pairs of elements
*
* @includeFunction ../../test/CollectionTest.kt foldRight
* @includeFunctionBody ../../test/CollectionTest.kt foldRight
*/
public inline fun <T> Iterable<T>.foldRight(initial: T, operation: (T, T) -> T): T = reverse().fold(initial, operation)
/**
* Transforms each element using the result as the key in a map to group elements by the result
*
* @includeFunction ../../test/CollectionTest.kt groupBy
* @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/
public inline fun <T, K> Iterable<T>.groupBy(result: Map<K, List<T>> = HashMap<K, List<T>>(), toKey: (T) -> K) : Map<K, List<T>> {
for (element in this) {
@@ -141,7 +141,7 @@ public inline fun <T, L: List<in T>> Iterable<T>.takeWhileTo(result: L, predicat
/**
* Reverses the order the elements into a list
*
* @includeFunction ../../test/CollectionTest.kt reverse
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun <T> Iterable<T>.reverse() : List<T> {
val answer = LinkedList<T>()
@@ -17,35 +17,35 @@ import java.util.List
/**
* Returns a list containing all elements which match the given *predicate*
*
* @includeFunction ../../test/CollectionTest.kt filter
* @includeFunctionBody ../../test/CollectionTest.kt filter
*/
public inline fun <T> Iterable<T>.filter(predicate: (T) -> Boolean) : List<T> = filterTo(ArrayList<T>(), predicate)
/**
* Returns a list containing all elements which do not match the given predicate
*
* @includeFunction ../../test/CollectionTest.kt filterNot
* @includeFunctionBody ../../test/CollectionTest.kt filterNot
*/
public inline fun <T> Iterable<T>.filterNot(predicate: (T)-> Boolean) : List<T> = filterNotTo(ArrayList<T>(), predicate)
/**
* Returns a list containing all the non-*null* elements
*
* @includeFunction ../../test/CollectionTest.kt filterNotNull
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNull
*/
public inline fun <T> Iterable<T?>?.filterNotNull() : List<T> = filterNotNullTo<T, ArrayList<T>>(java.util.ArrayList<T>())
/**
* Returns the result of transforming each element to one or more values which are concatenated together into a single collection
*
* @includeFunction ../../test/CollectionTest.kt flatMap
* @includeFunctionBody ../../test/CollectionTest.kt flatMap
*/
public inline fun <T, R> Iterable<T>.flatMap(transform: (T)-> Collection<R>) : Collection<R> = flatMapTo(ArrayList<R>(), transform)
/**
* Returns a list containing the first *n* elements
*
* @includeFunction ../../test/CollectionTest.kt take
* @includeFunctionBody ../../test/CollectionTest.kt take
*/
public inline fun <T> Iterable<T>.take(n: Int): List<T> {
fun countTo(n: Int): (T) -> Boolean {
@@ -58,14 +58,14 @@ public inline fun <T> Iterable<T>.take(n: Int): List<T> {
/**
* Returns a list containing the first elements that satisfy the given *predicate*
*
* @includeFunction ../../test/CollectionTest.kt takeWhile
* @includeFunctionBody ../../test/CollectionTest.kt takeWhile
*/
public inline fun <T> Iterable<T>.takeWhile(predicate: (T) -> Boolean): List<T> = takeWhileTo(ArrayList<T>(), predicate)
/**
* Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied
*
* @includeFunction ../../test/CollectionTest.kt join
* @includeFunctionBody ../../test/CollectionTest.kt join
*/
public inline fun <T> Iterable<T>.join(separator: String = ", ", prefix: String = "", postfix: String = "") : String {
val buffer = StringBuilder(prefix)