pub struct Map { /* private fields */ }tree only.Expand description
The members of an object of a tree, in the order in which they were written: a member that is added goes at the end, one that is given another value keeps its place, and one that is taken out leaves the others in theirs.
It is a list. An object of more than 256 members also keeps an index: the position of
each member under the hash of its name, in the order of the hashes, so that a member is
found by its name in a time that grows as log n, and no name is copied. Whatever builds
an object of n members with insert, finds each of them, reads one from
JSON or compares two takes a time that grows as n log n. Moving or taking out a member,
which moves those after it, takes a time that grows as n.
Implementations§
Source§impl Map
impl Map
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
An object without members, with room for capacity of them.
Sourcepub fn get_mut(&mut self, name: &str) -> Option<&mut Value>
pub fn get_mut(&mut self, name: &str) -> Option<&mut Value>
The member of this name, to change.
Sourcepub fn get_key_value(&self, name: &str) -> Option<(&String, &Value)>
pub fn get_key_value(&self, name: &str) -> Option<(&String, &Value)>
The member of this name, with its name as the object has it.
Sourcepub fn contains_key(&self, name: &str) -> bool
pub fn contains_key(&self, name: &str) -> bool
Whether it has a member of this name.
Sourcepub fn insert(&mut self, name: String, value: Value) -> Option<Value>
pub fn insert(&mut self, name: String, value: Value) -> Option<Value>
Give the member name the value value: at its place when the object has it,
and at the end otherwise. The value that it had, if any.
Sourcepub fn shift_insert(
&mut self,
position: usize,
name: String,
value: Value,
) -> Option<Value>
pub fn shift_insert( &mut self, position: usize, name: String, value: Value, ) -> Option<Value>
Give the member name the value value at position, or at the end for a position
past it: the member moves there when the object has it. The value that it had, if
any.
Sourcepub fn shift_remove(&mut self, name: &str) -> Option<Value>
pub fn shift_remove(&mut self, name: &str) -> Option<Value>
Take the member name out, and leave the others in their order.
Sourcepub fn remove(&mut self, name: &str) -> Option<Value>
pub fn remove(&mut self, name: &str) -> Option<Value>
Take the member name out, and leave the others in their order: as
shift_remove, which keeps the order of the members, and
not as the swap_remove of an IndexMap.
Sourcepub fn entry(&mut self, name: impl Into<String>) -> Entry<'_>
pub fn entry(&mut self, name: impl Into<String>) -> Entry<'_>
The member name, to give it a value when it has none.
Sourcepub fn retain(&mut self, keep: impl FnMut(&String, &mut Value) -> bool)
pub fn retain(&mut self, keep: impl FnMut(&String, &mut Value) -> bool)
Keep the members for which keep says so.
Sourcepub fn iter(
&self,
) -> impl DoubleEndedIterator<Item = (&String, &Value)> + ExactSizeIterator
pub fn iter( &self, ) -> impl DoubleEndedIterator<Item = (&String, &Value)> + ExactSizeIterator
The members, in their order.
Sourcepub fn iter_mut(
&mut self,
) -> impl DoubleEndedIterator<Item = (&String, &mut Value)> + ExactSizeIterator
pub fn iter_mut( &mut self, ) -> impl DoubleEndedIterator<Item = (&String, &mut Value)> + ExactSizeIterator
The members, in their order, to change their values.
Sourcepub fn keys(
&self,
) -> impl DoubleEndedIterator<Item = &String> + ExactSizeIterator
pub fn keys( &self, ) -> impl DoubleEndedIterator<Item = &String> + ExactSizeIterator
The names of the members, in their order.
Sourcepub fn values(
&self,
) -> impl DoubleEndedIterator<Item = &Value> + ExactSizeIterator
pub fn values( &self, ) -> impl DoubleEndedIterator<Item = &Value> + ExactSizeIterator
The values of the members, in their order.
Sourcepub fn values_mut(
&mut self,
) -> impl DoubleEndedIterator<Item = &mut Value> + ExactSizeIterator
pub fn values_mut( &mut self, ) -> impl DoubleEndedIterator<Item = &mut Value> + ExactSizeIterator
The values of the members, in their order, to change them.
Trait Implementations§
impl Eq for Map
Source§impl Extend<(String, Value)> for Map
impl Extend<(String, Value)> for Map
Source§fn extend<I: IntoIterator<Item = (String, Value)>>(&mut self, members: I)
fn extend<I: IntoIterator<Item = (String, Value)>>(&mut self, members: I)
The members after those of the object, as insert adds them one
after the other.
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)