pub struct Bitmap2048(/* private fields */);
Expand description
Experimental struct for now, a bitmap containing 2_048 bits. I wouldn’t yet recommend using this struct until it’s more stable!
Implementations§
Source§impl Bitmap2048
impl Bitmap2048
pub fn capacity() -> usize
pub fn to_array(&self) -> [usize; 32]
Sourcepub fn get(&self, index: usize) -> Result<bool, String>
pub fn get(&self, index: usize) -> Result<bool, String>
Examples found in repository?
examples/sieve_of_eratosthenes.rs (line 12)
4fn main() {
5 let max = 2048;
6
7 let mut bitmap = Bitmap2048::from([usize::MAX; 32]);
8
9 let time = Instant::now();
10
11 for i in 2..max {
12 if bitmap.get(i).unwrap() {
13 let mut j = i;
14 while i * j < max {
15 bitmap.set(i * j, false).unwrap();
16 j += 1;
17 }
18 }
19 }
20
21 let elapsed = time.elapsed().as_nanos();
22
23 for i in 2..max {
24 if bitmap.get(i).unwrap() {
25 print!("{}, ", i);
26 }
27 }
28 println!("Time elapsed: {}", elapsed);
29}
Sourcepub fn set(&mut self, index: usize, value: bool) -> Result<(), String>
pub fn set(&mut self, index: usize, value: bool) -> Result<(), String>
Examples found in repository?
examples/sieve_of_eratosthenes.rs (line 15)
4fn main() {
5 let max = 2048;
6
7 let mut bitmap = Bitmap2048::from([usize::MAX; 32]);
8
9 let time = Instant::now();
10
11 for i in 2..max {
12 if bitmap.get(i).unwrap() {
13 let mut j = i;
14 while i * j < max {
15 bitmap.set(i * j, false).unwrap();
16 j += 1;
17 }
18 }
19 }
20
21 let elapsed = time.elapsed().as_nanos();
22
23 for i in 2..max {
24 if bitmap.get(i).unwrap() {
25 print!("{}, ", i);
26 }
27 }
28 println!("Time elapsed: {}", elapsed);
29}
pub fn from_set(index: usize) -> Option<Bitmap2048>
pub fn new(value: bool) -> Bitmap2048
Trait Implementations§
Source§impl Add<usize> for Bitmap2048
impl Add<usize> for Bitmap2048
Source§impl AddAssign<usize> for Bitmap2048
impl AddAssign<usize> for Bitmap2048
Source§fn add_assign(&mut self, rhs: usize)
fn add_assign(&mut self, rhs: usize)
Performs the
+=
operation. Read moreSource§impl BitAnd for Bitmap2048
impl BitAnd for Bitmap2048
Source§impl BitAndAssign<[usize; 32]> for Bitmap2048
impl BitAndAssign<[usize; 32]> for Bitmap2048
Source§impl BitAndAssign for Bitmap2048
impl BitAndAssign for Bitmap2048
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
Performs the
&=
operation. Read moreSource§impl BitOr for Bitmap2048
impl BitOr for Bitmap2048
Source§impl BitOrAssign<[usize; 32]> for Bitmap2048
impl BitOrAssign<[usize; 32]> for Bitmap2048
Source§impl BitOrAssign for Bitmap2048
impl BitOrAssign for Bitmap2048
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
Performs the
|=
operation. Read moreSource§impl BitXor for Bitmap2048
impl BitXor for Bitmap2048
Source§impl BitXorAssign<[usize; 32]> for Bitmap2048
impl BitXorAssign<[usize; 32]> for Bitmap2048
Source§impl BitXorAssign for Bitmap2048
impl BitXorAssign for Bitmap2048
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
Performs the
^=
operation. Read moreSource§impl BitmapSize for Bitmap2048
impl BitmapSize for Bitmap2048
const MAP_LENGTH: usize = 2_048usize
Source§impl Clone for Bitmap2048
impl Clone for Bitmap2048
Source§fn clone(&self) -> Bitmap2048
fn clone(&self) -> Bitmap2048
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Bitmap2048
impl Debug for Bitmap2048
Source§impl Default for Bitmap2048
impl Default for Bitmap2048
Source§impl Deref for Bitmap2048
impl Deref for Bitmap2048
Source§impl Display for Bitmap2048
impl Display for Bitmap2048
Source§impl Hash for Bitmap2048
impl Hash for Bitmap2048
Source§impl Ord for Bitmap2048
impl Ord for Bitmap2048
Source§fn cmp(&self, other: &Bitmap2048) -> Ordering
fn cmp(&self, other: &Bitmap2048) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for Bitmap2048
impl PartialEq for Bitmap2048
Source§impl PartialOrd for Bitmap2048
impl PartialOrd for Bitmap2048
impl Copy for Bitmap2048
impl Eq for Bitmap2048
impl StructuralPartialEq for Bitmap2048
Auto Trait Implementations§
impl Freeze for Bitmap2048
impl RefUnwindSafe for Bitmap2048
impl Send for Bitmap2048
impl Sync for Bitmap2048
impl Unpin for Bitmap2048
impl UnwindSafe for Bitmap2048
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more