From 14f53fbf0876d25945d4430d638e974f6b01bd7c Mon Sep 17 00:00:00 2001 From: Wim Looman Date: Sat, 3 Jan 2015 22:04:03 +1300 Subject: [PATCH] Turn on warn(missing_docs) and hide some methods from the docs --- src/imp.rs | 11 ++++++----- src/iter.rs | 43 ++++++++++++++++++++++++++++--------------- src/lib.rs | 11 +++++++++++ 3 files changed, 45 insertions(+), 20 deletions(-) diff --git a/src/imp.rs b/src/imp.rs index 19570782..c13c1739 100644 --- a/src/imp.rs +++ b/src/imp.rs @@ -2,6 +2,7 @@ use std::{ u16, u32 }; use std::slice; use std::slice::BinarySearchResult::{ Found, NotFound }; +use iter; use iter::{ Iter, UnionIter, IntersectionIter, DifferenceIter, SymmetricDifferenceIter }; use container::Container; @@ -68,7 +69,7 @@ pub fn len(this: &RB) -> uint { #[inline] pub fn iter<'a>(this: &'a RB) -> Iter<'a> { - Iter::new(this.containers.iter()) + iter::new(this.containers.iter()) } fn pairs<'a>(this: &'a RB, other: &'a RB) -> Pairs<'a> { @@ -96,22 +97,22 @@ pub fn is_superset(this: &RB, other: &RB) -> bool { #[inline] pub fn union<'a>(this: &'a RB, other: &'a RB) -> UnionIter<'a> { - UnionIter::new(this.iter(), other.iter()) + iter::union::new(this.iter(), other.iter()) } #[inline] pub fn intersection<'a>(this: &'a RB, other: &'a RB) -> IntersectionIter<'a> { - IntersectionIter::new(this.iter(), other.iter()) + iter::intersection::new(this.iter(), other.iter()) } #[inline] pub fn difference<'a>(this: &'a RB, other: &'a RB) -> DifferenceIter<'a> { - DifferenceIter::new(this.iter(), other.iter()) + iter::difference::new(this.iter(), other.iter()) } #[inline] pub fn symmetric_difference<'a>(this: &'a RB, other: &'a RB) -> SymmetricDifferenceIter<'a> { - SymmetricDifferenceIter::new(this.iter(), other.iter()) + iter::symmetric_difference::new(this.iter(), other.iter()) } #[inline] diff --git a/src/iter.rs b/src/iter.rs index 8c2c0b7f..599cf563 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -5,6 +5,7 @@ use util::Either; use util::Either::{ Left, Right }; use container::{ Container }; +/// An iterator for `RoaringBitmap`. pub struct Iter<'a> { inner_iter: Option<(u16, Box + 'a>)>, container_iter: slice::Iter<'a, Container>, @@ -20,15 +21,15 @@ fn next_iter<'a>(container_iter: &mut slice::Iter<'a, Container>) -> Option<(u16 container_iter.next().map(|container| (container.key(), container.iter())) } -impl<'a> Iter<'a> { - #[inline] - pub fn new(mut container_iter: slice::Iter<'a, Container>) -> Iter<'a> { - Iter { - inner_iter: next_iter(&mut container_iter), - container_iter: container_iter - } +#[inline] +pub fn new<'a>(mut container_iter: slice::Iter<'a, Container>) -> Iter<'a> { + Iter { + inner_iter: next_iter(&mut container_iter), + container_iter: container_iter } +} +impl<'a> Iter<'a> { #[inline] fn choose_next(&mut self) -> Option + 'a>)>>> { match self.inner_iter { @@ -54,6 +55,7 @@ impl<'a> Iterator for Iter<'a> { } } +/// An iterator for `RoaringBitmap`. pub struct UnionIter<'a> { current1: Option, current2: Option, @@ -61,9 +63,11 @@ pub struct UnionIter<'a> { iter2: Iter<'a>, } -impl<'a> UnionIter<'a> { +pub mod union { + use super::{ Iter, UnionIter }; + #[inline] - pub fn new(mut iter1: Iter<'a>, mut iter2: Iter<'a>) -> UnionIter<'a> { + pub fn new<'a>(mut iter1: Iter<'a>, mut iter2: Iter<'a>) -> UnionIter<'a> { UnionIter { current1: iter1.next(), current2: iter2.next(), @@ -91,6 +95,7 @@ impl<'a> Iterator for UnionIter<'a> { } } +/// An iterator for `RoaringBitmap`. pub struct IntersectionIter<'a> { current1: Option, current2: Option, @@ -98,9 +103,11 @@ pub struct IntersectionIter<'a> { iter2: Iter<'a>, } -impl<'a> IntersectionIter<'a> { +pub mod intersection { + use super::{ Iter, IntersectionIter }; + #[inline] - pub fn new(mut iter1: Iter<'a>, mut iter2: Iter<'a>) -> IntersectionIter<'a> { + pub fn new<'a>(mut iter1: Iter<'a>, mut iter2: Iter<'a>) -> IntersectionIter<'a> { IntersectionIter { current1: iter1.next(), current2: iter2.next(), @@ -126,6 +133,7 @@ impl<'a> Iterator for IntersectionIter<'a> { } } +/// An iterator for `RoaringBitmap`. pub struct DifferenceIter<'a> { current1: Option, current2: Option, @@ -133,9 +141,11 @@ pub struct DifferenceIter<'a> { iter2: Iter<'a>, } -impl<'a> DifferenceIter<'a> { +pub mod difference { + use super::{ Iter, DifferenceIter }; + #[inline] - pub fn new(mut iter1: Iter<'a>, mut iter2: Iter<'a>) -> DifferenceIter<'a> { + pub fn new<'a>(mut iter1: Iter<'a>, mut iter2: Iter<'a>) -> DifferenceIter<'a> { DifferenceIter { current1: iter1.next(), current2: iter2.next(), @@ -162,6 +172,7 @@ impl<'a> Iterator for DifferenceIter<'a> { } } +/// An iterator for `RoaringBitmap`. pub struct SymmetricDifferenceIter<'a> { current1: Option, current2: Option, @@ -169,9 +180,11 @@ pub struct SymmetricDifferenceIter<'a> { iter2: Iter<'a>, } -impl<'a> SymmetricDifferenceIter<'a> { +pub mod symmetric_difference { + use super::{ Iter, SymmetricDifferenceIter }; + #[inline] - pub fn new(mut iter1: Iter<'a>, mut iter2: Iter<'a>) -> SymmetricDifferenceIter<'a> { + pub fn new<'a>(mut iter1: Iter<'a>, mut iter2: Iter<'a>) -> SymmetricDifferenceIter<'a> { SymmetricDifferenceIter { current1: iter1.next(), current2: iter2.next(), diff --git a/src/lib.rs b/src/lib.rs index 53c83075..e127c6f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,17 @@ +//! This is a [Rust][] port of the [Roaring bitmap][] data structure, initially +//! defined as a [Java library][roaring-java] and described in [_Better bitmap +//! performance with Roaring bitmaps_][roaring-paper]. +//! +//! [Rust]: https://rust-lang.org +//! [Roaring bitmap]: http://roaringbitmap.org +//! [roaring-java]: https://github.com/lemire/RoaringBitmap +//! [roaring-paper]: http://arxiv.org/pdf/1402.6407v4 + #![feature(slicing_syntax)] #![feature(advanced_slice_patterns)] +#![warn(missing_docs)] + use std::fmt::{ Show, Formatter, Result }; pub use iter::{ Iter, UnionIter, IntersectionIter, DifferenceIter, SymmetricDifferenceIter };