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

Method insert

perro_source/runtime_project/perro_runtime/src/cns/node_arena.rs:153–184  ·  view source on GitHub ↗

Insert a node and return its current slot/generation id. Reuses a free slot when available. Otherwise appends a new slot.

(&mut self, node: SceneNode)

Source from the content-addressed store, hash-verified

151
152 /// Create an empty arena.
153 ///
154 /// Slot 0 is reserved as the nil sentinel, so the first inserted node uses
155 /// index 1.
156 pub fn new() -> Self {
157 // Reserve index 0 as invalid/nil sentinel so first real node ID is 1.
158 let mut nodes = Vec::with_capacity(2);
159 let mut generations = Vec::with_capacity(2);
160 nodes.push(None);
161 generations.push(0);
162 Self {
163 nodes,
164 generations,
165 node_types: vec![NodeType::Node],
166 parents: vec![NodeID::nil()],
167 packed_child_offsets: vec![0, 0],
168 packed_child_ids: Vec::new(),
169 packed_children_revision: 0,
170 free_indices: Vec::new(),
171 name_index: AHashMap::default(),
172 tag_index: AHashMap::default(),
173 active_len: 0,
174 mutation_revision: 0,
175 physics_revision: 0,
176 structural_revision: 0,
177 }
178 }
179
180 /// Create an empty arena with capacity for active nodes.
181 ///
182 /// The internal vectors reserve one extra slot for the nil sentinel.
183 pub fn with_capacity(capacity: usize) -> Self {
184 // +1 for reserved nil sentinel slot at index 0.
185 let mut nodes = Vec::with_capacity(capacity.saturating_add(1));
186 let mut generations = Vec::with_capacity(capacity.saturating_add(1));
187 nodes.push(None);

Callers 15

sanitize_panim_identFunction · 0.45
push_recent_node_typeFunction · 0.45
add_recent_projectFunction · 0.45
filtered_file_pathsFunction · 0.45
file_dirs_with_childrenFunction · 0.45
sanitize_node_nameFunction · 0.45
inspector_tag_rowsFunction · 0.45

Calls 7

bump_mutation_versionMethod · 0.80
cloneMethod · 0.80
node_typeMethod · 0.80
popMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45
is_emptyMethod · 0.45

Tested by 15

inspector_tag_rowsFunction · 0.36
parse_script_importsFunction · 0.36
module_name_from_relFunction · 0.36
sample_profileFunction · 0.36