From 6c01e0950295d2f50713908663b69bdcf3d1ab9b Mon Sep 17 00:00:00 2001 From: Wim Looman Date: Sun, 12 Mar 2017 12:04:30 +0100 Subject: [PATCH 1/2] Rearrange modules Move RoaringBitmap into its own module. Rename roaring_treemap module to treemap. Expose Iter/IntoIter from submodules (fixes #40). --- src/{ => bitmap}/cmp.rs | 2 +- src/{ => bitmap}/container.rs | 4 +- src/{ => bitmap}/fmt.rs | 0 src/{ => bitmap}/inherent.rs | 4 +- src/{ => bitmap}/iter.rs | 2 +- src/bitmap/mod.rs | 36 +++++++++++++++++ src/{ => bitmap}/ops.rs | 0 src/{ => bitmap}/serialization.rs | 4 +- src/{ => bitmap}/store.rs | 0 src/{ => bitmap}/util.rs | 0 src/lib.rs | 42 +++----------------- src/{roaring_treemap => treemap}/cmp.rs | 0 src/{roaring_treemap => treemap}/fmt.rs | 0 src/{roaring_treemap => treemap}/inherent.rs | 0 src/{roaring_treemap => treemap}/iter.rs | 4 +- src/{roaring_treemap => treemap}/mod.rs | 3 +- src/{roaring_treemap => treemap}/ops.rs | 0 src/{roaring_treemap => treemap}/util.rs | 0 18 files changed, 53 insertions(+), 48 deletions(-) rename src/{ => bitmap}/cmp.rs (99%) rename src/{ => bitmap}/container.rs (98%) rename src/{ => bitmap}/fmt.rs (100%) rename src/{ => bitmap}/inherent.rs (99%) rename src/{ => bitmap}/iter.rs (98%) create mode 100644 src/bitmap/mod.rs rename src/{ => bitmap}/ops.rs (100%) rename src/{ => bitmap}/serialization.rs (98%) rename src/{ => bitmap}/store.rs (100%) rename src/{ => bitmap}/util.rs (100%) rename src/{roaring_treemap => treemap}/cmp.rs (100%) rename src/{roaring_treemap => treemap}/fmt.rs (100%) rename src/{roaring_treemap => treemap}/inherent.rs (100%) rename src/{roaring_treemap => treemap}/iter.rs (98%) rename src/{roaring_treemap => treemap}/mod.rs (94%) rename src/{roaring_treemap => treemap}/ops.rs (100%) rename src/{roaring_treemap => treemap}/util.rs (100%) diff --git a/src/cmp.rs b/src/bitmap/cmp.rs similarity index 99% rename from src/cmp.rs rename to src/bitmap/cmp.rs index 9b495163..09f89772 100644 --- a/src/cmp.rs +++ b/src/bitmap/cmp.rs @@ -2,7 +2,7 @@ use std::slice; use std::iter::Peekable; use RoaringBitmap; -use container::Container; +use super::container::Container; struct Pairs<'a>(Peekable>, Peekable>); diff --git a/src/container.rs b/src/bitmap/container.rs similarity index 98% rename from src/container.rs rename to src/bitmap/container.rs index 7d8c7549..ea79fd45 100644 --- a/src/container.rs +++ b/src/bitmap/container.rs @@ -1,7 +1,7 @@ use std::fmt; -use util; -use store::{ self, Store }; +use super::util; +use super::store::{ self, Store }; const ARRAY_LIMIT: u64 = 4096; diff --git a/src/fmt.rs b/src/bitmap/fmt.rs similarity index 100% rename from src/fmt.rs rename to src/bitmap/fmt.rs diff --git a/src/inherent.rs b/src/bitmap/inherent.rs similarity index 99% rename from src/inherent.rs rename to src/bitmap/inherent.rs index a5e779cb..82078cc4 100644 --- a/src/inherent.rs +++ b/src/bitmap/inherent.rs @@ -1,7 +1,7 @@ use RoaringBitmap; -use util; -use container::Container; +use super::util; +use super::container::Container; impl RoaringBitmap { /// Creates an empty `RoaringBitmap`. diff --git a/src/iter.rs b/src/bitmap/iter.rs similarity index 98% rename from src/iter.rs rename to src/bitmap/iter.rs index 2ee1b25f..f8aec072 100644 --- a/src/iter.rs +++ b/src/bitmap/iter.rs @@ -3,7 +3,7 @@ use std::slice; use std::vec; use RoaringBitmap; -use container::Container; +use super::container::Container; /// An iterator for `RoaringBitmap`. pub struct Iter<'a> { diff --git a/src/bitmap/mod.rs b/src/bitmap/mod.rs new file mode 100644 index 00000000..aef5e0e4 --- /dev/null +++ b/src/bitmap/mod.rs @@ -0,0 +1,36 @@ +mod store; +mod container; +mod util; +mod fmt; + +// Order of these modules matters as it determines the `impl` blocks order in +// the docs +mod inherent; +mod iter; +mod ops; +mod cmp; +mod serialization; + +pub use self::iter::Iter; +pub use self::iter::IntoIter; + +/// A compressed bitmap using the [Roaring bitmap compression scheme](http://roaringbitmap.org). +/// +/// # Examples +/// +/// ```rust +/// use roaring::RoaringBitmap; +/// +/// let mut rb = RoaringBitmap::new(); +/// +/// // insert all primes less than 10 +/// rb.insert(2); +/// rb.insert(3); +/// rb.insert(5); +/// rb.insert(7); +/// println!("total bits set to true: {}", rb.len()); +/// ``` +#[derive(PartialEq, Clone)] +pub struct RoaringBitmap { + containers: Vec, +} diff --git a/src/ops.rs b/src/bitmap/ops.rs similarity index 100% rename from src/ops.rs rename to src/bitmap/ops.rs diff --git a/src/serialization.rs b/src/bitmap/serialization.rs similarity index 98% rename from src/serialization.rs rename to src/bitmap/serialization.rs index fe041954..6a66a735 100644 --- a/src/serialization.rs +++ b/src/bitmap/serialization.rs @@ -2,8 +2,8 @@ use std::io; use byteorder::{ LittleEndian, ReadBytesExt, WriteBytesExt }; use RoaringBitmap; -use store::Store; -use container::Container; +use super::store::Store; +use super::container::Container; const SERIAL_COOKIE_NO_RUNCONTAINER: u32 = 12346; const SERIAL_COOKIE: u16 = 12347; diff --git a/src/store.rs b/src/bitmap/store.rs similarity index 100% rename from src/store.rs rename to src/bitmap/store.rs diff --git a/src/util.rs b/src/bitmap/util.rs similarity index 100% rename from src/util.rs rename to src/bitmap/util.rs diff --git a/src/lib.rs b/src/lib.rs index f1387c4c..b76bc1f8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,43 +14,11 @@ extern crate byteorder; -mod store; -mod container; -mod util; -mod fmt; - -// Order of these modules matters as it determines the `impl` blocks order in -// the docs -mod inherent; -mod iter; -mod ops; -mod cmp; -mod serialization; - -pub use iter::Iter; +/// A compressed bitmap using the [Roaring bitmap compression scheme](http://roaringbitmap.org). +pub mod bitmap; /// A compressed bitmap with u64 values. Implemented as a `BTreeMap` of `RoaringBitmap`s. -pub mod roaring_treemap; - -/// A compressed bitmap using the [Roaring bitmap compression scheme](http://roaringbitmap.org). -/// -/// # Examples -/// -/// ```rust -/// use roaring::RoaringBitmap; -/// -/// let mut rb = RoaringBitmap::new(); -/// -/// // insert all primes less than 10 -/// rb.insert(2); -/// rb.insert(3); -/// rb.insert(5); -/// rb.insert(7); -/// println!("total bits set to true: {}", rb.len()); -/// ``` -#[derive(PartialEq, Clone)] -pub struct RoaringBitmap { - containers: Vec, -} +pub mod treemap; -pub use roaring_treemap::RoaringTreemap; +pub use bitmap::RoaringBitmap; +pub use treemap::RoaringTreemap; diff --git a/src/roaring_treemap/cmp.rs b/src/treemap/cmp.rs similarity index 100% rename from src/roaring_treemap/cmp.rs rename to src/treemap/cmp.rs diff --git a/src/roaring_treemap/fmt.rs b/src/treemap/fmt.rs similarity index 100% rename from src/roaring_treemap/fmt.rs rename to src/treemap/fmt.rs diff --git a/src/roaring_treemap/inherent.rs b/src/treemap/inherent.rs similarity index 100% rename from src/roaring_treemap/inherent.rs rename to src/treemap/inherent.rs diff --git a/src/roaring_treemap/iter.rs b/src/treemap/iter.rs similarity index 98% rename from src/roaring_treemap/iter.rs rename to src/treemap/iter.rs index 3125ff29..e313ed59 100644 --- a/src/roaring_treemap/iter.rs +++ b/src/treemap/iter.rs @@ -2,8 +2,8 @@ use std::collections::BTreeMap; use std::collections::btree_map; use std::iter::{self, FromIterator}; -use iter::Iter as Iter32; -use iter::IntoIter as IntoIter32; +use bitmap::Iter as Iter32; +use bitmap::IntoIter as IntoIter32; use super::util; use RoaringBitmap; use RoaringTreemap; diff --git a/src/roaring_treemap/mod.rs b/src/treemap/mod.rs similarity index 94% rename from src/roaring_treemap/mod.rs rename to src/treemap/mod.rs index 703f1d7e..79f045cd 100644 --- a/src/roaring_treemap/mod.rs +++ b/src/treemap/mod.rs @@ -11,7 +11,8 @@ mod iter; mod ops; mod cmp; -pub use iter::{Iter, IntoIter}; +pub use self::iter::{Iter, IntoIter}; + /// A compressed bitmap with u64 values. /// Implemented as a `BTreeMap` of `RoaringBitmap`s. /// diff --git a/src/roaring_treemap/ops.rs b/src/treemap/ops.rs similarity index 100% rename from src/roaring_treemap/ops.rs rename to src/treemap/ops.rs diff --git a/src/roaring_treemap/util.rs b/src/treemap/util.rs similarity index 100% rename from src/roaring_treemap/util.rs rename to src/treemap/util.rs From c240ca7640a6871c79f2a4a2efd278f15d5b20de Mon Sep 17 00:00:00 2001 From: Wim Looman Date: Sun, 12 Mar 2017 12:09:13 +0100 Subject: [PATCH 2/2] Bump version to 0.5 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 65badc0e..335c1b9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "roaring" -version = "0.4.2" +version = "0.5.0" authors = ["Wim Looman "] description = "http://roaringbitmap.org : A better compressed bitset - pure Rust implementation "