This file contains hidden or 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
class PitTree[T](val children : Map[String, PitTree[T]], val value : Option[T]) extends Map[String, T] { | |
def this() = this(Map(), None) | |
def this(value : T) = this(Map(), Some(value)) | |
def update(path : String, upVal : T) : PitTree[T] = update(splitPath(path), upVal) | |
def update(path : List[String], upVal : T) : PitTree[T] = path match { | |
case Nil => | |
new PitTree[T](upVal) | |
case h :: t => | |
val child = children.getOrElse(h, new PitTree[T]()).update(t, upVal) | |
new PitTree[T](children + (h -> child), value) |