Trait SplinterRead

Source
pub trait SplinterRead {
    // Required methods
    fn is_empty(&self) -> bool;
    fn contains(&self, key: u32) -> bool;
    fn cardinality(&self) -> usize;
    fn iter(&self) -> impl Iterator<Item = u32> + '_;
    fn range<'a, R>(&'a self, range: R) -> impl Iterator<Item = u32> + 'a
       where R: RangeBounds<u32> + 'a;
    fn last(&self) -> Option<u32>;
}

Required Methods§

Source

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());
Source

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));
Source

fn cardinality(&self) -> usize

Calculates the total number of values stored in the Splinter.

§Examples

let mut splinter = Splinter::default();
splinter.insert(6);
splinter.insert(1);
splinter.insert(3);

assert_eq!(3, splinter.cardinality());
Source

fn iter(&self) -> impl Iterator<Item = u32> + '_

Returns an sorted Iterator over all keys.

§Examples

let mut splinter = Splinter::default();
splinter.insert(6);
splinter.insert(1);
splinter.insert(3);

assert_eq!(&[1, 3, 6], &*splinter.iter().collect::<Vec<_>>());
Source

fn range<'a, R>(&'a self, range: R) -> impl Iterator<Item = u32> + 'a
where R: RangeBounds<u32> + 'a,

Returns an sorted Iterator over all keys contained by the provided range.

§Examples

let mut splinter = Splinter::default();
splinter.insert(6);
splinter.insert(1);
splinter.insert(3);
splinter.insert(5);
splinter.insert(9);

assert_eq!(&[3, 5, 6], &*splinter.range(3..=6).collect::<Vec<_>>());
Source

fn last(&self) -> Option<u32>

Returns the last key in the set

§Examples

let mut splinter = Splinter::default();

assert_eq!(None, splinter.last());
splinter.insert(6);
splinter.insert(1);
splinter.insert(3);
assert_eq!(Some(6), splinter.last());

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§