Struct djinn::Population
[−]
[src]
pub struct Population<S: Simulation, C: Redis> { pub conn: C, // some fields omitted }
An interface to the Redis-backed agent population.
Fields
conn: C
Methods
impl<S: Simulation, C: Redis> Population<S, C>
[src]
fn new(simulation: S, conn: C) -> Population<S, C>
fn count(&self) -> usize
Count the population size.
fn world(&self) -> S::World
Get the world (state).
fn set_world(&self, world: S::World)
Set the world state.
fn get_agent(&self, id: u64) -> Option<Agent<S::State>>
Get an agent by id.
fn get_agents(&self, ids: Vec<u64>) -> Vec<Agent<S::State>>
Get agents by ids. If you need to fetch multiple agents, you should use this as it makes only one network request.
fn set_agent(&self, id: u64, state: &S::State)
Set an agent state by id.
fn set_agents(&self, updates: &Vec<(u64, &S::State)>)
Set multple agent states by ids. If you need to update multiple agents, you should use this as it makes only one network request.
fn update(&self)
Process queued updates (kill/spawn).
fn lookup(&self, index: &str) -> Vec<Agent<S::State>>
Lookup agents at a particular index.
fn random(&self, index: &str) -> Agent<S::State>
Select a random agent from an index.
fn randoms(&self, index: &str, count: usize) -> Vec<Agent<S::State>>
Select random agents from an index.
fn count_index(&self, index: &str) -> usize
Count the members of an index.
fn index(&self, index: &str, id: u64)
Add an agent (id) to an index.
fn indexes(&self, index: &str, ids: Vec<u64>)
Add agents (ids) to an index.
fn unindex(&self, index: &str, id: u64)
Remove an agent (id) from an index.
fn unindexes(&self, index: &str, ids: Vec<u64>)
Remove an agent (id) from an index.
fn reset_indices(&self)
Reset all indices.
fn reset(&self)
Reset the population; i.e. deletes all agents and updates from Redis and resets all indices.
Trait Implementations
impl<S: Clone + Simulation, C: Clone + Redis> Clone for Population<S, C>
[src]
fn clone(&self) -> Population<S, C>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more