Skip to content

Commit 07d6bc3

Browse files
authored
Merge pull request #295 from Dr-Emann/push-wlprxywvqwns
Lazily compute Iterator len
2 parents c4e3b34 + 820b270 commit 07d6bc3

File tree

5 files changed

+370
-46
lines changed

5 files changed

+370
-46
lines changed

roaring/src/bitmap/container.rs

+17
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,21 @@ impl Iterator for Iter<'_> {
300300
fn next(&mut self) -> Option<u32> {
301301
self.inner.next().map(|i| util::join(self.key, i))
302302
}
303+
304+
fn size_hint(&self) -> (usize, Option<usize>) {
305+
self.inner.size_hint()
306+
}
307+
308+
fn count(self) -> usize
309+
where
310+
Self: Sized,
311+
{
312+
self.inner.count()
313+
}
314+
315+
fn nth(&mut self, n: usize) -> Option<Self::Item> {
316+
self.inner.nth(n).map(|i| util::join(self.key, i))
317+
}
303318
}
304319

305320
impl DoubleEndedIterator for Iter<'_> {
@@ -308,6 +323,8 @@ impl DoubleEndedIterator for Iter<'_> {
308323
}
309324
}
310325

326+
impl ExactSizeIterator for Iter<'_> {}
327+
311328
impl fmt::Debug for Container {
312329
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
313330
format!("Container<{:?} @ {:?}>", self.len(), self.key).fmt(formatter)

0 commit comments

Comments
 (0)