MCPcopy Create free account
hub / github.com/douchuan/algorithm / put_dth

Method put_dth

src/strings/tries.rs:140–161  ·  view source on GitHub ↗
(
        &mut self,
        x: Option<NonNull<Node<T>>>,
        key: &str,
        val: Option<T>,
        d: usize,
    )

Source from the content-addressed store, hash-verified

138 }
139
140 unsafe fn put_dth(
141 &mut self,
142 x: Option<NonNull<Node<T>>>,
143 key: &str,
144 val: Option<T>,
145 d: usize,
146 ) -> Option<NonNull<Node<T>>> {
147 let mut x = x.unwrap_or_else(|| Node::new(None));
148
149 if d == key.len() {
150 if x.as_ref().val.is_none() {
151 self.n += 1;
152 }
153 x.as_mut().val = val;
154 } else {
155 let i = common::util::byte_at(key, d);
156 let next = x.as_ref().next[i];
157 x.as_mut().next[i] = self.put_dth(next, key, val, d + 1);
158 }
159
160 Some(x)
161 }
162
163 unsafe fn delete_dth(
164 &mut self,

Callers 1

putMethod · 0.80

Calls 3

byte_atFunction · 0.85
is_noneMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected