pub struct Dict { /* private fields */ }Expand description
A dictionary: keys mapped to values, sorted by key.
Its entries lie in a balanced tree of chunks, as a list’s elements do, in key order, and every branch keeps the key of its first entry. Looking up, inserting or removing a key costs O(log n) comparisons and steps.
Implementations§
Source§impl Dict
impl Dict
Sourcepub fn from_entries(
entries: impl IntoIterator<Item = (Value, Value)>,
) -> Result<Dict, DataError>
pub fn from_entries( entries: impl IntoIterator<Item = (Value, Value)>, ) -> Result<Dict, DataError>
Sourcepub fn iter(&self) -> impl ExactSizeIterator<Item = (&Value, &Value)>
pub fn iter(&self) -> impl ExactSizeIterator<Item = (&Value, &Value)>
Returns the entries, in key order.
Sourcepub fn keys(&self) -> impl ExactSizeIterator<Item = &Value>
pub fn keys(&self) -> impl ExactSizeIterator<Item = &Value>
Returns the keys, in key order.
Sourcepub fn values(&self) -> impl ExactSizeIterator<Item = &Value>
pub fn values(&self) -> impl ExactSizeIterator<Item = &Value>
Returns the values, in key order.
Sourcepub fn root(&self) -> Option<&Node<(Value, Value)>>
pub fn root(&self) -> Option<&Node<(Value, Value)>>
Returns the tree the entries lie in, in ascending key order, or
None when there are none.
Sourcepub fn from_tree(root: Option<Node<(Value, Value)>>) -> Dict
pub fn from_tree(root: Option<Node<(Value, Value)>>) -> Dict
Returns the dictionary whose entries are those of root, sharing it.
The keys must ascend across the whole tree and be distinct, as those
of Dict::root do; the caller checks that, as reading history
does, and a debug build checks it again. This costs constant time.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Dict
impl !UnwindSafe for Dict
impl Forget for Dict
impl Freeze for Dict
impl Move for Dict
impl Send for Dict
impl Sync for Dict
impl Unpin for Dict
impl UnsafeUnpin for Dictwhere
*const ArcInner<Inner<(Value, Value)>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Inner<(Value, Value)>>>: UnsafeUnpin,
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