Skip to content

@soc /::.scala
Last active

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
final case class ::[B](private var hd: B, private[scala] var tl: List[B]) extends List[B]
override def head: B = hd
override def tail: List[B] = tl
override def isEmpty: Boolean = false
private def readObject(in: ObjectInputStream): Unit =
val firstObject = in.readObject()
hd = firstObject.asInstanceOf[B]
assert(hd != ListSerializeEnd)
var current: ::[B] = this
while true
do in.readObject match
case ListSerializeEnd => = Nil
case a =>
val list: ::[B] = new ::(a.asInstanceOf[B], Nil) = list
current = list
private def writeObject(out: ObjectOutputStream): Unit =
var xs: List[B] = this
while !xs.isEmpty
do out.writeObject(xs.head); xs = xs.tail
override def slice(from: Int, until: Int): List[A] =
val lo = scala.math.max(from, 0)
if until <= lo || isEmpty
then Nil
else this drop lo take (until - lo)

How? Where?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.