MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / make_dict

Function make_dict

nodedb-array/src/codec/coord_delta.rs:271–286  ·  view source on GitHub ↗
(coords: &[i64])

Source from the content-addressed store, hash-verified

269 }
270
271 fn make_dict(coords: &[i64]) -> DimDict {
272 let mut d = DimDict {
273 values: vec![],
274 indices: vec![],
275 };
276 for &c in coords {
277 let cv = CoordValue::Int64(c);
278 if let Some(idx) = d.values.iter().position(|x| x == &cv) {
279 d.indices.push(idx as u32);
280 } else {
281 d.indices.push(d.values.len() as u32);
282 d.values.push(cv);
283 }
284 }
285 d
286 }
287
288 #[test]
289 fn empty_dict_roundtrip() {

Callers 5

single_entry_roundtripFunction · 0.70
large_coord_roundtripFunction · 0.70

Calls 3

iterMethod · 0.45
pushMethod · 0.45
lenMethod · 0.45

Tested by 5

single_entry_roundtripFunction · 0.56
large_coord_roundtripFunction · 0.56