pub struct StepContext<'a, S, A, Props, R, Sch>where
A: Agent,{ /* private fields */ }Expand description
Safe context passed to agent step functions.
Provides mutable access to space, properties, RNG, and the deferred-action buffer without aliasing the agent store or the current agent’s borrow.
§Type parameters
S- the space typeA- the agent typeProps- user-defined model propertiesR- the RNG typeSch- the scheduler type
Implementations§
Source§impl<'a, S, A, Props, R, Sch> StepContext<'a, S, A, Props, R, Sch>where
A: Agent,
impl<'a, S, A, Props, R, Sch> StepContext<'a, S, A, Props, R, Sch>where
A: Agent,
Sourcepub fn properties(&self) -> &Props
pub fn properties(&self) -> &Props
Immutable reference to user-defined model properties.
Sourcepub fn properties_mut(&mut self) -> &mut Props
pub fn properties_mut(&mut self) -> &mut Props
Mutable reference to user-defined model properties.
Sourcepub fn scheduler(&mut self) -> &mut Sch
pub fn scheduler(&mut self) -> &mut Sch
Mutable reference to the scheduler (rarely needed by user code).
Sourcepub fn defer_remove_agent(&mut self, id: AgentId)
pub fn defer_remove_agent(&mut self, id: AgentId)
Schedule an agent for removal after the current step completes.
With StandardModel::step, the removal is applied to the store only.
With StandardModel::step_spatial, the removal is applied to both the
store and the spatial index.
Sourcepub fn defer_insert_agent(&mut self, agent: A)
pub fn defer_insert_agent(&mut self, agent: A)
Schedule an agent for insertion after the current step completes.
With StandardModel::step, the insertion is applied to the store only.
With StandardModel::step_spatial, the insertion is applied to both
the store and the spatial index.