MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / get_or_less

Method get_or_less

cranelift/bforest/src/map.rs:117–130  ·  view source on GitHub ↗

Look up the value stored for `key`. If it exists, return the stored key-value pair. Otherwise, return the last key-value pair with a key that is less than or equal to `key`. If no stored keys are less than or equal to `key`, return `None`.

(
        &self,
        key: K,
        forest: &MapForest<K, V>,
        comp: &C,
    )

Source from the content-addressed store, hash-verified

115 ///
116 /// If no stored keys are less than or equal to `key`, return `None`.
117 pub fn get_or_less<C: Comparator<K>>(
118 &self,
119 key: K,
120 forest: &MapForest<K, V>,
121 comp: &C,
122 ) -> Option<(K, V)> {
123 self.root.expand().and_then(|root| {
124 let mut path = Path::default();
125 match path.find(key, root, &forest.nodes, comp) {
126 Some(v) => Some((key, v)),
127 None => path.prev(root, &forest.nodes),
128 }
129 })
130 }
131
132 /// Insert `key, value` into the map and return the old value stored for `key`, if any.
133 pub fn insert<C: Comparator<K>>(

Callers

nothing calls this directly

Calls 3

expandMethod · 0.45
findMethod · 0.45
prevMethod · 0.45

Tested by

no test coverage detected