use sp_arithmetic::traits::AtLeast8BitUnsigned; use sp_runtime::traits::UniqueSaturatedInto; use sp_std::vec::Vec; pub trait BoundedBitmapMetadata { fn total_bits_capacity() -> u32; fn chunk_size() -> u32; } pub trait BoundedBitmapWriter { fn insert>(&mut self, i: N) -> Option; fn remove>(&mut self, i: N) -> Option; fn truncate(&mut self); fn nullify(&mut self); } pub trait BoundedBitmapReader { fn active_bits_count(&self) -> u32; fn highest_bit(&self) -> Option where usize: UniqueSaturatedInto; fn count_ones(&self) -> N where u32: UniqueSaturatedInto; fn count_zeros(&self) -> N where u32: UniqueSaturatedInto; fn is_empty(&self) -> bool; fn contains(&self, index: N) -> bool where N: UniqueSaturatedInto; } pub trait BoundedBitmapGenerator { fn empty(n: N) -> Self where N: UniqueSaturatedInto; fn all_ones(n: N) -> Self where N: UniqueSaturatedInto; fn empty_from(bitmap: &Self) -> Self; fn from_bitmask(values: &Vec) -> Self where Outer: AtLeast8BitUnsigned + num_traits::PrimInt; fn from_vec(values: &Vec) -> Self where Outer: AtLeast8BitUnsigned + TryInto + PartialEq + Copy; } pub trait BoundedBitmapIterable { type IntoIter<'a, ItemType>: Iterator + 'a where Self: 'a, ItemType: 'static, u32: UniqueSaturatedInto; fn iter(&self) -> Self::IntoIter<'_, ItemType> where ItemType: 'static, u32: UniqueSaturatedInto; }