Skip to main content

Module store

Module store 

Source
Expand description

Agent containers - storage backends for the agent population.

Two implementations are provided:

  • HashMapStore - backed by hashbrown::HashMap. General-purpose; supports arbitrary agent addition and removal. Best when agents are frequently created or destroyed.

  • VecStore - backed by a Vec<Option<RefCell<A>>> indexed by agent ID. Faster iteration for dense, contiguous ID ranges. Best when agents are never (or rarely) removed.

Both stores use RefCell for interior mutability, allowing agent step functions to borrow one agent mutably while reading others immutably.

§Determinism note

Store iteration order is part of simulation reproducibility whenever a scheduler or caller relies on iter_ids() / iter_ids_into() without an additional ordering step.

  • VecStore iterates in ascending ID order.
  • HashMapStore iteration order is not guaranteed and must not be treated as a reproducible activation order.

For deterministic activation order across runs, prefer crate::scheduler::ById or another scheduler that imposes an explicit order.

Structs§

HashMapStore
Hash-map-based agent store.
VecStore
Dense vector-based agent store.

Traits§

AgentStore
Trait for agent containers.