pipecircuit 0.0.6

Correct. Robust. Fast. Portable.
Documentation
use alloc::vec::Vec;
use core::marker::PhantomData;

mod blocks;
mod bounds;
mod creation;
mod inconsistency;
mod insert;
mod key;
mod lookup;
mod move_slot;
mod remove;

pub use bounds::RangeIndexBounds;
pub use creation::RangeIndexCreationError;
pub use inconsistency::RangeIndexInconsistency;
pub use insert::{PreparedRangeIndexInsert, RangeIndexInsertError, RangeIndexInsertOutcome};
pub use key::RangeIndexKey;
pub use lookup::{RangeIndexLookupError, RangeIndexMembership};
pub use move_slot::{PreparedRangeIndexMove, RangeIndexMoveError, RangeIndexMoveOutcome};
pub use remove::{PreparedRangeIndexRemove, RangeIndexRemoveError, RangeIndexRemoveOutcome};

/// A bit-sliced numeric index whose memberships remain stable across dense-row moves.
#[doc(hidden)]
pub struct RangeIndex<Key: RangeIndexKey> {
    maximum_rows: usize,
    member_count: u64,
    blocks: Vec<u64>,
    key: PhantomData<fn() -> Key>,
}

impl<Key: RangeIndexKey> RangeIndex<Key> {
    pub const fn capacity(&self) -> usize {
        self.maximum_rows
    }

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

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

#[cfg(test)]
mod tests;