Trait BitSet

Source
pub trait BitSet<T> {
    // Required methods
    fn capacity(&self) -> T;
    fn has(&self, _: T) -> bool;
    fn is_empty(&self) -> bool;
    fn size(&self) -> T;
}
Expand description

A trait for reading values from a bit set.

Required Methods§

Source

fn capacity(&self) -> T

Returns the number of bits that can be stored in the set.

§Example
use index_set::BitSet;

let bitset: &[u32] = &[0; 4];
assert_eq!(bitset.capacity(), 128);
Source

fn has(&self, _: T) -> bool

Returns true if the set contains the given value.

§Example
use index_set::{BitSet, BitSetMut};

let mut bitset: [u32; 4] = [0; 4];
bitset.insert(0);
assert!(bitset.has(0));
Source

fn is_empty(&self) -> bool

Returns true if the set is empty.

§Example
use index_set::{BitSet, BitSetMut};

let mut bitset: [u32; 4] = [0; 4];
assert!(BitSet::is_empty(&bitset[..]));

bitset.insert(0);
assert!(!BitSet::is_empty(&bitset[..]));
Source

fn size(&self) -> T

Returns the number of values in the set.

§Example
use index_set::{BitSet, BitSetMut};

let mut bitset: [u32; 4] = [0; 4];

bitset.insert(0);
assert_eq!(bitset.size(), 1);

Implementations on Foreign Types§

Source§

impl BitSet<u16> for [u16]

Source§

fn capacity(&self) -> u16

Source§

fn has(&self, index: u16) -> bool

Source§

fn is_empty(&self) -> bool

Source§

fn size(&self) -> u16

Source§

impl BitSet<u32> for [u32]

Source§

fn capacity(&self) -> u32

Source§

fn has(&self, index: u32) -> bool

Source§

fn is_empty(&self) -> bool

Source§

fn size(&self) -> u32

Source§

impl BitSet<u32> for [AtomicU32]

Source§

fn capacity(&self) -> u32

Source§

fn has(&self, index: u32) -> bool

Source§

fn is_empty(&self) -> bool

Source§

fn size(&self) -> u32

Source§

impl BitSet<u64> for [u64]

Source§

fn capacity(&self) -> u64

Source§

fn has(&self, index: u64) -> bool

Source§

fn is_empty(&self) -> bool

Source§

fn size(&self) -> u64

Source§

impl BitSet<u64> for [AtomicU64]

Source§

fn capacity(&self) -> u64

Source§

fn has(&self, index: u64) -> bool

Source§

fn is_empty(&self) -> bool

Source§

fn size(&self) -> u64

Source§

impl BitSet<u128> for [u128]

Source§

fn capacity(&self) -> u128

Source§

fn has(&self, index: u128) -> bool

Source§

fn is_empty(&self) -> bool

Source§

fn size(&self) -> u128

Source§

impl BitSet<usize> for [usize]

Source§

fn capacity(&self) -> usize

Source§

fn has(&self, index: usize) -> bool

Source§

fn is_empty(&self) -> bool

Source§

fn size(&self) -> usize

Source§

impl BitSet<usize> for [AtomicUsize]

Source§

fn capacity(&self) -> usize

Source§

fn has(&self, index: usize) -> bool

Source§

fn is_empty(&self) -> bool

Source§

fn size(&self) -> usize

Source§

impl<Set, T> BitSet<T> for &Set
where Set: BitSet<T> + ?Sized,

Source§

fn capacity(&self) -> T

Source§

fn has(&self, index: T) -> bool

Source§

fn is_empty(&self) -> bool

Source§

fn size(&self) -> T

Source§

impl<Set, T> BitSet<T> for Box<Set>
where Set: BitSet<T> + ?Sized,

Source§

fn capacity(&self) -> T

Source§

fn has(&self, index: T) -> bool

Source§

fn is_empty(&self) -> bool

Source§

fn size(&self) -> T

Implementors§