File "tree"
This Prolog text provides a non-backtracking red-black tree. The
predicate tree_current/3 allows accessing a value from a red-black
tree by a key. The predicates tree_set/3 and tree_add/3 are
destructive and modify the red-black tree via change_arg/3.
The predicates tree_set/4 and tree_add/4 are non-destructive and
return a red-black tree.
The following hash table predicates are provided:
- tree_enum(T, P):
- The predicate succeeds in P with the key value pairs from the
red-black tree T.
- tree_pairs(T, L):
- The predicate succeeds in L with the key value pair list from
the red-black tree T.
- tree_new(T):
- The predicate succeeds in R with a new red-black tree.
- tree_size(T, S):
- The predicate succeeds in S with the number of key value pairs
of the red-black tree T.
- tree_current(T, K, V):
- The predicate succeeds in V with the value for the key K in
the red-black tree T.
- tree_set(T, K, V):
- The predicate succeeds. As a side effect the red-black tree T
is extended by the key value pair K,V if the key is new or else
the value for the K is replaced by V.
- tree_add(T, K, V):
- The predicate succeeds if the key is new. As a side effect the
red-black tree T is extended by the key value pair K,V.
- tree_set(T, K, V, T2):
- The predicate succeeds. It unifies T2 with the red-black tree
T is extended by the key value pair K,V if the key is new or
else the value for the K is replaced by V.
- tree_add(T, K, V, T2):
- The predicate succeeds if the key is new. It unifies T2 with
the red-black tree T extended by the key value pair K,V.
Kommentare