pub struct PropertyMap { /* private fields */ }Expand description
A compact, ordered property map.
Behaves like a BTreeMap<PropertyKey, Value> but stores small maps
inline (up to 4 entries) and uses linear scan for lookups. For the
sizes typical in graph workloads this is both faster and more
memory-efficient than a tree.
Implementations§
Source§impl PropertyMap
impl PropertyMap
Sourcepub fn with_capacity(cap: usize) -> Self
pub fn with_capacity(cap: usize) -> Self
Creates a property map with pre-allocated capacity.
Sourcepub fn get(&self, key: &PropertyKey) -> Option<&Value>
pub fn get(&self, key: &PropertyKey) -> Option<&Value>
Looks up a property by key.
Sourcepub fn contains_key(&self, key: &PropertyKey) -> bool
pub fn contains_key(&self, key: &PropertyKey) -> bool
Returns true if the map contains the given key.
Sourcepub fn insert(&mut self, key: PropertyKey, value: Value) -> Option<Value>
pub fn insert(&mut self, key: PropertyKey, value: Value) -> Option<Value>
Inserts a property, replacing any existing value for the same key.
Returns the previous value if the key was already present.
Sourcepub fn remove(&mut self, key: &PropertyKey) -> Option<Value>
pub fn remove(&mut self, key: &PropertyKey) -> Option<Value>
Removes a property by key, returning its value if present.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&PropertyKey, &Value)>
pub fn iter(&self) -> impl Iterator<Item = (&PropertyKey, &Value)>
Iterates over (key, value) pairs.
Sourcepub fn to_btree_map(&self) -> BTreeMap<PropertyKey, Value>
pub fn to_btree_map(&self) -> BTreeMap<PropertyKey, Value>
Converts to a BTreeMap (e.g. for serialization into Value::Map).
Trait Implementations§
Source§impl Clone for PropertyMap
impl Clone for PropertyMap
Source§fn clone(&self) -> PropertyMap
fn clone(&self) -> PropertyMap
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PropertyMap
impl Debug for PropertyMap
Source§impl Default for PropertyMap
impl Default for PropertyMap
Source§impl FromIterator<(PropertyKey, Value)> for PropertyMap
impl FromIterator<(PropertyKey, Value)> for PropertyMap
Source§fn from_iter<I: IntoIterator<Item = (PropertyKey, Value)>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = (PropertyKey, Value)>>(iter: I) -> Self
Creates a value from an iterator. Read more
Source§impl<'a> IntoIterator for &'a PropertyMap
impl<'a> IntoIterator for &'a PropertyMap
Source§type Item = (&'a PropertyKey, &'a Value)
type Item = (&'a PropertyKey, &'a Value)
The type of the elements being iterated over.
Source§type IntoIter = Map<Iter<'a, (PropertyKey, Value)>, fn(&'a (PropertyKey, Value)) -> (&'a PropertyKey, &'a Value)>
type IntoIter = Map<Iter<'a, (PropertyKey, Value)>, fn(&'a (PropertyKey, Value)) -> (&'a PropertyKey, &'a Value)>
Which kind of iterator are we turning this into?
Source§impl IntoIterator for PropertyMap
impl IntoIterator for PropertyMap
Source§impl PartialEq for PropertyMap
impl PartialEq for PropertyMap
impl StructuralPartialEq for PropertyMap
Auto Trait Implementations§
impl Freeze for PropertyMap
impl RefUnwindSafe for PropertyMap
impl Send for PropertyMap
impl Sync for PropertyMap
impl Unpin for PropertyMap
impl UnsafeUnpin for PropertyMap
impl UnwindSafe for PropertyMap
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