(index ("make-treap" 0))
(def (sig (procedure "make-treap:: KEY-COMPARE-PROC -> SELECTOR" (id make-treap))) (p "where " (tt "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.") (p "The returned selector procedure can take one of the following arguments:") (table (@ (class "symbol-table")) (tr (td "'get") (td "returns a procedure " (tt "LAMBDA KEY . DEFAULT-CLAUSE") " which searches the treap for an association with a given " (tt "KEY") ", and returns a (key . value) pair of the found association. If an association with " (tt "KEY") " cannot be located in the treap, the PROC returns the result of evaluating the " (tt "DEFAULT-CLAUSE") ". If the default clause is omitted, an error is signalled. " (tt "KEY") " must be comparable to the keys in the treap by a key-compare predicate (which has been specified when the treap was created)")) "\n" (tr (td "'get-min") (td "returns a (key . value) pair for an association in the treap with the smallest key. If the treap is empty, an error is signalled.")) "\n" (tr (td "'delete-min!") (td "removes the min key and the corresponding association from the treap. Returns a (key . value) pair of the removed association. If the treap is empty, an error is signalled. ")) "\n" (tr (td "'get-max") (td "returns a (key . value) pair for an association in the treap with the largest key. If the treap is empty, an error is signalled.")) "\n" (tr (td "'delete-max!") (td "removes the max key and the corresponding association from the treap. Returns a (key . value) pair of the removed association. If the treap is empty, an error is signalled.")) "\n" (tr (td "'empty?") (td "returns " (tt "#t") " if the treap is empty")) "\n" (tr (td "'size") (td "returns the size (the number of associations) in the treap")) "\n" (tr (td "'depth") (td "returns the depth of the tree. It requires the complete traversal of the tree, so use sparingly")) "\n" (tr (td "'clear!") (td "removes all associations from the treap (thus making it empty)")) "\n" (tr (td "'put!") (td "returns a procedure " (tt "LAMBDA KEY VALUE") " which, given a " (tt "KEY") " and a " (tt "VALUE") ", adds the corresponding association to the treap. If an association with the same " (tt "KEY") " already exists, its value is replaced with the " (tt "VALUE") " (and the old (key . value) association is returned). Otherwise, the return value is " (tt "#f") ".")) "\n" (tr (td "'delete!") (td "returns a procedure " (tt "LAMBDA KEY . DEFAULT-CLAUSE") " which searches the treap for an association with a given " (tt "KEY") ", deletes it, and returns a (key . value) pair of the found and deleted association. If an association with the KEY cannot be located in the treap, the " (tt "PROC") " returns the result of evaluating " (tt "DEFAULT-CLAUSE") ". If the default clause is omitted, an error is signalled. ")) "\n" (tr (td "'for-each-ascending") (td "returns a procedure " (tt "LAMBDA PROC") " that will apply the given procedure PROC to each (key . value) association of the treap, from the one with the smallest key all the way to the one with the max key, in an ascending order of keys. The treap must not be empty.")) "\n" (tr (td "'for-each-descending") (td "returns a procedure " (tt "LAMBDA PROC") " that will apply the given procedure " (tt "PROC") "to each (key . value) association of the treap, in the descending order of keys. The treap must not be empty.")) "\n" (tr (td "'debugprint") (td "prints out all the nodes in the treap, for debug purposes"))))
