chickadee » slib-wt-tree » wt-tree/index-pair

wt-tree/index tree kprocedure
wt-tree/index-datum tree kprocedure
wt-tree/index-pair tree kprocedure

tree must not be empty, and k must be a positive exact integer.

Returns the 0-based kth association of tree in the sorted sequence of keys. wt-tree/index returns the kth key, wt-tree/index-datum returns the value associated with the kth key, and wt-tree/index-pair returns the kth association as a (KEY . VALUE) pair. If k(wt-tree/size tree), an error is signalled. (O(log n))

Example:

(let ((t (alist->wt-tree string-wt-type
                         '(("rincewind" . 23)
                           ("twoflower" . 11)
                           ("the luggage" . 31)))))
  (list (wt-tree/index t 1)
        (wt-tree/index-datum t 0)
        (wt-tree/index-pair t 2)))
; -> ("the luggage" 23 ("twoflower" . 11))