pub struct Splinter { /* private fields */ }Expand description
An owned, compressed bitmap for u32 keys
Implementations§
Source§impl Splinter
impl Splinter
pub fn from_slice(data: &[u32]) -> Self
pub fn from_bytes<T: AsRef<[u8]>>(data: T) -> Result<Self, Culprit<DecodeErr>>
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the splinter is empty.
§Examples
let mut splinter = Splinter::default();
assert!(splinter.is_empty());
splinter.insert(1);
assert!(!splinter.is_empty());Sourcepub fn contains(&self, key: u32) -> bool
pub fn contains(&self, key: u32) -> bool
Returns true if the splinter contains the given key.
§Examples
let mut splinter = Splinter::default();
splinter.insert(1);
splinter.insert(3);
assert!(splinter.contains(1));
assert!(!splinter.contains(2));
assert!(splinter.contains(3));Sourcepub fn cardinality(&self) -> usize
pub fn cardinality(&self) -> usize
Calculates the total number of values stored in the set.
§Examples
let mut splinter = Splinter::default();
splinter.insert(6);
splinter.insert(1);
splinter.insert(3);
assert_eq!(3, splinter.cardinality());Sourcepub fn insert(&mut self, key: u32) -> bool
pub fn insert(&mut self, key: u32) -> bool
Attempts to insert a key into the Splinter, returning true if a key was inserted
pub fn serialize<B: BufMut>(&self, out: &mut B) -> usize
pub fn serialize_to_bytes(&self) -> Bytes
pub fn serialize_to_splinter_ref(&self) -> SplinterRef<Bytes>
Trait Implementations§
Source§impl<T: AsRef<[u8]>> From<SplinterRef<T>> for Splinter
impl<T: AsRef<[u8]>> From<SplinterRef<T>> for Splinter
Source§fn from(value: SplinterRef<T>) -> Self
fn from(value: SplinterRef<T>) -> Self
Converts to this type from the input type.
Source§impl<K: Into<u32>> FromIterator<K> for Splinter
impl<K: Into<u32>> FromIterator<K> for Splinter
Source§fn from_iter<T: IntoIterator<Item = K>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = K>>(iter: T) -> Self
Creates a value from an iterator. Read more
Source§impl<T: AsRef<[u8]>> Intersection<Splinter> for SplinterRef<T>
impl<T: AsRef<[u8]>> Intersection<Splinter> for SplinterRef<T>
Source§impl<T: AsRef<[u8]>> Intersection<SplinterRef<T>> for Splinter
impl<T: AsRef<[u8]>> Intersection<SplinterRef<T>> for Splinter
type Output = Splinter
Source§fn intersection(&self, rhs: &SplinterRef<T>) -> Self::Output
fn intersection(&self, rhs: &SplinterRef<T>) -> Self::Output
Returns the intersection between self and other
Source§impl Intersection for Splinter
impl Intersection for Splinter
Source§impl<T: AsRef<[u8]>> Merge<SplinterRef<T>> for Splinter
impl<T: AsRef<[u8]>> Merge<SplinterRef<T>> for Splinter
Source§fn merge(&mut self, rhs: &SplinterRef<T>)
fn merge(&mut self, rhs: &SplinterRef<T>)
Merges rhs into self
Auto Trait Implementations§
impl Freeze for Splinter
impl RefUnwindSafe for Splinter
impl Send for Splinter
impl Sync for Splinter
impl Unpin for Splinter
impl UnwindSafe for Splinter
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more