MCPcopy Create free account
hub / github.com/angular-rust/ux-charts / find_max_value

Function find_max_value

src/utils.rs:72–95  ·  view source on GitHub ↗

Returns the maximum value in a [DataTable].

(stream: &DataStream<'a, M, D>)

Source from the content-addressed store, hash-verified

70
71/// Returns the maximum value in a [DataTable].
72pub fn find_max_value<'a, M, D>(stream: &DataStream<'a, M, D>) -> D
73where
74 M: fmt::Display,
75 D: fmt::Display + Copy + Into<f64> + Ord + Default,
76{
77 let mut result: Option<D> = None;
78 for channel in stream.meta.iter() {
79 let channel_index = channel.tag as u64;
80 for frame in stream.frames.iter() {
81 if let Some(value) = frame.data.get(channel_index) {
82 match result {
83 Some(max_value) => {
84 if *value > max_value {
85 result = Some(*value);
86 }
87 }
88 None => result = Some(*value),
89 }
90 }
91 }
92 }
93
94 result.unwrap_or_default()
95}
96
97/// Returns the minimum value in a [DataTable].
98pub fn find_min_value<'a, M, D>(stream: &DataStream<'a, M, D>) -> D

Callers 3

Calls

no outgoing calls

Tested by

no test coverage detected