Skip to content

Commit

Permalink
Merge pull request #295 from Dr-Emann/push-wlprxywvqwns
Browse files Browse the repository at this point in the history
Lazily compute Iterator len
  • Loading branch information
Kerollmops authored Oct 30, 2024
2 parents c4e3b34 + 820b270 commit 07d6bc3
Show file tree
Hide file tree
Showing 5 changed files with 370 additions and 46 deletions.
17 changes: 17 additions & 0 deletions roaring/src/bitmap/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,21 @@ impl Iterator for Iter<'_> {
fn next(&mut self) -> Option<u32> {
self.inner.next().map(|i| util::join(self.key, i))
}

fn size_hint(&self) -> (usize, Option<usize>) {
self.inner.size_hint()
}

fn count(self) -> usize
where
Self: Sized,
{
self.inner.count()
}

fn nth(&mut self, n: usize) -> Option<Self::Item> {
self.inner.nth(n).map(|i| util::join(self.key, i))
}
}

impl DoubleEndedIterator for Iter<'_> {
Expand All @@ -308,6 +323,8 @@ impl DoubleEndedIterator for Iter<'_> {
}
}

impl ExactSizeIterator for Iter<'_> {}

impl fmt::Debug for Container {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
format!("Container<{:?} @ {:?}>", self.len(), self.key).fmt(formatter)
Expand Down
Loading

0 comments on commit 07d6bc3

Please sign in to comment.