MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / visit

Function visit

atomic-cli/src/commands/view/list.rs:307–326  ·  view source on GitHub ↗
(
        entry: &'a ViewEntry,
        depth: usize,
        children: &HashMap<&str, Vec<&'a ViewEntry>>,
        visited: &mut HashSet<&'a str>,
        visible: &HashSet<String>,
        ordered: 

Source from the content-addressed store, hash-verified

305 roots.sort_by(|a, b| a.name.cmp(&b.name));
306
307 fn visit<'a>(
308 entry: &'a ViewEntry,
309 depth: usize,
310 children: &HashMap<&str, Vec<&'a ViewEntry>>,
311 visited: &mut HashSet<&'a str>,
312 visible: &HashSet<String>,
313 ordered: &mut Vec<(usize, &'a ViewEntry)>,
314 ) {
315 if !visited.insert(entry.name.as_str()) {
316 return; // cut parent cycles
317 }
318 if visible.contains(&entry.name) {
319 ordered.push((depth, entry));
320 }
321 if let Some(kids) = children.get(entry.name.as_str()) {
322 for kid in kids {
323 visit(kid, depth + 1, children, visited, visible, ordered);
324 }
325 }
326 }
327
328 let mut ordered = Vec::new();
329 let mut visited: HashSet<&str> = HashSet::new();

Callers 1

tree_orderFunction · 0.70

Calls 5

getMethod · 0.65
insertMethod · 0.45
as_strMethod · 0.45
containsMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected