Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement SkipTo for iter::Iter #287

Closed
wants to merge 16 commits into from
Closed
21 changes: 21 additions & 0 deletions roaring/src/bitmap/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ impl<'a> Iterator for Iter<'a> {
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()
}
}

impl DoubleEndedIterator for Iter<'_> {
Expand All @@ -313,3 +317,20 @@ impl fmt::Debug for Container {
format!("Container<{:?} @ {:?}>", self.len(), self.key).fmt(formatter)
}
}

impl<'a> Iter<'a> {
pub fn empty() -> Self {
Self { key: 0, inner: store::Iter::Vec(vec![].into_iter()) }
}

#[inline]
pub fn peek(&mut self) -> Option<u32> {
self.inner.peek().map(|i| util::join(self.key, i))
}
}

impl AsRef<Container> for Container {
fn as_ref(&self) -> &Container {
self
}
}
Loading