Skip to content

Commit

Permalink
reinstate into_iter1
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed Dec 16, 2022
1 parent 0761f89 commit 061953d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions provider/datagen/src/transform/cldr/decimal/compact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ mod tests {
.iter0()
.flat_map(|kkv| {
let key0 = *kkv.key0();
kkv.iter1()
kkv.into_iter1()
.map(move |(k, v)| (key0, Count::from_unaligned(*k), Pattern::zero_from(v)))
})
.collect();
Expand Down Expand Up @@ -222,7 +222,7 @@ mod tests {
.iter0()
.flat_map(|kkv| {
let key0 = *kkv.key0();
kkv.iter1()
kkv.into_iter1()
.map(move |(k, v)| (key0, Count::from_unaligned(*k), Pattern::zero_from(v)))
})
.collect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ mod tests {
.iter0()
.flat_map(|kkv| {
let key0 = *kkv.key0();
kkv.iter1()
kkv.into_iter1()
.map(move |(k, v)| (key0, Count::from_unaligned(*k), Pattern::zero_from(v)))
})
.collect();
Expand Down Expand Up @@ -532,7 +532,7 @@ mod tests {
.iter0()
.flat_map(|kkv| {
let key0 = *kkv.key0();
kkv.iter1()
kkv.into_iter1()
.map(move |(k, v)| (key0, Count::from_unaligned(*k), Pattern::zero_from(v)))
})
.collect();
Expand Down
19 changes: 19 additions & 0 deletions utils/zerovec/src/map2d/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,25 @@ where
})
}

/// Transform this cursor into an ordered iterator over keys1 for a particular key0.
pub fn into_iter1(
self,
) -> impl Iterator<
Item = (
&'l <K1 as ZeroMapKV<'a>>::GetType,
&'l <V as ZeroMapKV<'a>>::GetType,
),
> {
let range = self.get_range();
#[allow(clippy::unwrap_used)] // `self.get_range()` returns a valid range
range.map(move |idx| {
(
self.keys1.zvl_get(idx).unwrap(),
self.values.zvl_get(idx).unwrap(),
)
})
}

/// Given key0_index, returns the corresponding range of keys1, which will be valid
pub(super) fn get_range(&self) -> Range<usize> {
debug_assert!(self.key0_index < self.joiner.len());
Expand Down

0 comments on commit 061953d

Please sign in to comment.