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

Method with_capacity

atomic-core/src/apply/workspace.rs:356–375  ·  view source on GitHub ↗

Create a workspace with pre-allocated capacity. Use this when you know approximately how many items will be processed. # Arguments `context_capacity` - Expected number of context positions `edge_capacity` - Expected number of edges # Example ```rust use atomic_core::apply::Workspace; // Pre-allocate for a large change let workspace = Workspace::with_capacity(100, 500); ```

(context_capacity: usize, edge_capacity: usize)

Source from the content-addressed store, hash-verified

354 /// let workspace = Workspace::with_capacity(100, 500);
355 /// ```
356 pub fn with_capacity(context_capacity: usize, edge_capacity: usize) -> Self {
357 Self {
358 predecessors: Vec::with_capacity(context_capacity),
359 successors: Vec::with_capacity(context_capacity),
360 predecessor_vertices: Vec::with_capacity(context_capacity),
361 successor_vertices: Vec::with_capacity(context_capacity),
362 current_vertices_by_start: HashMap::with_capacity(context_capacity),
363 current_vertices_by_end: HashMap::with_capacity(context_capacity),
364 pending_edges: Vec::with_capacity(edge_capacity),
365 deleted_edges: HashSet::with_capacity(edge_capacity / 10),
366 parents: HashMap::with_capacity(context_capacity),
367 children: HashMap::with_capacity(context_capacity),
368 missing_contexts: Vec::new(),
369 zombies: Vec::new(),
370 rooted: HashSet::with_capacity(context_capacity),
371 adjacency_buffer: Vec::with_capacity(32),
372 traversal_stack: Vec::with_capacity(64),
373 visited: HashSet::with_capacity(context_capacity),
374 }
375 }
376
377 /// Clear all workspace state for reuse.
378 ///

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected