pipecircuit 0.0.14

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

use super::SlotSet;
use crate::storage::warp_table::IndexKey;
use crate::storage::warp_table::dense_key_index::DenseKeyIndex;

mod creation;
mod inconsistency;
mod insert;
mod lookup;
mod move_slot;
mod remove;

pub use creation::SecondaryIndexCreationError;
pub use inconsistency::SecondaryIndexInconsistency;
pub use insert::{
    PreparedSecondaryIndexInsert, SecondaryIndexInsertError, SecondaryIndexInsertOutcome,
};
pub use lookup::SecondaryIndexMembership;
pub use move_slot::{
    PreparedSecondaryIndexMove, SecondaryIndexMoveError, SecondaryIndexMoveOutcome,
};
pub use remove::{
    PreparedSecondaryIndexRemove, SecondaryIndexCommitRemoveOutcome,
    SecondaryIndexPrepareRemoveOutcome, SecondaryIndexRemoveError, SecondaryIndexRemoveOutcome,
    SecondaryIndexRemoveResult,
};

pub struct SecondaryIndex<SecondaryKey: IndexKey> {
    maximum_distinct_keys: usize,
    secondary_keys: Vec<SecondaryKey>,
    slot_sets: Vec<SlotSet>,
    secondary_key_index: DenseKeyIndex,
}

impl<SecondaryKey: IndexKey> SecondaryIndex<SecondaryKey> {
    pub const fn len(&self) -> usize {
        self.secondary_keys.len()
    }

    pub const fn is_empty(&self) -> bool {
        self.secondary_keys.is_empty()
    }
}

#[cfg(test)]
mod tests;