pub struct SimulationDatabase {
pub rows: Vec<DbRow>,
pub name: String,
}Expand description
A simple in-memory relational table for simulation data.
Supports insert, column-based equality filtering, and projection.
Fields§
§rows: Vec<DbRow>All rows stored in the table.
name: StringTable name for metadata/export purposes.
Implementations§
Source§impl SimulationDatabase
impl SimulationDatabase
Sourcepub fn query_eq(&self, col: &str, val: &DbValue) -> Vec<&DbRow>
pub fn query_eq(&self, col: &str, val: &DbValue) -> Vec<&DbRow>
Query rows where column col equals val.
Sourcepub fn query_range(&self, col: &str, lo: f64, hi: f64) -> Vec<&DbRow>
pub fn query_range(&self, col: &str, lo: f64, hi: f64) -> Vec<&DbRow>
Query rows where column col (numeric) is in [lo, hi].
Sourcepub fn project(&self, cols: &[&str]) -> Vec<HashMap<String, DbValue>>
pub fn project(&self, cols: &[&str]) -> Vec<HashMap<String, DbValue>>
Return a projected view: for each row, extract the listed columns.
Sourcepub fn delete_eq(&mut self, col: &str, val: &DbValue) -> usize
pub fn delete_eq(&mut self, col: &str, val: &DbValue) -> usize
Delete all rows where column col equals val.
Returns the number of rows deleted.
Sourcepub fn column_mean(&self, col: &str) -> Option<f64>
pub fn column_mean(&self, col: &str) -> Option<f64>
Compute the mean of a numeric column across all rows.
Returns None if no numeric values are found.
Trait Implementations§
Source§impl Debug for SimulationDatabase
impl Debug for SimulationDatabase
Source§impl Default for SimulationDatabase
impl Default for SimulationDatabase
Source§fn default() -> SimulationDatabase
fn default() -> SimulationDatabase
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SimulationDatabase
impl RefUnwindSafe for SimulationDatabase
impl Send for SimulationDatabase
impl Sync for SimulationDatabase
impl Unpin for SimulationDatabase
impl UnsafeUnpin for SimulationDatabase
impl UnwindSafe for SimulationDatabase
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.