BSTREE
signaturefunctor MkTreap(structure HashKey : HASHKEY)
A BSTREE is a binary search tree. Are you sure you didn't already know that?
structure Key : ORDKEY
type 'v bst
type 'v node =
{ left : 'v bst, key : Key.t, value : 'v, right : 'v bst }
type key = Key.t
val size : 'v bst -> int
val empty : unit -> 'v bst
val singleton : key * 'v -> 'v bst
val makeNode : 'v node -> 'v bst
val expose : 'v bst -> 'v node option
val join : 'v bst * 'v bst -> 'v bst
val splitAt :
'v bst * key -> 'v bst * 'v option * 'v bst
val $ : key * 'v -> 'v bst
structure Key : ORDKEY
Key
substructure defines the
key
type of a bst, providing
equality and toString
functions on such keys.type 'a bst
type 'a node =
{ left : 'a bst, key : Key.t, value : 'a, right : 'a bst }
'a node
to and from values of
type 'a bst
.type key = Key.t
Key.t
.val size :
'a bst -> int
val empty :
unit -> 'a bst
val singleton :
key * 'a -> 'a bst
val makeNode :
'a node -> 'a bst
'a node
to the internal 'a bst
representation.val expose :
'a bst -> 'a node option
val join :
'a bst * 'a bst -> 'a bst
bst
such that
all keys in $A$ are strictly less than all keys in $B$,
(join (A, B))
evaluates to a bst containing
all keys in $A$ and $B$.val splitAt :
'a bst * key -> 'a bst * 'a option * 'a bst
(splitAt (T, k))
evaluates to $(L, m, R)$
where $L$ is a bst containing all keys less than $k$, $R$
is a bst containing all keys greater than $k$, and $m$ is
an option indicating if $k\in T$ (and if so, what value
$k$ is mapped to).