Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion roaring/src/bitmap/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub(crate) struct Iter<'a> {
}

impl Container {
pub fn new(key: u16) -> Container {
pub const fn new(key: u16) -> Container {
Container { key, store: Store::new() }
}

Expand Down
2 changes: 1 addition & 1 deletion roaring/src/bitmap/inherent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl RoaringBitmap {
/// use roaring::RoaringBitmap;
/// let rb = RoaringBitmap::new();
/// ```
pub fn new() -> RoaringBitmap {
pub const fn new() -> RoaringBitmap {
RoaringBitmap { containers: Vec::new() }
}

Expand Down
2 changes: 1 addition & 1 deletion roaring/src/bitmap/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ impl RoaringBitmap {
}
}

fn header_size(size: usize, has_run_containers: bool) -> usize {
const fn header_size(size: usize, has_run_containers: bool) -> usize {
if has_run_containers {
// New format encodes the size (number of containers) into the 4 byte cookie
// Additionally a bitmap is included marking which containers are run containers
Expand Down
4 changes: 2 additions & 2 deletions roaring/src/bitmap/store/array_store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ pub(crate) fn last_contiguous_range_len(slice: &[u16]) -> usize {
}

impl ArrayStore {
pub fn new() -> ArrayStore {
pub const fn new() -> ArrayStore {
ArrayStore { vec: vec![] }
}

pub fn serialized_byte_size(cardinality: u64) -> usize {
pub const fn serialized_byte_size(cardinality: u64) -> usize {
cardinality as usize * ARRAY_ELEMENT_BYTES
}

Expand Down
4 changes: 2 additions & 2 deletions roaring/src/bitmap/store/array_store/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ pub struct CardinalityCounter {
}

impl CardinalityCounter {
pub fn new() -> CardinalityCounter {
pub const fn new() -> CardinalityCounter {
CardinalityCounter { count: 0 }
}

pub fn into_inner(self) -> u64 {
pub const fn into_inner(self) -> u64 {
self.count as u64
}
}
Expand Down
10 changes: 5 additions & 5 deletions roaring/src/bitmap/store/bitmap_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl BitmapStore {
BitmapStore { len: 0, bits: Box::new([0; BITMAP_LENGTH]) }
}

pub fn capacity(&self) -> usize {
pub const fn capacity(&self) -> usize {
BITMAP_LENGTH * u64::BITS as usize
}

Expand Down Expand Up @@ -282,11 +282,11 @@ impl BitmapStore {
ArrayStore::from_vec_unchecked(vec)
}

pub fn len(&self) -> u64 {
pub const fn len(&self) -> u64 {
self.len
}

pub fn is_empty(&self) -> bool {
pub const fn is_empty(&self) -> bool {
self.len == 0
}

Expand Down Expand Up @@ -813,12 +813,12 @@ impl<B: Borrow<[u64; BITMAP_LENGTH]>> DoubleEndedIterator for BitmapIter<B> {
impl<B: Borrow<[u64; BITMAP_LENGTH]>> ExactSizeIterator for BitmapIter<B> {}

#[inline]
pub fn key(index: u16) -> usize {
pub const fn key(index: u16) -> usize {
index as usize / 64
}

#[inline]
pub fn bit(index: u16) -> usize {
pub const fn bit(index: u16) -> usize {
index as usize % 64
}

Expand Down
14 changes: 7 additions & 7 deletions roaring/src/bitmap/store/interval_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl IntervalStore {
Self::serialized_byte_size(self.run_amount())
}

pub fn serialized_byte_size(run_amount: u64) -> usize {
pub const fn serialized_byte_size(run_amount: u64) -> usize {
RUN_NUM_BYTES + (RUN_ELEMENT_BYTES * run_amount as usize)
}

Expand Down Expand Up @@ -648,7 +648,7 @@ pub(crate) struct RunIter<I: SliceIterator<Interval>> {
}

impl<I: SliceIterator<Interval>> RunIter<I> {
fn new(intervals: I) -> Self {
const fn new(intervals: I) -> Self {
Self { forward_offset: 0, backward_offset: 0, intervals }
}

Expand Down Expand Up @@ -926,7 +926,7 @@ impl IntoIterator for &'_ Interval {
}
}

pub(crate) fn cmp_index_interval(index: u16, iv: Interval) -> Ordering {
pub(crate) const fn cmp_index_interval(index: u16, iv: Interval) -> Ordering {
if index < iv.start {
Ordering::Less
} else if index > iv.end {
Expand All @@ -942,15 +942,15 @@ impl Interval {
Self { start, end }
}

pub fn start(&self) -> u16 {
pub const fn start(&self) -> u16 {
self.start
}

pub fn end(&self) -> u16 {
pub const fn end(&self) -> u16 {
self.end
}

pub fn overlaps(&self, interval: &Self) -> bool {
pub const fn overlaps(&self, interval: &Self) -> bool {
interval.start <= self.end && self.start <= interval.end
}

Expand All @@ -966,7 +966,7 @@ impl Interval {
u64::from(self.end - self.start) + 1
}

pub fn is_full(&self) -> bool {
pub const fn is_full(&self) -> bool {
self.start == 0 && self.end == u16::MAX
}
}
Expand Down
2 changes: 1 addition & 1 deletion roaring/src/bitmap/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub(crate) enum Iter<'a> {
}

impl Store {
pub fn new() -> Store {
pub const fn new() -> Store {
Store::Array(ArrayStore::new())
}

Expand Down
2 changes: 1 addition & 1 deletion roaring/src/bitmap/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::ops::{Bound, RangeBounds, RangeInclusive};
/// Returns the container key and the index
/// in this container for a given integer.
#[inline]
pub fn split(value: u32) -> (u16, u16) {
pub const fn split(value: u32) -> (u16, u16) {
((value >> 16) as u16, value as u16)
}

Expand Down
2 changes: 1 addition & 1 deletion roaring/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct NonSortedIntegers {

impl NonSortedIntegers {
/// Returns the number of elements that were
pub fn valid_until(&self) -> u64 {
pub const fn valid_until(&self) -> u64 {
self.valid_until
}
}
Expand Down
2 changes: 1 addition & 1 deletion roaring/src/treemap/inherent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl RoaringTreemap {
/// use roaring::RoaringTreemap;
/// let rb = RoaringTreemap::new();
/// ```
pub fn new() -> RoaringTreemap {
pub const fn new() -> RoaringTreemap {
RoaringTreemap { map: BTreeMap::new() }
}

Expand Down
2 changes: 1 addition & 1 deletion roaring/src/treemap/util.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::ops::{Bound, RangeBounds, RangeInclusive};

#[inline]
pub fn split(value: u64) -> (u32, u32) {
pub const fn split(value: u64) -> (u32, u32) {
((value >> 32) as u32, value as u32)
}

Expand Down
Loading