reformatted root.lyng for better readability
This commit is contained in:
parent
41a3617850
commit
f66e61c185
@ -1,8 +1,8 @@
|
|||||||
package lyng.stdlib
|
package lyng.stdlib
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Wrap a builder into a zero-argument thunk that computes once and caches the result.
|
Wrap a builder into a zero-argument thunk that computes once and caches the result.
|
||||||
The first call invokes builder() and stores the value; subsequent calls return the cached value.
|
The first call invokes builder() and stores the value; subsequent calls return the cached value.
|
||||||
*/
|
*/
|
||||||
fun cached(builder) {
|
fun cached(builder) {
|
||||||
var calculated = false
|
var calculated = false
|
||||||
@ -30,7 +30,7 @@ fun Iterable.filterFlow(predicate): Flow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Filter this iterable and return List of elements
|
Filter this iterable and return List of elements
|
||||||
*/
|
*/
|
||||||
fun Iterable.filter(predicate) {
|
fun Iterable.filter(predicate) {
|
||||||
val result = []
|
val result = []
|
||||||
@ -39,7 +39,7 @@ fun Iterable.filter(predicate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Count all items in this iterable for which predicate return true
|
Count all items in this iterable for which predicate return true
|
||||||
*/
|
*/
|
||||||
fun Iterable.count(predicate): Int {
|
fun Iterable.count(predicate): Int {
|
||||||
var hits = 0
|
var hits = 0
|
||||||
@ -49,8 +49,8 @@ fun Iterable.count(predicate): Int {
|
|||||||
hits
|
hits
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
filter out all null elements from this collection (Iterable); flow of
|
filter out all null elements from this collection (Iterable); flow of
|
||||||
non-null elements is returned
|
non-null elements is returned
|
||||||
*/
|
*/
|
||||||
fun Iterable.filterFlowNotNull(): Flow {
|
fun Iterable.filterFlowNotNull(): Flow {
|
||||||
filterFlow { it != null }
|
filterFlow { it != null }
|
||||||
@ -76,8 +76,8 @@ val Iterable.first get() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Return the first element that matches the predicate or throws
|
Return the first element that matches the predicate or throws
|
||||||
NuSuchElementException
|
NuSuchElementException
|
||||||
*/
|
*/
|
||||||
fun Iterable.findFirst(predicate) {
|
fun Iterable.findFirst(predicate) {
|
||||||
for( x in this ) {
|
for( x in this ) {
|
||||||
@ -88,7 +88,7 @@ fun Iterable.findFirst(predicate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
return the first element matching the predicate or null
|
return the first element matching the predicate or null
|
||||||
*/
|
*/
|
||||||
fun Iterable.findFirstOrNull(predicate) {
|
fun Iterable.findFirstOrNull(predicate) {
|
||||||
for( x in this ) {
|
for( x in this ) {
|
||||||
@ -215,8 +215,8 @@ fun Iterable.shuffled() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Returns a single list of all elements from all collections in the given collection.
|
Returns a single list of all elements from all collections in the given collection.
|
||||||
@return List
|
@return List
|
||||||
*/
|
*/
|
||||||
fun Iterable.flatten() {
|
fun Iterable.flatten() {
|
||||||
val result = []
|
val result = []
|
||||||
@ -227,8 +227,8 @@ fun Iterable.flatten() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Returns a single list of all elements yielded from results of transform function being
|
Returns a single list of all elements yielded from results of transform function being
|
||||||
invoked on each element of original collection.
|
invoked on each element of original collection.
|
||||||
*/
|
*/
|
||||||
fun Iterable.flatMap(transform): List {
|
fun Iterable.flatMap(transform): List {
|
||||||
map(transform).flatten()
|
map(transform).flatten()
|
||||||
@ -279,8 +279,8 @@ val String.re get() = Regex(this)
|
|||||||
fun TODO(message=null) = throw NotImplementedException(message ?: "not implemented")
|
fun TODO(message=null) = throw NotImplementedException(message ?: "not implemented")
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Provides different access types for delegates.
|
Provides different access types for delegates.
|
||||||
Used in the 'bind' hook to validate delegate usage.
|
Used in the 'bind' hook to validate delegate usage.
|
||||||
*/
|
*/
|
||||||
enum DelegateAccess {
|
enum DelegateAccess {
|
||||||
Val,
|
Val,
|
||||||
@ -289,9 +289,9 @@ enum DelegateAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Base interface for all delegates.
|
Base interface for all delegates.
|
||||||
Implementing this interface is optional as Lyng uses dynamic dispatch,
|
Implementing this interface is optional as Lyng uses dynamic dispatch,
|
||||||
but it is recommended for documentation and clarity.
|
but it is recommended for documentation and clarity.
|
||||||
*/
|
*/
|
||||||
interface Delegate {
|
interface Delegate {
|
||||||
/* Called when a delegated 'val' or 'var' is read. */
|
/* Called when a delegated 'val' or 'var' is read. */
|
||||||
@ -321,9 +321,9 @@ fun with(self, block) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Standard implementation of a lazy-initialized property delegate.
|
Standard implementation of a lazy-initialized property delegate.
|
||||||
The provided creator lambda is called once on the first access to compute the value.
|
The provided creator lambda is called once on the first access to compute the value.
|
||||||
Can only be used with 'val' properties.
|
Can only be used with 'val' properties.
|
||||||
*/
|
*/
|
||||||
class lazy(creatorParam) : Delegate {
|
class lazy(creatorParam) : Delegate {
|
||||||
private val creator = creatorParam
|
private val creator = creatorParam
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user