ceiling_of: Get the smallest key greater than or equal to a given key

Description Usage Arguments Details Examples

Description

Get the smallest key greater than or equal to a given key

Usage

1
ceiling_of(tree, key, ...)

Arguments

tree

A bst

key

The key to use in comparisons

...

Other arguments (not used)

Details

If the key exists in the tree, then it is returned. If the key is larger than the largest key in the tree, then NULL is returned. Otherwise, the smallest key that is greater than the given key is returned.

Examples

1
2
3
4
5
mytree <- bst()
mytree <- insert(mytree, 1, "val1")
mytree <- insert(mytree, 3, "val2")
retrieve(mytree, ceiling_of(mytree, 2))
retrieve(mytree, floor_of(mytree, 3))

tarakc02/rbst documentation built on May 31, 2019, 3:55 a.m.