is the tree rooted at x a BST with all keys strictly between min and max (if min or max is null, treat as empty constraint)
(x: Option<NonNull<Node<K, V>>>, min: Option<&K>, max: Option<&K>)
| 260 | /// is the tree rooted at x a BST with all keys strictly between min and max |
| 261 | /// (if min or max is null, treat as empty constraint) |
| 262 | pub fn is_bst<K, V>(x: Option<NonNull<Node<K, V>>>, min: Option<&K>, max: Option<&K>) -> bool |
| 263 | where |
| 264 | K: Ord, |
| 265 | { |
| 266 | x.map_or(true, |x| { |
| 267 | let x = NodeQuery::new(Some(x)); |
| 268 | let key = x.get_key(); |
| 269 | if (min.is_some() && key.lt(&min)) || (max.is_some() && key.gt(&max)) { |
| 270 | false |
| 271 | } else { |
| 272 | is_bst(x.left().node, min, key) && is_bst(x.right().node, key, max) |
| 273 | } |
| 274 | }) |
| 275 | } |
| 276 | |
| 277 | /// Returns the number of key-value pairs |
| 278 | pub fn calc_size<K, V>(x: Option<NonNull<Node<K, V>>>) -> usize { |