MCPcopy Create free account
hub / github.com/argumentcomputer/ix / ordered_insert

Function ordered_insert

crates/kernel/src/level.rs:354–363  ·  view source on GitHub ↗

Insert into a sorted list, returning `None` if already present.

(a: u64, list: &[u64])

Source from the content-addressed store, hash-verified

352
353fn norm_add_const(s: &mut NormLevel, k: u64, path: &[u64]) {
354 if k == 0 || (k == 1 && !path.is_empty()) {
355 return;
356 }
357 let node = s.entry(path.to_vec()).or_default();
358 node.constant = node.constant.max(k);
359}
360
361/// Insert into a sorted list, returning `None` if already present.
362fn ordered_insert(a: u64, list: &[u64]) -> Option<Vec<u64>> {
363 match list.binary_search(&a) {
364 Ok(_) => None,
365 Err(pos) => {
366 let mut result = list.to_vec();

Callers 2

normalize_auxFunction · 0.85
normalize_imax_dispatchFunction · 0.85

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected