DigitBin

Trait DigitBin 

Source
pub trait DigitBin: Clone + Default {
    // Required methods
    fn insert(&mut self, id: u64);
    fn remove(&mut self, id: u64) -> bool;
    fn len(&self) -> usize;
    fn is_empty(&self) -> bool;
    fn get_random(&self, rng: &mut impl Rng) -> Option<u64>;
    fn get_random_and_remove(&mut self, rng: &mut impl Rng) -> Option<u64>;
}
Expand description

Trait for types that can be used as leaf bins in a DigitBinIndex.

Implement this trait for any container you want to use for storing IDs in the leaf nodes. Provided implementations: Vec<u32>, RoaringBitmap.

Required Methods§

Source

fn insert(&mut self, id: u64)

Source

fn remove(&mut self, id: u64) -> bool

Source

fn len(&self) -> usize

Source

fn is_empty(&self) -> bool

Source

fn get_random(&self, rng: &mut impl Rng) -> Option<u64>

Source

fn get_random_and_remove(&mut self, rng: &mut impl Rng) -> Option<u64>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl DigitBin for Vec<u32>

Source§

fn insert(&mut self, id: u64)

Source§

fn remove(&mut self, id: u64) -> bool

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn get_random(&self, rng: &mut impl Rng) -> Option<u64>

Source§

fn get_random_and_remove(&mut self, rng: &mut impl Rng) -> Option<u64>

Source§

impl DigitBin for RoaringBitmap

Source§

fn insert(&mut self, id: u64)

Source§

fn remove(&mut self, id: u64) -> bool

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn get_random(&self, rng: &mut impl Rng) -> Option<u64>

Source§

fn get_random_and_remove(&mut self, rng: &mut impl Rng) -> Option<u64>

Source§

impl DigitBin for RoaringTreemap

Source§

fn insert(&mut self, id: u64)

Source§

fn remove(&mut self, id: u64) -> bool

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn get_random(&self, rng: &mut impl Rng) -> Option<u64>

Source§

fn get_random_and_remove(&mut self, rng: &mut impl Rng) -> Option<u64>

Implementors§