pub struct ScenarioSet<T> { /* private fields */ }Expand description
The common module records and containers. These explicit facade exports keep ordinary callers out of the component crate paths. Named alternatives with no implied time order.
Implementations§
Source§impl<T> ScenarioSet<T>
impl<T> ScenarioSet<T>
pub fn new(scenarios: Vec<Scenario<T>>) -> Result<ScenarioSet<T>, Error>
Sourcepub fn get(&self, id: &str) -> Option<&T>
pub fn get(&self, id: &str) -> Option<&T>
Look one scenario value up by its stable ID. Constant time: IDs are case sensitive and never normalized, and the index is built once.
Sourcepub fn entry(&self, id: &str) -> Option<&Scenario<T>>
pub fn entry(&self, id: &str) -> Option<&Scenario<T>>
Look up the complete scenario entry by its stable ID.
Sourcepub fn get_at(&self, position: usize) -> Option<&T>
pub fn get_at(&self, position: usize) -> Option<&T>
Look up one scenario value by its insertion position.
Sourcepub fn entry_at(&self, position: usize) -> Option<&Scenario<T>>
pub fn entry_at(&self, position: usize) -> Option<&Scenario<T>>
Look up one complete scenario entry by its insertion position.
pub fn iter(&self) -> impl ExactSizeIterator
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Source§impl<T> ScenarioSet<T>where
T: Clone,
impl<T> ScenarioSet<T>where
T: Clone,
Sourcepub fn get_mut(&mut self, id: &str) -> Option<&mut T>
pub fn get_mut(&mut self, id: &str) -> Option<&mut T>
Mutably borrow one scenario value by ID through copy on write.
Sourcepub fn entry_mut(&mut self, id: &str) -> Option<&mut Scenario<T>>
pub fn entry_mut(&mut self, id: &str) -> Option<&mut Scenario<T>>
Mutably borrow one complete scenario entry by ID through copy on write. Its public mutable surface exposes only the value, preserving the validated ID index and probability sum.
Sourcepub fn get_at_mut(&mut self, position: usize) -> Option<&mut T>
pub fn get_at_mut(&mut self, position: usize) -> Option<&mut T>
Mutably borrow one scenario value by insertion position.
Sourcepub fn entry_at_mut(&mut self, position: usize) -> Option<&mut Scenario<T>>
pub fn entry_at_mut(&mut self, position: usize) -> Option<&mut Scenario<T>>
Mutably borrow one complete scenario entry by insertion position.
Sourcepub fn iter_mut(&mut self) -> impl ExactSizeIterator
pub fn iter_mut(&mut self) -> impl ExactSizeIterator
Iterate over mutable scenario entries through one copy on write detachment. Entry identities and probabilities remain immutable.
Sourcepub fn map_values<U>(self, map: impl FnMut(T) -> U) -> ScenarioSet<U>
pub fn map_values<U>(self, map: impl FnMut(T) -> U) -> ScenarioSet<U>
Consume the set and map each scenario value while retaining identities, probabilities, order, and the already validated identity index. A uniquely owned set moves its values without cloning them; a shared set first performs the copy on write split.
Trait Implementations§
Source§impl<T> Clone for ScenarioSet<T>
impl<T> Clone for ScenarioSet<T>
Source§fn clone(&self) -> ScenarioSet<T>
fn clone(&self) -> ScenarioSet<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more