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
23 changes: 22 additions & 1 deletion roaring/src/bitmap/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,15 @@ impl IntoIterator for Container {
}
}

impl<'a> Iterator for Iter<'a> {
impl Iterator for Iter<'_> {
type Item = u32;
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 Iter<'_> {
pub fn empty() -> Self {
Self { key: 0, inner: store::Iter::empty() }
}

#[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
Loading