-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into documentation
- Loading branch information
Showing
225 changed files
with
9,819 additions
and
1,615 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Giovanni Ciatto (giovanni.ciatto@unibo.it, giovanni.ciatto@gmail.com) | ||
Enrico Siboni (enrico.siboni3@studio.unibo.it) | ||
Paolo Verdini (paolo.verdini@studio.unibo.it, paolopiano1997@gmail.com) | ||
Manuel Bonarrigo (manuel.bonarrigo@studio.unibo.it) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Cached.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package it.unibo.tuprolog.utils | ||
|
||
import it.unibo.tuprolog.utils.impl.CachedImpl | ||
|
||
interface Cached<T> { | ||
companion object { | ||
fun <T> of(generator: () -> T): Cached<T> { | ||
return CachedImpl(generator) | ||
} | ||
} | ||
|
||
val isValid: Boolean | ||
|
||
val isInvalid: Boolean | ||
|
||
val value: T | ||
|
||
fun regenerate() | ||
|
||
fun <R> regenerating(consumer: (T) -> R): R { | ||
regenerate() | ||
return value.let(consumer) | ||
} | ||
|
||
fun invalidate() | ||
|
||
fun <R> ifValid(consumer: (T) -> R): Optional<out R> { | ||
return if (isValid) { | ||
Optional.of(value.let(consumer)) | ||
} else { | ||
Optional.none() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package it.unibo.tuprolog.utils | ||
|
||
expect fun <T> dequeOf(vararg items: T): MutableList<T> | ||
|
||
expect fun <T> dequeOf(items: Iterable<T>): MutableList<T> | ||
|
||
expect fun <T> dequeOf(items: Sequence<T>): MutableList<T> | ||
|
||
expect fun <T> MutableList<T>.addFirst(item: T) |
14 changes: 14 additions & 0 deletions
14
core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Indexed.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package it.unibo.tuprolog.utils | ||
|
||
interface Indexed<K, T> { | ||
val index: K | ||
|
||
val value: T | ||
|
||
operator fun component1(): K = index | ||
|
||
operator fun component2(): T = value | ||
|
||
fun <R> map(mapper: (T) -> R): Indexed<K, R> | ||
} | ||
|
19 changes: 19 additions & 0 deletions
19
core/src/commonMain/kotlin/it/unibo/tuprolog/utils/IntIndexed.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package it.unibo.tuprolog.utils | ||
|
||
import it.unibo.tuprolog.utils.impl.IntIndexedImpl | ||
|
||
interface IntIndexed<T> : Indexed<Int, T>, Comparable<IntIndexed<T>> { | ||
|
||
override fun compareTo(other: IntIndexed<T>): Int { | ||
return index - other.index | ||
} | ||
|
||
override fun <R> map(mapper: (T) -> R): IntIndexed<R> | ||
|
||
companion object { | ||
fun <T> of(index: Int, value: T): IntIndexed<T> { | ||
return IntIndexedImpl(index, value) | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.