[][src]Struct agilulf_skiplist::SkipMap

pub struct SkipMap<T: Default + Clone> { /* fields omitted */ }

A map contains a skiplist and a serial_number.

This example is not tested
pub struct SkipMap<T: Default + Clone> {
    skiplist: SkipList<Item<T>>,
    serial_number: AtomicU64,
}

serial_number is automatically increased. It's used to keep the order of insert: The later it is inserted, the smaller it is. (Actually the serial_number is bigger but the item is smaller according to the strategy of comparing item.

Generic parameter T should be Default + Clone. However the limitation can be relaxed to only Default. The Clone here is to avoid lifetime parameter and keep this crate simple. (And what we need to use for T is actually Clone). If we remove the Clone limitation, the insert method may need to receive a T but not &T

Methods

impl<T: Default + Clone> SkipMap<T>[src]

pub fn len(&self) -> u64[src]

pub fn insert(&self, key: &Slice, value: &T)[src]

 let map: SkipMap<Slice> = SkipMap::default();
 map.insert(&Slice(b"key1".to_vec()), &Slice(b"value1".to_vec()));
 map.insert(&Slice(b"key2".to_vec()), &Slice(b"value2".to_vec()));
 map.insert(&Slice(b"key3".to_vec()), &Slice(b"value3".to_vec()));

 assert_eq!(
     map.find(&Slice(b"key1".to_vec())).unwrap(),
     Slice(b"value1".to_vec())
 );

 map.insert(
     &Slice(b"key1".to_vec()),
     &Slice(b"modified_value1".to_vec()),
 );
 assert_eq!(
     map.find(&Slice(b"key1".to_vec())).unwrap(),
     Slice(b"modified_value1".to_vec())
 );

pub fn find(&self, key: &Slice) -> Option<T>[src]

pub fn scan<R>(&self, range: R) -> Vec<(Slice, T)> where
    R: RangeBounds<Slice>, 
[src]

Trait Implementations

impl<T: Default + Clone> Default for SkipMap<T>[src]

Auto Trait Implementations

impl<T> Unpin for SkipMap<T> where
    T: Unpin

impl<T> Sync for SkipMap<T>

impl<T> Send for SkipMap<T>

impl<T> RefUnwindSafe for SkipMap<T>

impl<T> UnwindSafe for SkipMap<T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,