Struct BitmapKB

Source
pub struct BitmapKB(/* private fields */);
Expand description

Experimental struct for now, a bitmap containing 8_192 bits. I wouldn’t yet recommend using this struct until it’s more stable!

Implementations§

Source§

impl BitmapKB

Source

pub fn capacity() -> usize

Source

pub fn to_array(&self) -> [usize; 128]

Source

pub fn get(&self, index: usize) -> Result<bool, String>

Source

pub fn set(&mut self, index: usize, value: bool) -> Result<(), String>

Examples found in repository?
examples/using_bitmap_kb.rs (line 26)
3fn main() {
4    let mut bitmap = BitmapKB::default();
5    let mut array = [0; 128];
6    array[127] = usize::MAX;
7    println!("{}", bitmap);
8
9    bitmap |= array;
10    println!("{}", bitmap);
11
12    bitmap += 1;
13    println!("{}", bitmap);
14
15    bitmap += usize::MAX;
16    println!("{}", bitmap);
17    bitmap += 1;
18    println!("{}", bitmap);
19
20    let mut a = bitmap;
21    a += 1;
22    println!("A: {}", a);
23    println!("Bitmap: {}", bitmap);
24
25    let mut a = BitmapKB::default();
26    a.set(1054, true).unwrap();
27    a.set(1000, true).unwrap();
28    let mut b = BitmapKB::default();
29    b.set(1054, true).unwrap();
30    b.set(1000, true).unwrap();
31    let mut c = BitmapKB::default();
32    c.set(1054, true).unwrap();
33    assert_eq!(a, b);
34    assert_ne!(a, c);
35}
Source

pub fn from_set(index: usize) -> Option<BitmapKB>

Source

pub fn new(value: bool) -> BitmapKB

Trait Implementations§

Source§

impl Add<usize> for BitmapKB

Source§

type Output = BitmapKB

The resulting type after applying the + operator.
Source§

fn add(self, rhs: usize) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign<usize> for BitmapKB

Source§

fn add_assign(&mut self, rhs: usize)

Performs the += operation. Read more
Source§

impl BitAnd<[usize; 128]> for BitmapKB

Source§

type Output = BitmapKB

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: [usize; 128]) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAnd for BitmapKB

Source§

type Output = BitmapKB

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAndAssign<[usize; 128]> for BitmapKB

Source§

fn bitand_assign(&mut self, rhs: [usize; 128])

Performs the &= operation. Read more
Source§

impl BitAndAssign for BitmapKB

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitOr<[usize; 128]> for BitmapKB

Source§

type Output = BitmapKB

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: [usize; 128]) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOr for BitmapKB

Source§

type Output = BitmapKB

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOrAssign<[usize; 128]> for BitmapKB

Source§

fn bitor_assign(&mut self, rhs: [usize; 128])

Performs the |= operation. Read more
Source§

impl BitOrAssign for BitmapKB

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl BitXor<[usize; 128]> for BitmapKB

Source§

type Output = BitmapKB

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: [usize; 128]) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXor for BitmapKB

Source§

type Output = BitmapKB

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXorAssign<[usize; 128]> for BitmapKB

Source§

fn bitxor_assign(&mut self, rhs: [usize; 128])

Performs the ^= operation. Read more
Source§

impl BitXorAssign for BitmapKB

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl BitmapSize for BitmapKB

Source§

const MAP_LENGTH: usize = 8_192usize

Source§

impl Clone for BitmapKB

Source§

fn clone(&self) -> BitmapKB

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BitmapKB

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BitmapKB

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Deref for BitmapKB

Source§

type Target = [usize; 128]

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Display for BitmapKB

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<[usize; 128]> for BitmapKB

Source§

fn from(value: [usize; 128]) -> Self

Converts to this type from the input type.
Source§

impl Hash for BitmapKB

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for BitmapKB

Source§

fn cmp(&self, other: &BitmapKB) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for BitmapKB

Source§

fn eq(&self, other: &BitmapKB) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for BitmapKB

Source§

fn partial_cmp(&self, other: &BitmapKB) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for BitmapKB

Source§

impl Eq for BitmapKB

Source§

impl StructuralPartialEq for BitmapKB

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.