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: usizeTrait Implementations§
Source§impl<S: Clone> Clone for LimitStrategy<S>
impl<S: Clone> Clone for LimitStrategy<S>
Source§fn clone(&self) -> LimitStrategy<S>
fn clone(&self) -> LimitStrategy<S>
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<S: Debug> Debug for LimitStrategy<S>
impl<S: Debug> Debug for LimitStrategy<S>
Source§impl<S> GrowStrategy for LimitStrategy<S>where
S: GrowStrategy,
impl<S> GrowStrategy for LimitStrategy<S>where
S: GrowStrategy,
Source§fn 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
Source§fn 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 moreSource§impl<S: Hash> Hash for LimitStrategy<S>
impl<S: Hash> Hash for LimitStrategy<S>
Source§impl<S: PartialEq> PartialEq for LimitStrategy<S>
impl<S: PartialEq> PartialEq for LimitStrategy<S>
impl<S: Copy> Copy for LimitStrategy<S>
impl<S: Eq> Eq for LimitStrategy<S>
impl<S> StructuralPartialEq for LimitStrategy<S>
Auto Trait Implementations§
impl<S> Freeze for LimitStrategy<S>where
S: Freeze,
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§
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