6.3.4 WB-Map Operations

These operations make use of the ordering of the map, as determined by its key comparison function. They are not defined on CHAMP maps.

Method: rank (wb-map)  m x

If m contains key x, returns the rank of x in the ordering defined by the key comparison function of m, and a true second value. If x is not in the map, the second value is false, and the first value is the rank that x would have if it were added. Note that if there are keys that are unequal but equivalent to x, an arbitrary order will be imposed on them for this purpose; but another collection that is equal? but not eq to this one will in general order them differently. O(log n).

Method: at-rank (wb-map)  m rank

Returns the pair whose rank is rank. rank must be in [0 .. size(m)). Note that if there are keys that are unequal but equivalent in m, an arbitrary order will be imposed on them for this purpose; but another collection that is equal? but not eq to this one will in general order them differently. O(log n).

Method: least (wb-map)  m

If m is nonempty, returns the pair at rank 0 and a true third value; otherwise, nil, nil, and false.

Method: greatest (wb-map)  m

If m is nonempty, returns the pair with the largest rank and a true third value; otherwise, nil, nil, and false.

Method: split-from (wb-map)  m x

Returns the submap of m with keys greater than or equal to x. O(log n).

Method: split-above (wb-map)  m x

Returns the submap of m with keys strictly greater than x. O(log n) in general; O(1) if x is the first value of (arb m).

Method: split-through (wb-map)  m x

Returns the submap of m with keys less than or equal to x. O(log n).

Method: split-below (wb-map)  m x

Returns the submap of m with keys strictly less than x. O(log n) in general; O(1) if x is the result of (arb m).