Skip to content
Snippets Groups Projects
Commit 27100d2a authored by Viktor Kuncak's avatar Viktor Kuncak
Browse files

cleaned up a bit

parent 0267d262
No related branches found
No related tags found
No related merge requests found
......@@ -12,8 +12,10 @@ object BSTAsSet extends Application {
case Node(_,left,v,right) if (x > v) => Node(content + x,
left, v, right.add(x))
case Node(_,_,v,_) if (v == x) => this
// this is due to limitation of pattern matching check
case _ => this
}
} ensuring(result => (result.content == content + x))
} ensuring (_.content == content + x)
// patterns are exhaustive, disjoint and all reachable
def contains(key: Int): Boolean = {
......@@ -22,8 +24,10 @@ object BSTAsSet extends Application {
case Node(_,_,v,right) if (key > v) => right.contains(key)
case Node(_,_,v, _) if (key == v) => true
case Empty(_) => false
// this is due to limitation of pattern matching check
case _ => false
}
} ensuring(res => (res == content.contains(key)))
} ensuring (_ == content.contains(key))
}
case class Empty(override val content : Set[Int]) extends BST(Set.empty)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment