Skip to content

Instantly share code, notes, and snippets.

View joelpedraza's full-sized avatar

Joel Pedraza joelpedraza

View GitHub Profile
@Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS")
inline class Result<out T : Any, out E : Any> @PublishedApi internal constructor(
@PublishedApi
@JvmField
internal val value: Any
) {
companion object {
@Suppress("NOTHING_TO_INLINE")
inline fun <T : Any, E : Any> Ok(value: T): Result<T, E> = Result(value)
import java.util.*
class Node<T : Comparable<T>>(
val value: T,
val children: MutableSet<Node<T>> = hashSetOf(),
val parents: MutableSet<Node<T>> = hashSetOf()
) : Comparable<Node<T>> {
override fun compareTo(other: Node<T>): Int = this.value.compareTo(other.value)
// prevent toString from infinite recursion