MCPcopy Create free account
hub / github.com/PerroEngine/Perro / visible_items

Method visible_items

perro_source/core/perro_ui/src/tree.rs:134–150  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

132 }
133
134 pub fn visible_items(&self) -> Vec<UiTreeListVisibleItem> {
135 // Adjacency built in one pass; slot 0 = roots, slot idx+1 = children
136 // of item idx. Keeps the walk O(n) instead of re-scanning all items
137 // per node.
138 let len = self.items.len();
139 let mut children: Vec<Vec<usize>> = vec![Vec::new(); len + 1];
140 for (idx, item) in self.items.iter().enumerate() {
141 match item.parent {
142 None => children[0].push(idx),
143 Some(parent) if parent < len => children[parent + 1].push(idx),
144 Some(_) => {}
145 }
146 }
147 let mut out = Vec::new();
148 self.push_visible_children(&children, 0, 0, &mut out);
149 out
150 }
151
152 pub fn clear_items(&mut self) {
153 self.items.clear();

Calls 4

push_visible_childrenMethod · 0.80
lenMethod · 0.45
iterMethod · 0.45
pushMethod · 0.45