Returns the maximum value in a [DataTable].
(stream: &DataStream<'a, M, D>)
| 70 | |
| 71 | /// Returns the maximum value in a [DataTable]. |
| 72 | pub fn find_max_value<'a, M, D>(stream: &DataStream<'a, M, D>) -> D |
| 73 | where |
| 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]. |
| 98 | pub fn find_min_value<'a, M, D>(stream: &DataStream<'a, M, D>) -> D |
no outgoing calls
no test coverage detected