pub struct Art<K, V> { /* private fields */ }
Expand description
Adaptive Radix Tree.
Radix tree is ordered according to key. Radix tree requires that key to be representable as comparable by sequence, e.g. key should implement Key trait which used to convert it to byte sequence.
This crate provides Key implementations for most commonly used data types:
- unsigned integers(u8, u16, u32, u64, u128)
- signed integers(i8, i16, i32, i64, i128)
- usize
- floating point numbers through Float32/Float64 types
- ByteString for raw byte sequences. It can be used for ASCII strings(UTF-8 strings not supported now, they require additional library to convert into comparable byte sequence).
Implementations§
Source§impl<K: Key, V> Art<K, V>
impl<K: Key, V> Art<K, V>
Sourcepub fn insert(&mut self, key: K, value: V) -> bool
pub fn insert(&mut self, key: K, value: V) -> bool
Insert key-value pair into tree.
Return true
if key-value successfully inserted into tree, otherwise false
if tree
already contains same key.
Sourcepub fn upsert(&mut self, key: K, value: V)
pub fn upsert(&mut self, key: K, value: V)
Insert key-value pair into tree. If key already exists in tree, existing value will be replaced, otherwise inserts new KV into tree.
Sourcepub fn remove(&mut self, key: &K) -> Option<V>
pub fn remove(&mut self, key: &K) -> Option<V>
Remove value associated with key.
Returns Some(V)
if key found in tree, otherwise None
.
Sourcepub fn get(&self, key: &K) -> Option<&V>
pub fn get(&self, key: &K) -> Option<&V>
Get value associated with key.
Returns Some(V)
if key found in tree, otherwise None
.
Sourcepub fn range(
&self,
range: impl RangeBounds<K>,
) -> impl DoubleEndedIterator<Item = (&K, &V)>where
K: Ord,
pub fn range(
&self,
range: impl RangeBounds<K>,
) -> impl DoubleEndedIterator<Item = (&K, &V)>where
K: Ord,
Execute tree range scan.