diff options
| author | tslil <tslil@posteo.de> | 2026-03-24 18:27:04 +0000 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-03-24 18:31:24 +0000 |
| commit | 12455c6369547e970c4556bb20d8261eadc3b5ab (patch) | |
| tree | 94d7bb592e50b1eaa4954b50322af4534ae5036d /rprt-engine/src/selection.rs | |
| parent | 5ee9f5e935e147e5f16801a9cbe461f0585c6ba8 (diff) | |
big ole rename for consistent terminology: scalar, vector, matrix, tensor
Diffstat (limited to 'rprt-engine/src/selection.rs')
| -rw-r--r-- | rprt-engine/src/selection.rs | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/rprt-engine/src/selection.rs b/rprt-engine/src/selection.rs index 341c6ad..a3259b8 100644 --- a/rprt-engine/src/selection.rs +++ b/rprt-engine/src/selection.rs @@ -52,19 +52,19 @@ impl Interval { #[derive(Debug, Clone)] pub enum Selection { - Position { + Scalar { buffer_id: BufferID, pos: usize, }, - Range { + Vector { buffer_id: BufferID, interval: Interval, }, - Ranges { + Vectors { buffer_id: BufferID, ranges: Vec<Interval>, }, - MultiRanges { + MultiVectors { multi_ranges: HashMap<BufferID, Vec<Interval>>, }, } @@ -94,13 +94,13 @@ where impl Selection { pub fn empty() -> Self { - Self::MultiRanges { + Self::MultiVectors { multi_ranges: HashMap::new(), } } fn normalise(&mut self) { - if let Self::MultiRanges { multi_ranges } = self { + if let Self::MultiVectors { multi_ranges } = self { multi_ranges.retain(|_, v| !v.is_empty()) } } @@ -108,19 +108,19 @@ impl Selection { pub fn is_empty(&mut self) -> bool { self.normalise(); match self { - Self::Position { .. } => return false, - Self::Range { .. } => return false, - Self::Ranges { ranges, .. } => ranges.is_empty(), - Self::MultiRanges { multi_ranges } => multi_ranges.is_empty(), + Self::Scalar { .. } => return false, + Self::Vector { .. } => return false, + Self::Vectors { ranges, .. } => ranges.is_empty(), + Self::MultiVectors { multi_ranges } => multi_ranges.is_empty(), } } fn rank(&self) -> Rank { match self { - Self::Position { .. } => Rank::Zero, - Self::Range { .. } => Rank::One, - Self::Ranges { .. } => Rank::Two, - Self::MultiRanges { .. } => Rank::Three, + Self::Scalar { .. } => Rank::Zero, + Self::Vector { .. } => Rank::One, + Self::Vectors { .. } => Rank::Two, + Self::MultiVectors { .. } => Rank::Three, } } @@ -128,13 +128,13 @@ impl Selection { use Rank::*; match (self, to_rank) { - (Self::Position { .. }, Zero) => Ok(self.clone()), - (Self::Range { .. }, One) => Ok(self.clone()), - (Self::Ranges { .. }, Two) => Ok(self.clone()), - (Self::MultiRanges { .. }, Three) => Ok(self.clone()), + (Self::Scalar { .. }, Zero) => Ok(self.clone()), + (Self::Vector { .. }, One) => Ok(self.clone()), + (Self::Vectors { .. }, Two) => Ok(self.clone()), + (Self::MultiVectors { .. }, Three) => Ok(self.clone()), - // Position - (Self::Position { pos, buffer_id }, One) => Ok(Self::Range { + // Scalar + (Self::Scalar { pos, buffer_id }, One) => Ok(Self::Vector { interval: Interval { start: pos + 0, end: pos + 1, @@ -142,7 +142,7 @@ impl Selection { }, buffer_id: *buffer_id, }), - (Self::Position { pos, buffer_id }, Two) => Ok(Self::Ranges { + (Self::Scalar { pos, buffer_id }, Two) => Ok(Self::Vectors { ranges: vec![Interval { start: pos + 0, end: pos + 1, @@ -150,7 +150,7 @@ impl Selection { }], buffer_id: *buffer_id, }), - (Self::Position { pos, buffer_id }, Three) => { + (Self::Scalar { pos, buffer_id }, Three) => { let mut map = HashMap::new(); map.insert( *buffer_id, @@ -160,22 +160,22 @@ impl Selection { capture_groups: Vec::new(), }], ); - Ok(Self::MultiRanges { multi_ranges: map }) + Ok(Self::MultiVectors { multi_ranges: map }) } - // Range promotions + // Vector promotions ( - Self::Range { + Self::Vector { interval, buffer_id, }, Two, - ) => Ok(Self::Ranges { + ) => Ok(Self::Vectors { ranges: vec![interval.clone()], buffer_id: *buffer_id, }), ( - Self::Range { + Self::Vector { interval, buffer_id, }, @@ -183,14 +183,14 @@ impl Selection { ) => { let mut map = HashMap::new(); map.insert(*buffer_id, vec![interval.clone()]); - Ok(Self::MultiRanges { multi_ranges: map }) + Ok(Self::MultiVectors { multi_ranges: map }) } - // Ranges promotion - (Self::Ranges { ranges, buffer_id }, Three) => { + // Vectors promotion + (Self::Vectors { ranges, buffer_id }, Three) => { let mut map = HashMap::new(); map.insert(*buffer_id, ranges.clone()); - Ok(Self::MultiRanges { multi_ranges: map }) + Ok(Self::MultiVectors { multi_ranges: map }) } // all other cases @@ -203,10 +203,10 @@ impl Selection { fn buffers(&self) -> Vec<BufferID> { match self { - Self::Position { buffer_id, .. } => vec![*buffer_id], - Self::Range { buffer_id, .. } => vec![*buffer_id], - Self::Ranges { buffer_id, .. } => vec![*buffer_id], - Self::MultiRanges { multi_ranges } => multi_ranges.keys().copied().collect(), + Self::Scalar { buffer_id, .. } => vec![*buffer_id], + Self::Vector { buffer_id, .. } => vec![*buffer_id], + Self::Vectors { buffer_id, .. } => vec![*buffer_id], + Self::MultiVectors { multi_ranges } => multi_ranges.keys().copied().collect(), } } @@ -243,12 +243,12 @@ impl Selection { for sel in &promoted { match sel { - Self::Ranges { ranges, .. } => all_intervals.extend(ranges.clone()), - _ => unreachable!("promote() to Rank::Two should always produce Ranges"), + Self::Vectors { ranges, .. } => all_intervals.extend(ranges.clone()), + _ => unreachable!("promote() to Rank::Two should always produce Vectors"), } } - Ok(Self::Ranges { + Ok(Self::Vectors { ranges: all_intervals, buffer_id, }) @@ -259,7 +259,7 @@ impl Selection { for sel in &promoted { match sel { - Self::MultiRanges { multi_ranges } => { + Self::MultiVectors { multi_ranges } => { for (&buffer, intervals) in multi_ranges { buffer_intervals .entry(buffer) @@ -268,12 +268,12 @@ impl Selection { } } _ => unreachable!( - "promote() to Rank::Three should always produce MultiRanges" + "promote() to Rank::Three should always produce MultiVectors" ), } } - Ok(Self::MultiRanges { + Ok(Self::MultiVectors { multi_ranges: buffer_intervals, }) } @@ -299,18 +299,18 @@ impl Selection { }; match self { - &Self::Position { buffer_id, pos } => { + &Self::Scalar { buffer_id, pos } => { fn_rank_zero(state, buffer_id, pos).map_err(ProcessingError) } - Self::Range { + Self::Vector { interval, buffer_id, } => fn_rank_one(state, *buffer_id, interval).map_err(VectoriseError::ProcessingError), - Self::Ranges { buffer_id, ranges } => { + Self::Vectors { buffer_id, ranges } => { let results = do_rank_one(*buffer_id, ranges)?; Self::union(results).map_err(SelectionError) } - Self::MultiRanges { multi_ranges } => { + Self::MultiVectors { multi_ranges } => { let all_ok: Vec<Vec<Self>> = multi_ranges .iter() .map(|(buffer_id, ranges)| do_rank_one(*buffer_id, ranges)) |
