chickadee » rb-tree » rb-tree-map

rb-tree-map:procedure

where KEY-COMPARE-PROC is a user-supplied function that takes two keys and returns a negative, positive, or zero number depending on how the first key compares to the second.

Optional keyword argument insdel-key-compare can be used to specify different key comparison predicates for the insertion and deletion operations.

The <PersistentMap> typeclass contains the following operations:

empty
returns a new empty tree
empty? TREE
returns #t if the given tree is empty
get TREE
returns a procedure of the form (LAMBDA KEY . DEFAULT-CLAUSE which searches the given tree for an association with a given KEY, and returns a (key . value) pair of the found association. If an association with KEY cannot be located in the tree, the procedure returns the result of evaluating the DEFAULT-CLAUSE. If the default clause is omitted, an error is signalled. KEY must be comparable to the keys in the tree by a key-compare predicate (which has been specified when the tree was created)
get-value TREE
returns a procedure of the form (LAMBDA KEY . DEFAULT-CLAUSE which searches the tree for an association with a given KEY, and returns the value of (key . value) pair of the found association. If an association with KEY cannot be located in the tree, the procedure returns the result of evaluating the DEFAULT-CLAUSE. If the default clause is omitted, an error is signalled. KEY must be comparable to the keys in the tree by a key-compare predicate (which has been specified when the tree was created)
get-min TREE
returns a (key . value) pair for an association in the tree with the smallest key. If the tree is empty, an error is signalled.
get-max TREE
returns a (key . value) pair for an association in the tree with the largest key. If the tree is empty, an error is signalled.
size TREE
returns the size (the number of associations) in the tree
put TREE KEY VALUE
returns a new tree object that contains the given association
delete TREE KEY . DEFAULT-CLAUSE
if the specified key is found, it returns a new tree object that no longer contains the association specified by that key, while the original tree object is unmodified. If the key is not found, the procedure returns the result of evaluating DEFAULT-CLAUSE
for-each-ascending TREE
returns a procedure LAMBDA PROC that will apply the given procedure PROC to each (key . value) association of the tree, from the one with the smallest key all the way to the one with the max key, in an ascending order of keys.
for-each-descending TREE
returns a procedure LAMBDA PROC that will apply the given procedure PROCto each (key . value) association of the tree, in the descending order of keys.
map TREE
returns a procedure LAMBDA PROC that will apply the given procedure PROCto the value component of each association in the tree, in the ascending order of keys, and will construct a copy of the tree that contains the values returned by that procedure.
mapi TREE
returns a procedure LAMBDA PROC that will apply the given procedure PROCto each (key . value) association in the tree, in the ascending order of keys, and will construct a copy of the tree that contains the values returned by that procedure.
fold TREE
returns a procedure LAMBDA PROC INITIAL such that, given the associations in the tree ordered by the descending order of keys: (key-n . value-n) ... (key-2 . value-2) (key-1 . value-1) the procedure returns the result of the successive function applications (PROC value-1 (PROC value-2 ... (PROC value-n INITIAL).
foldi TREE
returns a procedure LAMBDA PROC INITIAL such that, given the associations in the tree ordered by the descending order of keys: (key-n . value-n) ... (key-2 . value-2) (key-1 . value-1) the procedure returns the result of the successive function applications (PROC key-1 value-1 (PROC key-2 value-2 ... (PROC key-n value-n INITIAL).
fold-right TREE
returns a procedure LAMBDA PROC INITIAL such that, given the associations in the tree ordered by the ascending order of keys: (key-1 . value-1) (key-2 . value-2) ... (key-n . value-n) the procedure returns the result of the successive function applications (PROC value-n ... (PROC value-2 (PROC value-1 INITIAL).
foldi-right TREE
returns a procedure LAMBDA PROC INITIAL such that, given the associations in the tree ordered by the ascending order of keys: (key-1 . value-1) (key-2 . value-2) ... (key-n . value-n) the procedure returns the result of the successive function applications (PROC key-n value-n ... (PROC key-2 value-2 (PROC key-1 value-1 INITIAL).
fold-partial TREE
returns a procedure LAMBDA PRED PROC INITIAL such that, given the associations in the tree ordered by the descending order of keys: (key-n . value-n) ... (key-2 . value-2) (key-1 . value-1) the procedure returns the result of the successive function applications (PROC value-i ... (PROC value-n INITIAL), where i <= n and (PRED x) holds true for all x = (value-n) ... (value-i). In other words, this function acts like fold on the ordered subset of the values x in the tree such that (PRED x) is true.
foldi-partial TREE
returns a procedure LAMBDA PRED PROC INITIAL such that, given the associations in the tree ordered by the descending order of keys: (key-n . value-n) ... (key-2 . value-2) (key-1 . value-1) the procedure returns the result of the successive function applications (PROC key-i value-i ... (PROC key-n value-n INITIAL), where i <= n and (PRED xk x) holds true for all x = (value-n) ... (value-i) and xk = (key-n) ... (key-i). In other words, this function acts like foldi on the ordered subset of the key-value pairs (k . x) in the tree such that (PRED k x) is true.
fold-right-partial TREE
returns a procedure LAMBDA PRED PROC INITIAL such that, given the associations in the tree ordered by the ascending order of keys: (key-1 . value-1) (key-2 . value-2) ... (key-n . value-n) the procedure returns the result of the successive function applications (PROC value-1 ... (PROC value-i INITIAL), where i <= n and (PRED x) holds true for all x = (value-1) ... (value-i). In other words, this function acts like fold-right on the ordered subset of the values x in the tree such that (PRED x) is true.
foldi-right-partial TREE
returns a procedure LAMBDA PRED PROC INITIAL such that, given the associations in the tree ordered by the descending order of keys: (key-1 . value-1) (key-2 . value-2) ... (key-1 . value-1) the procedure returns the result of the successive function applications (PROC key-1 value-1 ... (PROC key-i value-i INITIAL), where i <= n and (PRED xk x) holds true for all x = (value-1) ... (value-i) and xk = (key-1) ... (key-i). In other words, this function acts like foldi-right on the ordered subset of the key-value pairs (k . x) in the tree such that (PRED k x) is true.
fold-limit TREE
returns a procedure LAMBDA PRED PROC INITIAL such that, given the associations in the tree ordered by the descending order of keys: (key-n . value-n) ... (key-2 . value-2) (key-1 . value-1) the procedure returns the result of the successive function applications (PROC value-i ... (PROC value-n INITIAL), where i <= n and (PRED x) does not hold true for all x = (PROC value-n INITIAL) ... (PROC (value-i) (PROC value-(i-1)....
fold-right-limit TREE
returns a procedure LAMBDA PRED PROC INITIAL such that, given the associations in the tree ordered by the descending order of keys: (key-1 . value-1) (key-2 . value-2) ... (key-i . value-1) the procedure returns the result of the successive function applications (PROC value-i ... (PROC value-1 INITIAL), where i <= n and (PRED x) does not hold true for all x = (PROC value-1 INITIAL) ... (PROC (value-i) (PROC value-(i-1)....