From d4d177c0edd56fb0f7bf856bd1d6f72f717219f7 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Fri, 30 Mar 2012 13:38:22 +0400 Subject: [PATCH] added 'public' annotation to library functions --- .../src/generated/ArraysFromJavaIterables.kt | 40 +++++++++---------- .../generated/ArraysFromJavaIterablesLazy.kt | 14 +++---- .../JavaUtilIteratorsFromJavaIterables.kt | 40 +++++++++---------- .../generated/StandardFromJavaIterables.kt | 40 +++++++++---------- .../StandardFromJavaIterablesLazy.kt | 14 +++---- libraries/stdlib/src/kotlin/Arrays.kt | 2 +- libraries/stdlib/src/kotlin/Iterators.kt | 20 +++++----- libraries/stdlib/src/kotlin/JavaIterables.kt | 40 +++++++++---------- .../stdlib/src/kotlin/JavaIterablesLazy.kt | 14 +++---- .../src/kotlin/support/AbstractIterator.kt | 12 +++--- 10 files changed, 118 insertions(+), 118 deletions(-) diff --git a/libraries/stdlib/src/generated/ArraysFromJavaIterables.kt b/libraries/stdlib/src/generated/ArraysFromJavaIterables.kt index 40cfd14f442..b56f7307b5c 100644 --- a/libraries/stdlib/src/generated/ArraysFromJavaIterables.kt +++ b/libraries/stdlib/src/generated/ArraysFromJavaIterables.kt @@ -10,7 +10,7 @@ import java.util.* * * @includeFunction ../../test/CollectionTest.kt any */ -inline fun Array.any(predicate: (T) -> Boolean) : Boolean { +public inline fun Array.any(predicate: (T) -> Boolean) : Boolean { for (element in this) if (predicate(element)) return true return false } @@ -20,7 +20,7 @@ inline fun Array.any(predicate: (T) -> Boolean) : Boolean { * * @includeFunction ../../test/CollectionTest.kt all */ -inline fun Array.all(predicate: (T) -> Boolean) : Boolean { +public inline fun Array.all(predicate: (T) -> Boolean) : Boolean { for (element in this) if (!predicate(element)) return false return true } @@ -30,7 +30,7 @@ inline fun Array.all(predicate: (T) -> Boolean) : Boolean { * * @includeFunction ../../test/CollectionTest.kt count */ -inline fun Array.count(predicate: (T) -> Boolean) : Int { +public inline fun Array.count(predicate: (T) -> Boolean) : Int { var count = 0 for (element in this) if (predicate(element)) count++ return count @@ -41,7 +41,7 @@ inline fun Array.count(predicate: (T) -> Boolean) : Int { * * @includeFunction ../../test/CollectionTest.kt find */ -inline fun Array.find(predicate: (T) -> Boolean) : T? { +public inline fun Array.find(predicate: (T) -> Boolean) : T? { for (element in this) if (predicate(element)) return element return null } @@ -51,7 +51,7 @@ inline fun Array.find(predicate: (T) -> Boolean) : T? { * * @includeFunction ../../test/CollectionTest.kt filterIntoLinkedList */ -inline fun > Array.filterTo(result: C, predicate: (T) -> Boolean) : C { +public inline fun > Array.filterTo(result: C, predicate: (T) -> Boolean) : C { for (element in this) if (predicate(element)) result.add(element) return result } @@ -61,7 +61,7 @@ inline fun > Array.filterTo(result: C, predicate: (T) * * @includeFunction ../../test/CollectionTest.kt filterNotIntoLinkedList */ -inline fun > Array.filterNotTo(result: L, predicate: (T) -> Boolean) : L { +public inline fun > Array.filterNotTo(result: L, predicate: (T) -> Boolean) : L { for (element in this) if (!predicate(element)) result.add(element) return result } @@ -71,7 +71,7 @@ inline fun > Array.filterNotTo(result: L, predicate: (T) -> * * @includeFunction ../../test/CollectionTest.kt filterNotNullIntoLinkedList */ -inline fun > Array?.filterNotNullTo(result: L) : L { +public inline fun > Array?.filterNotNullTo(result: L) : L { if (this != null) { for (element in this) if (element != null) result.add(element) } @@ -83,7 +83,7 @@ inline fun > Array?.filterNotNullTo(result: L) : L { * * @includeFunction ../../test/CollectionTest.kt flatMap */ -inline fun Array.flatMapTo(result: Collection, transform: (T) -> Collection) : Collection { +public inline fun Array.flatMapTo(result: Collection, transform: (T) -> Collection) : Collection { for (element in this) { val list = transform(element) if (list != null) { @@ -98,14 +98,14 @@ inline fun Array.flatMapTo(result: Collection, transform: (T) -> Co * * @includeFunction ../../test/CollectionTest.kt forEach */ -inline fun Array.forEach(operation: (T) -> Unit) = for (element in this) operation(element) +public inline fun Array.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 */ -inline fun Array.fold(initial: T, operation: (T, T) -> T): T { +public inline fun Array.fold(initial: T, operation: (T, T) -> T): T { var answer = initial for (element in this) answer = operation(answer, element) return answer @@ -116,14 +116,14 @@ inline fun Array.fold(initial: T, operation: (T, T) -> T): T { * * @includeFunction ../../test/CollectionTest.kt foldRight */ -inline fun Array.foldRight(initial: T, operation: (T, T) -> T): T = reverse().fold(initial, operation) +public inline fun Array.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 */ -inline fun Array.groupBy(result: Map> = HashMap>(), toKey: (T) -> K) : Map> { +public inline fun Array.groupBy(result: Map> = HashMap>(), toKey: (T) -> K) : Map> { for (element in this) { val key = toKey(element) val list = result.getOrPut(key) { ArrayList() } @@ -133,7 +133,7 @@ inline fun Array.groupBy(result: Map> = HashMap> } /** Returns a list containing the first elements that satisfy the given *predicate* */ -inline fun > Array.takeWhileTo(result: L, predicate: (T) -> Boolean) : L { +public inline fun > Array.takeWhileTo(result: L, predicate: (T) -> Boolean) : L { for (element in this) if (predicate(element)) result.add(element) else break return result } @@ -143,33 +143,33 @@ inline fun > Array.takeWhileTo(result: L, predicate: (T) -> * * @includeFunction ../../test/CollectionTest.kt reverse */ -inline fun Array.reverse() : List { +public inline fun Array.reverse() : List { val answer = LinkedList() for (element in this) answer.addFirst(element) return answer } /** Copies all elements into the given collection */ -inline fun > Array.to(result: C) : C { +public inline fun > Array.to(result: C) : C { for (element in this) result.add(element) return result } /** Copies all elements into a [[LinkedList]] */ -inline fun Array.toLinkedList() : LinkedList = to(LinkedList()) +public inline fun Array.toLinkedList() : LinkedList = to(LinkedList()) /** Copies all elements into a [[List]] */ -inline fun Array.toList() : List = to(ArrayList()) +public inline fun Array.toList() : List = to(ArrayList()) /** Copies all elements into a [[Set]] */ -inline fun Array.toSet() : Set = to(HashSet()) +public inline fun Array.toSet() : Set = to(HashSet()) /** Copies all elements into a [[SortedSet]] */ -inline fun Array.toSortedSet() : SortedSet = to(TreeSet()) +public inline fun Array.toSortedSet() : SortedSet = to(TreeSet()) /** TODO figure out necessary variance/generics ninja stuff... :) -inline fun Array.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List { +public inline fun Array.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List { val answer = this.toList() answer.sort(transform) return answer diff --git a/libraries/stdlib/src/generated/ArraysFromJavaIterablesLazy.kt b/libraries/stdlib/src/generated/ArraysFromJavaIterablesLazy.kt index 63b3fefa7fd..cf12eae38a9 100644 --- a/libraries/stdlib/src/generated/ArraysFromJavaIterablesLazy.kt +++ b/libraries/stdlib/src/generated/ArraysFromJavaIterablesLazy.kt @@ -19,35 +19,35 @@ import java.util.List * * @includeFunction ../../test/CollectionTest.kt filter */ -inline fun Array.filter(predicate: (T) -> Boolean) : List = filterTo(ArrayList(), predicate) +public inline fun Array.filter(predicate: (T) -> Boolean) : List = filterTo(ArrayList(), predicate) /** * Returns a list containing all elements which do not match the given predicate * * @includeFunction ../../test/CollectionTest.kt filterNot */ -inline fun Array.filterNot(predicate: (T)-> Boolean) : List = filterNotTo(ArrayList(), predicate) +public inline fun Array.filterNot(predicate: (T)-> Boolean) : List = filterNotTo(ArrayList(), predicate) /** * Returns a list containing all the non-*null* elements * * @includeFunction ../../test/CollectionTest.kt filterNotNull */ -inline fun Array?.filterNotNull() : List = filterNotNullTo>(java.util.ArrayList()) +public inline fun Array?.filterNotNull() : List = filterNotNullTo>(java.util.ArrayList()) /** * 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 */ -inline fun Array.flatMap(transform: (T)-> Collection) : Collection = flatMapTo(ArrayList(), transform) +public inline fun Array.flatMap(transform: (T)-> Collection) : Collection = flatMapTo(ArrayList(), transform) /** * Returns a list containing the first *n* elements * * @includeFunction ../../test/CollectionTest.kt take */ -inline fun Array.take(n: Int): List { +public inline fun Array.take(n: Int): List { fun countTo(n: Int): (T) -> Boolean { var count = 0 return { ++count; count <= n } @@ -60,14 +60,14 @@ inline fun Array.take(n: Int): List { * * @includeFunction ../../test/CollectionTest.kt takeWhile */ -inline fun Array.takeWhile(predicate: (T) -> Boolean): List = takeWhileTo(ArrayList(), predicate) +public inline fun Array.takeWhile(predicate: (T) -> Boolean): List = takeWhileTo(ArrayList(), 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 */ -inline fun Array.join(separator: String = ", ", prefix: String = "", postfix: String = "") : String { +public inline fun Array.join(separator: String = ", ", prefix: String = "", postfix: String = "") : String { val buffer = StringBuilder(prefix) var first = true for (element in this) { diff --git a/libraries/stdlib/src/generated/JavaUtilIteratorsFromJavaIterables.kt b/libraries/stdlib/src/generated/JavaUtilIteratorsFromJavaIterables.kt index 8500b4eb6b3..19cee700c7d 100644 --- a/libraries/stdlib/src/generated/JavaUtilIteratorsFromJavaIterables.kt +++ b/libraries/stdlib/src/generated/JavaUtilIteratorsFromJavaIterables.kt @@ -8,7 +8,7 @@ import java.util.* * * @includeFunction ../../test/CollectionTest.kt any */ -inline fun java.util.Iterator.any(predicate: (T) -> Boolean) : Boolean { +public inline fun java.util.Iterator.any(predicate: (T) -> Boolean) : Boolean { for (element in this) if (predicate(element)) return true return false } @@ -18,7 +18,7 @@ inline fun java.util.Iterator.any(predicate: (T) -> Boolean) : Boolean { * * @includeFunction ../../test/CollectionTest.kt all */ -inline fun java.util.Iterator.all(predicate: (T) -> Boolean) : Boolean { +public inline fun java.util.Iterator.all(predicate: (T) -> Boolean) : Boolean { for (element in this) if (!predicate(element)) return false return true } @@ -28,7 +28,7 @@ inline fun java.util.Iterator.all(predicate: (T) -> Boolean) : Boolean { * * @includeFunction ../../test/CollectionTest.kt count */ -inline fun java.util.Iterator.count(predicate: (T) -> Boolean) : Int { +public inline fun java.util.Iterator.count(predicate: (T) -> Boolean) : Int { var count = 0 for (element in this) if (predicate(element)) count++ return count @@ -39,7 +39,7 @@ inline fun java.util.Iterator.count(predicate: (T) -> Boolean) : Int { * * @includeFunction ../../test/CollectionTest.kt find */ -inline fun java.util.Iterator.find(predicate: (T) -> Boolean) : T? { +public inline fun java.util.Iterator.find(predicate: (T) -> Boolean) : T? { for (element in this) if (predicate(element)) return element return null } @@ -49,7 +49,7 @@ inline fun java.util.Iterator.find(predicate: (T) -> Boolean) : T? { * * @includeFunction ../../test/CollectionTest.kt filterIntoLinkedList */ -inline fun > java.util.Iterator.filterTo(result: C, predicate: (T) -> Boolean) : C { +public inline fun > java.util.Iterator.filterTo(result: C, predicate: (T) -> Boolean) : C { for (element in this) if (predicate(element)) result.add(element) return result } @@ -59,7 +59,7 @@ inline fun > java.util.Iterator.filterTo(result: C, pr * * @includeFunction ../../test/CollectionTest.kt filterNotIntoLinkedList */ -inline fun > java.util.Iterator.filterNotTo(result: L, predicate: (T) -> Boolean) : L { +public inline fun > java.util.Iterator.filterNotTo(result: L, predicate: (T) -> Boolean) : L { for (element in this) if (!predicate(element)) result.add(element) return result } @@ -69,7 +69,7 @@ inline fun > java.util.Iterator.filterNotTo(result: L, predi * * @includeFunction ../../test/CollectionTest.kt filterNotNullIntoLinkedList */ -inline fun > java.util.Iterator?.filterNotNullTo(result: L) : L { +public inline fun > java.util.Iterator?.filterNotNullTo(result: L) : L { if (this != null) { for (element in this) if (element != null) result.add(element) } @@ -81,7 +81,7 @@ inline fun > java.util.Iterator?.filterNotNullTo(result: L) * * @includeFunction ../../test/CollectionTest.kt flatMap */ -inline fun java.util.Iterator.flatMapTo(result: Collection, transform: (T) -> Collection) : Collection { +public inline fun java.util.Iterator.flatMapTo(result: Collection, transform: (T) -> Collection) : Collection { for (element in this) { val list = transform(element) if (list != null) { @@ -96,14 +96,14 @@ inline fun java.util.Iterator.flatMapTo(result: Collection, transfo * * @includeFunction ../../test/CollectionTest.kt forEach */ -inline fun java.util.Iterator.forEach(operation: (T) -> Unit) = for (element in this) operation(element) +public inline fun java.util.Iterator.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 */ -inline fun java.util.Iterator.fold(initial: T, operation: (T, T) -> T): T { +public inline fun java.util.Iterator.fold(initial: T, operation: (T, T) -> T): T { var answer = initial for (element in this) answer = operation(answer, element) return answer @@ -114,14 +114,14 @@ inline fun java.util.Iterator.fold(initial: T, operation: (T, T) -> T): T * * @includeFunction ../../test/CollectionTest.kt foldRight */ -inline fun java.util.Iterator.foldRight(initial: T, operation: (T, T) -> T): T = reverse().fold(initial, operation) +public inline fun java.util.Iterator.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 */ -inline fun java.util.Iterator.groupBy(result: Map> = HashMap>(), toKey: (T) -> K) : Map> { +public inline fun java.util.Iterator.groupBy(result: Map> = HashMap>(), toKey: (T) -> K) : Map> { for (element in this) { val key = toKey(element) val list = result.getOrPut(key) { ArrayList() } @@ -131,7 +131,7 @@ inline fun java.util.Iterator.groupBy(result: Map> = HashMa } /** Returns a list containing the first elements that satisfy the given *predicate* */ -inline fun > java.util.Iterator.takeWhileTo(result: L, predicate: (T) -> Boolean) : L { +public inline fun > java.util.Iterator.takeWhileTo(result: L, predicate: (T) -> Boolean) : L { for (element in this) if (predicate(element)) result.add(element) else break return result } @@ -141,33 +141,33 @@ inline fun > java.util.Iterator.takeWhileTo(result: L, predi * * @includeFunction ../../test/CollectionTest.kt reverse */ -inline fun java.util.Iterator.reverse() : List { +public inline fun java.util.Iterator.reverse() : List { val answer = LinkedList() for (element in this) answer.addFirst(element) return answer } /** Copies all elements into the given collection */ -inline fun > java.util.Iterator.to(result: C) : C { +public inline fun > java.util.Iterator.to(result: C) : C { for (element in this) result.add(element) return result } /** Copies all elements into a [[LinkedList]] */ -inline fun java.util.Iterator.toLinkedList() : LinkedList = to(LinkedList()) +public inline fun java.util.Iterator.toLinkedList() : LinkedList = to(LinkedList()) /** Copies all elements into a [[List]] */ -inline fun java.util.Iterator.toList() : List = to(ArrayList()) +public inline fun java.util.Iterator.toList() : List = to(ArrayList()) /** Copies all elements into a [[Set]] */ -inline fun java.util.Iterator.toSet() : Set = to(HashSet()) +public inline fun java.util.Iterator.toSet() : Set = to(HashSet()) /** Copies all elements into a [[SortedSet]] */ -inline fun java.util.Iterator.toSortedSet() : SortedSet = to(TreeSet()) +public inline fun java.util.Iterator.toSortedSet() : SortedSet = to(TreeSet()) /** TODO figure out necessary variance/generics ninja stuff... :) -inline fun java.util.Iterator.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List { +public inline fun java.util.Iterator.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List { val answer = this.toList() answer.sort(transform) return answer diff --git a/libraries/stdlib/src/generated/StandardFromJavaIterables.kt b/libraries/stdlib/src/generated/StandardFromJavaIterables.kt index 9202070b625..ea7008c61f3 100644 --- a/libraries/stdlib/src/generated/StandardFromJavaIterables.kt +++ b/libraries/stdlib/src/generated/StandardFromJavaIterables.kt @@ -10,7 +10,7 @@ import java.util.* * * @includeFunction ../../test/CollectionTest.kt any */ -inline fun Iterable.any(predicate: (T) -> Boolean) : Boolean { +public inline fun Iterable.any(predicate: (T) -> Boolean) : Boolean { for (element in this) if (predicate(element)) return true return false } @@ -20,7 +20,7 @@ inline fun Iterable.any(predicate: (T) -> Boolean) : Boolean { * * @includeFunction ../../test/CollectionTest.kt all */ -inline fun Iterable.all(predicate: (T) -> Boolean) : Boolean { +public inline fun Iterable.all(predicate: (T) -> Boolean) : Boolean { for (element in this) if (!predicate(element)) return false return true } @@ -30,7 +30,7 @@ inline fun Iterable.all(predicate: (T) -> Boolean) : Boolean { * * @includeFunction ../../test/CollectionTest.kt count */ -inline fun Iterable.count(predicate: (T) -> Boolean) : Int { +public inline fun Iterable.count(predicate: (T) -> Boolean) : Int { var count = 0 for (element in this) if (predicate(element)) count++ return count @@ -41,7 +41,7 @@ inline fun Iterable.count(predicate: (T) -> Boolean) : Int { * * @includeFunction ../../test/CollectionTest.kt find */ -inline fun Iterable.find(predicate: (T) -> Boolean) : T? { +public inline fun Iterable.find(predicate: (T) -> Boolean) : T? { for (element in this) if (predicate(element)) return element return null } @@ -51,7 +51,7 @@ inline fun Iterable.find(predicate: (T) -> Boolean) : T? { * * @includeFunction ../../test/CollectionTest.kt filterIntoLinkedList */ -inline fun > Iterable.filterTo(result: C, predicate: (T) -> Boolean) : C { +public inline fun > Iterable.filterTo(result: C, predicate: (T) -> Boolean) : C { for (element in this) if (predicate(element)) result.add(element) return result } @@ -61,7 +61,7 @@ inline fun > Iterable.filterTo(result: C, predicate: ( * * @includeFunction ../../test/CollectionTest.kt filterNotIntoLinkedList */ -inline fun > Iterable.filterNotTo(result: L, predicate: (T) -> Boolean) : L { +public inline fun > Iterable.filterNotTo(result: L, predicate: (T) -> Boolean) : L { for (element in this) if (!predicate(element)) result.add(element) return result } @@ -71,7 +71,7 @@ inline fun > Iterable.filterNotTo(result: L, predicate: (T) * * @includeFunction ../../test/CollectionTest.kt filterNotNullIntoLinkedList */ -inline fun > Iterable?.filterNotNullTo(result: L) : L { +public inline fun > Iterable?.filterNotNullTo(result: L) : L { if (this != null) { for (element in this) if (element != null) result.add(element) } @@ -83,7 +83,7 @@ inline fun > Iterable?.filterNotNullTo(result: L) : L { * * @includeFunction ../../test/CollectionTest.kt flatMap */ -inline fun Iterable.flatMapTo(result: Collection, transform: (T) -> Collection) : Collection { +public inline fun Iterable.flatMapTo(result: Collection, transform: (T) -> Collection) : Collection { for (element in this) { val list = transform(element) if (list != null) { @@ -98,14 +98,14 @@ inline fun Iterable.flatMapTo(result: Collection, transform: (T) -> * * @includeFunction ../../test/CollectionTest.kt forEach */ -inline fun Iterable.forEach(operation: (T) -> Unit) = for (element in this) operation(element) +public inline fun Iterable.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 */ -inline fun Iterable.fold(initial: T, operation: (T, T) -> T): T { +public inline fun Iterable.fold(initial: T, operation: (T, T) -> T): T { var answer = initial for (element in this) answer = operation(answer, element) return answer @@ -116,14 +116,14 @@ inline fun Iterable.fold(initial: T, operation: (T, T) -> T): T { * * @includeFunction ../../test/CollectionTest.kt foldRight */ -inline fun Iterable.foldRight(initial: T, operation: (T, T) -> T): T = reverse().fold(initial, operation) +public inline fun Iterable.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 */ -inline fun Iterable.groupBy(result: Map> = HashMap>(), toKey: (T) -> K) : Map> { +public inline fun Iterable.groupBy(result: Map> = HashMap>(), toKey: (T) -> K) : Map> { for (element in this) { val key = toKey(element) val list = result.getOrPut(key) { ArrayList() } @@ -133,7 +133,7 @@ inline fun Iterable.groupBy(result: Map> = HashMap> Iterable.takeWhileTo(result: L, predicate: (T) -> Boolean) : L { +public inline fun > Iterable.takeWhileTo(result: L, predicate: (T) -> Boolean) : L { for (element in this) if (predicate(element)) result.add(element) else break return result } @@ -143,33 +143,33 @@ inline fun > Iterable.takeWhileTo(result: L, predicate: (T) * * @includeFunction ../../test/CollectionTest.kt reverse */ -inline fun Iterable.reverse() : List { +public inline fun Iterable.reverse() : List { val answer = LinkedList() for (element in this) answer.addFirst(element) return answer } /** Copies all elements into the given collection */ -inline fun > Iterable.to(result: C) : C { +public inline fun > Iterable.to(result: C) : C { for (element in this) result.add(element) return result } /** Copies all elements into a [[LinkedList]] */ -inline fun Iterable.toLinkedList() : LinkedList = to(LinkedList()) +public inline fun Iterable.toLinkedList() : LinkedList = to(LinkedList()) /** Copies all elements into a [[List]] */ -inline fun Iterable.toList() : List = to(ArrayList()) +public inline fun Iterable.toList() : List = to(ArrayList()) /** Copies all elements into a [[Set]] */ -inline fun Iterable.toSet() : Set = to(HashSet()) +public inline fun Iterable.toSet() : Set = to(HashSet()) /** Copies all elements into a [[SortedSet]] */ -inline fun Iterable.toSortedSet() : SortedSet = to(TreeSet()) +public inline fun Iterable.toSortedSet() : SortedSet = to(TreeSet()) /** TODO figure out necessary variance/generics ninja stuff... :) -inline fun Iterable.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List { +public inline fun Iterable.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List { val answer = this.toList() answer.sort(transform) return answer diff --git a/libraries/stdlib/src/generated/StandardFromJavaIterablesLazy.kt b/libraries/stdlib/src/generated/StandardFromJavaIterablesLazy.kt index 37f635e52bb..c68858deb1b 100644 --- a/libraries/stdlib/src/generated/StandardFromJavaIterablesLazy.kt +++ b/libraries/stdlib/src/generated/StandardFromJavaIterablesLazy.kt @@ -19,35 +19,35 @@ import java.util.List * * @includeFunction ../../test/CollectionTest.kt filter */ -inline fun Iterable.filter(predicate: (T) -> Boolean) : List = filterTo(ArrayList(), predicate) +public inline fun Iterable.filter(predicate: (T) -> Boolean) : List = filterTo(ArrayList(), predicate) /** * Returns a list containing all elements which do not match the given predicate * * @includeFunction ../../test/CollectionTest.kt filterNot */ -inline fun Iterable.filterNot(predicate: (T)-> Boolean) : List = filterNotTo(ArrayList(), predicate) +public inline fun Iterable.filterNot(predicate: (T)-> Boolean) : List = filterNotTo(ArrayList(), predicate) /** * Returns a list containing all the non-*null* elements * * @includeFunction ../../test/CollectionTest.kt filterNotNull */ -inline fun Iterable?.filterNotNull() : List = filterNotNullTo>(java.util.ArrayList()) +public inline fun Iterable?.filterNotNull() : List = filterNotNullTo>(java.util.ArrayList()) /** * 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 */ -inline fun Iterable.flatMap(transform: (T)-> Collection) : Collection = flatMapTo(ArrayList(), transform) +public inline fun Iterable.flatMap(transform: (T)-> Collection) : Collection = flatMapTo(ArrayList(), transform) /** * Returns a list containing the first *n* elements * * @includeFunction ../../test/CollectionTest.kt take */ -inline fun Iterable.take(n: Int): List { +public inline fun Iterable.take(n: Int): List { fun countTo(n: Int): (T) -> Boolean { var count = 0 return { ++count; count <= n } @@ -60,14 +60,14 @@ inline fun Iterable.take(n: Int): List { * * @includeFunction ../../test/CollectionTest.kt takeWhile */ -inline fun Iterable.takeWhile(predicate: (T) -> Boolean): List = takeWhileTo(ArrayList(), predicate) +public inline fun Iterable.takeWhile(predicate: (T) -> Boolean): List = takeWhileTo(ArrayList(), 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 */ -inline fun Iterable.join(separator: String = ", ", prefix: String = "", postfix: String = "") : String { +public inline fun Iterable.join(separator: String = ", ", prefix: String = "", postfix: String = "") : String { val buffer = StringBuilder(prefix) var first = true for (element in this) { diff --git a/libraries/stdlib/src/kotlin/Arrays.kt b/libraries/stdlib/src/kotlin/Arrays.kt index 83770a8cae7..d8484f064f4 100644 --- a/libraries/stdlib/src/kotlin/Arrays.kt +++ b/libraries/stdlib/src/kotlin/Arrays.kt @@ -99,7 +99,7 @@ public inline fun CharArray.copyOfRange(from: Int, to: Int) : CharArray = public inline fun Array.copyOfRange(from: Int, to: Int) : Array = Arrays.copyOfRange(this as Array, from, to) as Array -inline val ByteArray.inputStream : ByteArrayInputStream +public inline val ByteArray.inputStream : ByteArrayInputStream get() = ByteArrayInputStream(this) public inline fun ByteArray.inputStream(offset: Int, length: Int) : ByteArrayInputStream = ByteArrayInputStream(this, offset, length) diff --git a/libraries/stdlib/src/kotlin/Iterators.kt b/libraries/stdlib/src/kotlin/Iterators.kt index 18ba2bcc719..841ecd71644 100644 --- a/libraries/stdlib/src/kotlin/Iterators.kt +++ b/libraries/stdlib/src/kotlin/Iterators.kt @@ -8,10 +8,10 @@ import kotlin.support.FunctionIterator * * @includeFunction ../../test/iterators/IteratorsTest.kt fibonacci */ -inline fun iterate(nextFunction: () -> T?) : java.util.Iterator = FunctionIterator(nextFunction) +public inline fun iterate(nextFunction: () -> T?) : java.util.Iterator = FunctionIterator(nextFunction) /** Returns an iterator over elements that are instances of a given type *R* which is a subclass of *T* */ -inline fun java.util.Iterator.filterIsInstance(klass: Class): java.util.Iterator = FilterIsIterator(this, klass) +public inline fun java.util.Iterator.filterIsInstance(klass: Class): java.util.Iterator = FilterIsIterator(this, klass) private class FilterIsIterator(val iterator : java.util.Iterator, val klass: Class) : AbstractIterator() { override protected fun computeNext(): R? { @@ -29,7 +29,7 @@ private class FilterIsIterator(val iterator : java.util.Iterator, va * * @includeFunction ../../test/iterators/IteratorsTest.kt filterAndTakeWhileExtractTheElementsWithinRange */ -inline fun java.util.Iterator.filter(predicate: (T) -> Boolean) : java.util.Iterator = FilterIterator(this, predicate) +public inline fun java.util.Iterator.filter(predicate: (T) -> Boolean) : java.util.Iterator = FilterIterator(this, predicate) private class FilterIterator(val iterator : java.util.Iterator, val predicate: (T)-> Boolean) : AbstractIterator() { override protected fun computeNext(): T? { @@ -43,10 +43,10 @@ private class FilterIterator(val iterator : java.util.Iterator, val predic } /** Returns an iterator over elements which do not match the given *predicate* */ -inline fun java.util.Iterator.filterNot(predicate: (T) -> Boolean) : java.util.Iterator = filter { !predicate(it) } +public inline fun java.util.Iterator.filterNot(predicate: (T) -> Boolean) : java.util.Iterator = filter { !predicate(it) } /** Returns an iterator over non-*null* elements */ -inline fun java.util.Iterator?.filterNotNull() : java.util.Iterator = FilterNotNullIterator(this) +public inline fun java.util.Iterator?.filterNotNull() : java.util.Iterator = FilterNotNullIterator(this) private class FilterNotNullIterator(val iterator : java.util.Iterator?) : AbstractIterator() { override protected fun computeNext(): T? { @@ -66,7 +66,7 @@ private class FilterNotNullIterator(val iterator : java.util.Iterator?) : * * @includeFunction ../../test/iterators/IteratorsTest.kt mapAndTakeWhileExtractTheTransformedElements */ -inline fun java.util.Iterator.map(transform: (T) -> R): java.util.Iterator = MapIterator(this, transform) +public inline fun java.util.Iterator.map(transform: (T) -> R): java.util.Iterator = MapIterator(this, transform) private class MapIterator(val iterator : java.util.Iterator, val transform: (T) -> R) : AbstractIterator() { override protected fun computeNext() : R? = if (iterator.hasNext()) (transform)(iterator.next()) else { done(); null } @@ -77,7 +77,7 @@ private class MapIterator(val iterator : java.util.Iterator, val transf * * @includeFunction ../../test/iterators/IteratorsTest.kt flatMapAndTakeExtractTheTransformedElements */ -inline fun java.util.Iterator.flatMap(transform: (T) -> java.util.Iterator): java.util.Iterator = FlatMapIterator(this, transform) +public inline fun java.util.Iterator.flatMap(transform: (T) -> java.util.Iterator): java.util.Iterator = FlatMapIterator(this, transform) private class FlatMapIterator(val iterator : java.util.Iterator, val transform: (T) -> java.util.Iterator) : AbstractIterator() { var transformed: java.util.Iterator = iterate { null } @@ -98,7 +98,7 @@ private class FlatMapIterator(val iterator : java.util.Iterator, val tr * * @includeFunction ../../test/iterators/IteratorsTest.kt takeExtractsTheFirstNElements */ -inline fun java.util.Iterator.take(n: Int): java.util.Iterator { +public inline fun java.util.Iterator.take(n: Int): java.util.Iterator { fun countTo(n: Int): (T) -> Boolean { var count = 0 return { ++count; count <= n } @@ -111,7 +111,7 @@ inline fun java.util.Iterator.take(n: Int): java.util.Iterator { * * @includeFunction ../../test/iterators/IteratorsTest.kt filterAndTakeWhileExtractTheElementsWithinRange */ -inline fun java.util.Iterator.takeWhile(predicate: (T) -> Boolean): java.util.Iterator = TakeWhileIterator(this, predicate) +public inline fun java.util.Iterator.takeWhile(predicate: (T) -> Boolean): java.util.Iterator = TakeWhileIterator(this, predicate) private class TakeWhileIterator(val iterator: java.util.Iterator, val predicate: (T) -> Boolean) : AbstractIterator() { override protected fun computeNext() : T? { @@ -129,7 +129,7 @@ private class TakeWhileIterator(val iterator: java.util.Iterator, val pred * * @includeFunction ../../test/iterators/IteratorsTest.kt joinConcatenatesTheFirstNElementsAboveAThreshold */ -inline fun java.util.Iterator.join(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int? = null) : String { +public inline fun java.util.Iterator.join(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int? = null) : String { val buffer = StringBuilder(prefix) var first = true; var count = 0 for (element in this) { diff --git a/libraries/stdlib/src/kotlin/JavaIterables.kt b/libraries/stdlib/src/kotlin/JavaIterables.kt index e8f8d9fc8ba..a561b38bcb2 100644 --- a/libraries/stdlib/src/kotlin/JavaIterables.kt +++ b/libraries/stdlib/src/kotlin/JavaIterables.kt @@ -7,7 +7,7 @@ import java.util.* * * @includeFunction ../../test/CollectionTest.kt any */ -inline fun java.lang.Iterable.any(predicate: (T) -> Boolean) : Boolean { +public inline fun java.lang.Iterable.any(predicate: (T) -> Boolean) : Boolean { for (element in this) if (predicate(element)) return true return false } @@ -17,7 +17,7 @@ inline fun java.lang.Iterable.any(predicate: (T) -> Boolean) : Boolean { * * @includeFunction ../../test/CollectionTest.kt all */ -inline fun java.lang.Iterable.all(predicate: (T) -> Boolean) : Boolean { +public inline fun java.lang.Iterable.all(predicate: (T) -> Boolean) : Boolean { for (element in this) if (!predicate(element)) return false return true } @@ -27,7 +27,7 @@ inline fun java.lang.Iterable.all(predicate: (T) -> Boolean) : Boolean { * * @includeFunction ../../test/CollectionTest.kt count */ -inline fun java.lang.Iterable.count(predicate: (T) -> Boolean) : Int { +public inline fun java.lang.Iterable.count(predicate: (T) -> Boolean) : Int { var count = 0 for (element in this) if (predicate(element)) count++ return count @@ -38,7 +38,7 @@ inline fun java.lang.Iterable.count(predicate: (T) -> Boolean) : Int { * * @includeFunction ../../test/CollectionTest.kt find */ -inline fun java.lang.Iterable.find(predicate: (T) -> Boolean) : T? { +public inline fun java.lang.Iterable.find(predicate: (T) -> Boolean) : T? { for (element in this) if (predicate(element)) return element return null } @@ -48,7 +48,7 @@ inline fun java.lang.Iterable.find(predicate: (T) -> Boolean) : T? { * * @includeFunction ../../test/CollectionTest.kt filterIntoLinkedList */ -inline fun > java.lang.Iterable.filterTo(result: C, predicate: (T) -> Boolean) : C { +public inline fun > java.lang.Iterable.filterTo(result: C, predicate: (T) -> Boolean) : C { for (element in this) if (predicate(element)) result.add(element) return result } @@ -58,7 +58,7 @@ inline fun > java.lang.Iterable.filterTo(result: C, pr * * @includeFunction ../../test/CollectionTest.kt filterNotIntoLinkedList */ -inline fun > java.lang.Iterable.filterNotTo(result: L, predicate: (T) -> Boolean) : L { +public inline fun > java.lang.Iterable.filterNotTo(result: L, predicate: (T) -> Boolean) : L { for (element in this) if (!predicate(element)) result.add(element) return result } @@ -68,7 +68,7 @@ inline fun > java.lang.Iterable.filterNotTo(result: L, predi * * @includeFunction ../../test/CollectionTest.kt filterNotNullIntoLinkedList */ -inline fun > java.lang.Iterable?.filterNotNullTo(result: L) : L { +public inline fun > java.lang.Iterable?.filterNotNullTo(result: L) : L { if (this != null) { for (element in this) if (element != null) result.add(element) } @@ -80,7 +80,7 @@ inline fun > java.lang.Iterable?.filterNotNullTo(result: L) * * @includeFunction ../../test/CollectionTest.kt flatMap */ -inline fun java.lang.Iterable.flatMapTo(result: Collection, transform: (T) -> Collection) : Collection { +public inline fun java.lang.Iterable.flatMapTo(result: Collection, transform: (T) -> Collection) : Collection { for (element in this) { val list = transform(element) if (list != null) { @@ -95,14 +95,14 @@ inline fun java.lang.Iterable.flatMapTo(result: Collection, transfo * * @includeFunction ../../test/CollectionTest.kt forEach */ -inline fun java.lang.Iterable.forEach(operation: (T) -> Unit) = for (element in this) operation(element) +public inline fun java.lang.Iterable.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 */ -inline fun java.lang.Iterable.fold(initial: T, operation: (T, T) -> T): T { +public inline fun java.lang.Iterable.fold(initial: T, operation: (T, T) -> T): T { var answer = initial for (element in this) answer = operation(answer, element) return answer @@ -113,14 +113,14 @@ inline fun java.lang.Iterable.fold(initial: T, operation: (T, T) -> T): T * * @includeFunction ../../test/CollectionTest.kt foldRight */ -inline fun java.lang.Iterable.foldRight(initial: T, operation: (T, T) -> T): T = reverse().fold(initial, operation) +public inline fun java.lang.Iterable.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 */ -inline fun java.lang.Iterable.groupBy(result: Map> = HashMap>(), toKey: (T) -> K) : Map> { +public inline fun java.lang.Iterable.groupBy(result: Map> = HashMap>(), toKey: (T) -> K) : Map> { for (element in this) { val key = toKey(element) val list = result.getOrPut(key) { ArrayList() } @@ -130,7 +130,7 @@ inline fun java.lang.Iterable.groupBy(result: Map> = HashMa } /** Returns a list containing the first elements that satisfy the given *predicate* */ -inline fun > java.lang.Iterable.takeWhileTo(result: L, predicate: (T) -> Boolean) : L { +public inline fun > java.lang.Iterable.takeWhileTo(result: L, predicate: (T) -> Boolean) : L { for (element in this) if (predicate(element)) result.add(element) else break return result } @@ -140,33 +140,33 @@ inline fun > java.lang.Iterable.takeWhileTo(result: L, predi * * @includeFunction ../../test/CollectionTest.kt reverse */ -inline fun java.lang.Iterable.reverse() : List { +public inline fun java.lang.Iterable.reverse() : List { val answer = LinkedList() for (element in this) answer.addFirst(element) return answer } /** Copies all elements into the given collection */ -inline fun > java.lang.Iterable.to(result: C) : C { +public inline fun > java.lang.Iterable.to(result: C) : C { for (element in this) result.add(element) return result } /** Copies all elements into a [[LinkedList]] */ -inline fun java.lang.Iterable.toLinkedList() : LinkedList = to(LinkedList()) +public inline fun java.lang.Iterable.toLinkedList() : LinkedList = to(LinkedList()) /** Copies all elements into a [[List]] */ -inline fun java.lang.Iterable.toList() : List = to(ArrayList()) +public inline fun java.lang.Iterable.toList() : List = to(ArrayList()) /** Copies all elements into a [[Set]] */ -inline fun java.lang.Iterable.toSet() : Set = to(HashSet()) +public inline fun java.lang.Iterable.toSet() : Set = to(HashSet()) /** Copies all elements into a [[SortedSet]] */ -inline fun java.lang.Iterable.toSortedSet() : SortedSet = to(TreeSet()) +public inline fun java.lang.Iterable.toSortedSet() : SortedSet = to(TreeSet()) /** TODO figure out necessary variance/generics ninja stuff... :) -inline fun java.lang.Iterable.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List { +public inline fun java.lang.Iterable.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List { val answer = this.toList() answer.sort(transform) return answer diff --git a/libraries/stdlib/src/kotlin/JavaIterablesLazy.kt b/libraries/stdlib/src/kotlin/JavaIterablesLazy.kt index a2019d2cd92..9eba06d7e9e 100644 --- a/libraries/stdlib/src/kotlin/JavaIterablesLazy.kt +++ b/libraries/stdlib/src/kotlin/JavaIterablesLazy.kt @@ -16,35 +16,35 @@ import java.util.List * * @includeFunction ../../test/CollectionTest.kt filter */ -inline fun java.lang.Iterable.filter(predicate: (T) -> Boolean) : List = filterTo(ArrayList(), predicate) +public inline fun java.lang.Iterable.filter(predicate: (T) -> Boolean) : List = filterTo(ArrayList(), predicate) /** * Returns a list containing all elements which do not match the given predicate * * @includeFunction ../../test/CollectionTest.kt filterNot */ -inline fun java.lang.Iterable.filterNot(predicate: (T)-> Boolean) : List = filterNotTo(ArrayList(), predicate) +public inline fun java.lang.Iterable.filterNot(predicate: (T)-> Boolean) : List = filterNotTo(ArrayList(), predicate) /** * Returns a list containing all the non-*null* elements * * @includeFunction ../../test/CollectionTest.kt filterNotNull */ -inline fun java.lang.Iterable?.filterNotNull() : List = filterNotNullTo>(java.util.ArrayList()) +public inline fun java.lang.Iterable?.filterNotNull() : List = filterNotNullTo>(java.util.ArrayList()) /** * 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 */ -inline fun java.lang.Iterable.flatMap(transform: (T)-> Collection) : Collection = flatMapTo(ArrayList(), transform) +public inline fun java.lang.Iterable.flatMap(transform: (T)-> Collection) : Collection = flatMapTo(ArrayList(), transform) /** * Returns a list containing the first *n* elements * * @includeFunction ../../test/CollectionTest.kt take */ -inline fun java.lang.Iterable.take(n: Int): List { +public inline fun java.lang.Iterable.take(n: Int): List { fun countTo(n: Int): (T) -> Boolean { var count = 0 return { ++count; count <= n } @@ -57,14 +57,14 @@ inline fun java.lang.Iterable.take(n: Int): List { * * @includeFunction ../../test/CollectionTest.kt takeWhile */ -inline fun java.lang.Iterable.takeWhile(predicate: (T) -> Boolean): List = takeWhileTo(ArrayList(), predicate) +public inline fun java.lang.Iterable.takeWhile(predicate: (T) -> Boolean): List = takeWhileTo(ArrayList(), 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 */ -inline fun java.lang.Iterable.join(separator: String = ", ", prefix: String = "", postfix: String = "") : String { +public inline fun java.lang.Iterable.join(separator: String = ", ", prefix: String = "", postfix: String = "") : String { val buffer = StringBuilder(prefix) var first = true for (element in this) { diff --git a/libraries/stdlib/src/kotlin/support/AbstractIterator.kt b/libraries/stdlib/src/kotlin/support/AbstractIterator.kt index f44e1707d53..d54b2300b45 100644 --- a/libraries/stdlib/src/kotlin/support/AbstractIterator.kt +++ b/libraries/stdlib/src/kotlin/support/AbstractIterator.kt @@ -2,7 +2,7 @@ package kotlin.support import java.util.NoSuchElementException -enum class State { +public enum class State { Ready NotReady Done @@ -14,10 +14,10 @@ enum class State { * to implement the iterator, calling [[done()]] when the iteration is complete. */ public abstract class AbstractIterator: java.util.Iterator { - var state: State = State.NotReady - var next: T? = null + public var state: State = State.NotReady + public var next: T? = null - override fun hasNext(): Boolean { + public override fun hasNext(): Boolean { require(state != State.Failed) return when (state) { State.Done -> false @@ -26,13 +26,13 @@ public abstract class AbstractIterator: java.util.Iterator { } } - override fun next(): T { + public override fun next(): T { if (!hasNext()) throw NoSuchElementException() state = State.NotReady return next.sure() } - override fun remove() { throw UnsupportedOperationException() } + public override fun remove() { throw UnsupportedOperationException() } /** Returns the next element in the iteration without advancing the iteration */ fun peek(): T {