Struct bitmac::grow_strategy::LimitStrategy
source · [−]pub struct LimitStrategy<S> {
pub strategy: S,
pub limit: usize,
}
Expand description
Increases the size of the container until the limit is reached.
Example:
use bitmac::grow_strategy::{GrowStrategy, MinimumRequiredStrategy, LimitStrategy, MinimumRequiredLength};
let mut s = LimitStrategy{
strategy: MinimumRequiredStrategy,
limit: 5,
};
assert_eq!(s.try_grow(MinimumRequiredLength::new_unchecked(1), 0, 0).unwrap().value(), 1);
assert_eq!(s.try_grow(MinimumRequiredLength::new_unchecked(2), 0, 10).unwrap().value(), 2);
assert_eq!(s.try_grow(MinimumRequiredLength::new_unchecked(3), 0, 23).unwrap().value(), 3);
assert_eq!(s.try_grow(MinimumRequiredLength::new_unchecked(4), 3, 24).unwrap().value(), 4);
assert_eq!(s.try_grow(MinimumRequiredLength::new_unchecked(5), 3, 35).unwrap().value(), 5);
assert!(s.try_grow(MinimumRequiredLength::new_unchecked(6), 3, 47).is_err());
assert!(!s.is_force_grow());
Fields
strategy: S
limit: usize
Trait Implementations
sourceimpl<S: Clone> Clone for LimitStrategy<S>
impl<S: Clone> Clone for LimitStrategy<S>
sourcefn clone(&self) -> LimitStrategy<S>
fn clone(&self) -> LimitStrategy<S>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<S: Debug> Debug for LimitStrategy<S>
impl<S: Debug> Debug for LimitStrategy<S>
sourceimpl<S> GrowStrategy for LimitStrategy<S> where
S: GrowStrategy,
impl<S> GrowStrategy for LimitStrategy<S> where
S: GrowStrategy,
sourcefn try_grow(
&mut self,
min_req_len: MinimumRequiredLength,
old_len: usize,
bit_idx: usize
) -> Result<FinalLength, ResizeError>
fn try_grow(
&mut self,
min_req_len: MinimumRequiredLength,
old_len: usize,
bit_idx: usize
) -> Result<FinalLength, ResizeError>
Will be called when the bitmap needs to extend its container. New length always >= minimal required length of container. Read more
sourcefn is_force_grow(&self) -> bool
fn is_force_grow(&self) -> bool
Checks if the container should grow if the changing bit is exceeding container’s length
and its new state is 0
(false
) Read more
sourceimpl<S: Hash> Hash for LimitStrategy<S>
impl<S: Hash> Hash for LimitStrategy<S>
sourceimpl<S: PartialEq> PartialEq<LimitStrategy<S>> for LimitStrategy<S>
impl<S: PartialEq> PartialEq<LimitStrategy<S>> for LimitStrategy<S>
sourcefn eq(&self, other: &LimitStrategy<S>) -> bool
fn eq(&self, other: &LimitStrategy<S>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
impl<S: Copy> Copy for LimitStrategy<S>
impl<S: Eq> Eq for LimitStrategy<S>
impl<S> StructuralEq for LimitStrategy<S>
impl<S> StructuralPartialEq for LimitStrategy<S>
Auto Trait Implementations
impl<S> RefUnwindSafe for LimitStrategy<S> where
S: RefUnwindSafe,
impl<S> Send for LimitStrategy<S> where
S: Send,
impl<S> Sync for LimitStrategy<S> where
S: Sync,
impl<S> Unpin for LimitStrategy<S> where
S: Unpin,
impl<S> UnwindSafe for LimitStrategy<S> where
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more