From 0cf07f32ca4b7de6da709815e0e9ce14c24a258c Mon Sep 17 00:00:00 2001 From: tower120 Date: Sun, 10 Mar 2024 19:28:35 +0200 Subject: [PATCH] max_capacity() added lib include reorder --- src/bitset.rs | 10 ++++++++-- src/lib.rs | 11 ++++++----- src/small_bitset.rs | 8 +++++++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/bitset.rs b/src/bitset.rs index 3ec34de..511b4a7 100644 --- a/src/bitset.rs +++ b/src/bitset.rs @@ -1,7 +1,7 @@ use std::mem::{ManuallyDrop, MaybeUninit}; use crate::{assume, BitSetBase, internals}; use crate::bitset_interface::{LevelMasks, LevelMasksIterExt}; -use crate::config::{Config}; +use crate::config::Config; use crate::block::Block; use crate::raw; @@ -47,7 +47,13 @@ impl BitSet { #[inline] pub fn new() -> Self{ Default::default() - } + } + + /// Max usize, container with this `Conf` can hold. + #[inline] + pub const fn max_capacity() -> usize { + RawBitSet::::max_capacity() + } /// # Safety /// diff --git a/src/lib.rs b/src/lib.rs index f329dd1..3a59e8c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -165,20 +165,21 @@ mod level; mod bit_block; mod bit_queue; mod bit_utils; -pub mod config; -pub mod ops; mod reduce; mod bitset_interface; mod apply; -pub mod iter; -pub mod cache; -pub mod internals; mod compact_block; mod raw; mod small_bitset; mod primitive_array; mod bitset; +pub mod config; +pub mod ops; +pub mod iter; +pub mod cache; +pub mod internals; + pub use bitset_interface::{BitSetBase, BitSetInterface}; pub use apply::Apply; pub use reduce::Reduce; diff --git a/src/small_bitset.rs b/src/small_bitset.rs index eb2a49f..9177f0e 100644 --- a/src/small_bitset.rs +++ b/src/small_bitset.rs @@ -61,7 +61,7 @@ type RawSmallBitSet = RawBitSet< /// SparseBitMap - `bit_block` acts as a sparse array: /// ```text /// 0 1 2 3 ◁═ popcnt before element -/// +/// (dense_array indices) /// bit_block 0 1 1 0 0 0 1 1 0 0 ... /// └───┬─┬───────┬─┬─────────┘ /// ┌──┘┌┘ ┌─────┘ │ @@ -122,6 +122,12 @@ impl SmallBitSet { Default::default() } + /// Max usize, container with this `Conf` can hold. + #[inline] + pub const fn max_capacity() -> usize { + RawSmallBitSet::::max_capacity() + } + #[inline] pub fn insert(&mut self, index: usize){ self.0.insert(index)