[−][src]Struct agilulf_skiplist::SkipMap
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]
R: RangeBounds<Slice>,
Trait Implementations
Auto Trait Implementations
impl<T> Send for SkipMap<T>
impl<T> Unpin for SkipMap<T> where
T: Unpin,
T: Unpin,
impl<T> Sync for SkipMap<T>
impl<T> UnwindSafe for SkipMap<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> RefUnwindSafe for SkipMap<T>
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,