Struct matterdb::indexes::MapIndex [−][src]
A map of keys and values. Access to the elements of this map is obtained using the keys.
MapIndex
requires that keys implement the BinaryKey
trait and values implement
the BinaryValue
trait.
Implementations
impl<T, K: ?Sized, V> MapIndex<T, K, V> where
T: RawAccess,
K: BinaryKey,
V: BinaryValue,
[src]
impl<T, K: ?Sized, V> MapIndex<T, K, V> where
T: RawAccess,
K: BinaryKey,
V: BinaryValue,
[src]pub fn get(&self, key: &K) -> Option<V>
[src]
pub fn get(&self, key: &K) -> Option<V>
[src]Returns a value corresponding to the key.
Examples
use matterdb::{access::CopyAccessExt, TemporaryDB, Database, MapIndex}; let db = TemporaryDB::default(); let fork = db.fork(); let mut index = fork.get_map("name"); assert!(index.get(&1).is_none()); index.put(&1, 2); assert_eq!(Some(2), index.get(&1));
pub fn contains(&self, key: &K) -> bool
[src]
pub fn contains(&self, key: &K) -> bool
[src]Returns true
if the map contains a value corresponding to the specified key.
Examples
use matterdb::{access::CopyAccessExt, TemporaryDB, Database, MapIndex}; let db = TemporaryDB::default(); let fork = db.fork(); let mut index = fork.get_map("name"); assert!(!index.contains(&1)); index.put(&1, 2); assert!(index.contains(&1));
pub fn iter(&self) -> Entries<'_, K, V>ⓘ
[src]
pub fn iter(&self) -> Entries<'_, K, V>ⓘ
[src]Returns an iterator over the entries of the map in ascending order.
Examples
use matterdb::{access::CopyAccessExt, TemporaryDB, Database, MapIndex}; let db = TemporaryDB::default(); let fork = db.fork(); let index: MapIndex<_, u8, u8> = fork.get_map("name"); for v in index.iter() { println!("{:?}", v); }
pub fn keys(&self) -> Keys<'_, K>ⓘ
[src]
pub fn keys(&self) -> Keys<'_, K>ⓘ
[src]Returns an iterator over the keys of a map in ascending order.
Examples
use matterdb::{access::CopyAccessExt, TemporaryDB, Database, MapIndex}; let db = TemporaryDB::default(); let fork = db.fork(); let index: MapIndex<_, u8, u8> = fork.get_map("name"); for key in index.keys() { println!("{}", key); }
pub fn values(&self) -> Values<'_, V>ⓘNotable traits for Values<'_, V>
impl<V> Iterator for Values<'_, V> where
V: BinaryValue, type Item = V;
[src]
pub fn values(&self) -> Values<'_, V>ⓘNotable traits for Values<'_, V>
impl<V> Iterator for Values<'_, V> where
V: BinaryValue, type Item = V;
[src]Returns an iterator over the values of a map in ascending order of keys.
Examples
use matterdb::{access::CopyAccessExt, TemporaryDB, Database, MapIndex}; let db = TemporaryDB::default(); let fork = db.fork(); let index: MapIndex<_, u8, u8> = fork.get_map("name"); for val in index.values() { println!("{}", val); }
pub fn iter_from(&self, from: &K) -> Entries<'_, K, V>ⓘ
[src]
pub fn iter_from(&self, from: &K) -> Entries<'_, K, V>ⓘ
[src]Returns an iterator over the entries of a map in ascending order starting from the specified key.
Examples
use matterdb::{access::CopyAccessExt, TemporaryDB, Database, MapIndex}; let db = TemporaryDB::default(); let fork = db.fork(); let index: MapIndex<_, u8, u8> = fork.get_map("name"); for v in index.iter_from(&2) { println!("{:?}", v); }
pub fn keys_from(&self, from: &K) -> Keys<'_, K>ⓘ
[src]
pub fn keys_from(&self, from: &K) -> Keys<'_, K>ⓘ
[src]Returns an iterator over the keys of a map in ascending order starting from the specified key.
Examples
use matterdb::{access::CopyAccessExt, TemporaryDB, Database, MapIndex}; let db = TemporaryDB::default(); let fork = db.fork(); let index: MapIndex<_, u8, u8> = fork.get_map("name"); for key in index.keys_from(&2) { println!("{}", key); }
pub fn values_from(&self, from: &K) -> Values<'_, V>ⓘNotable traits for Values<'_, V>
impl<V> Iterator for Values<'_, V> where
V: BinaryValue, type Item = V;
[src]
pub fn values_from(&self, from: &K) -> Values<'_, V>ⓘNotable traits for Values<'_, V>
impl<V> Iterator for Values<'_, V> where
V: BinaryValue, type Item = V;
[src]Returns an iterator over the values of a map in ascending order of keys starting from the specified key.
Examples
use matterdb::{access::CopyAccessExt, TemporaryDB, Database, MapIndex}; let db = TemporaryDB::default(); let fork = db.fork(); let index: MapIndex<_, u8, u8> = fork.get_map("name"); for val in index.values_from(&2) { println!("{}", val); }
impl<T, K: ?Sized, V> MapIndex<T, K, V> where
T: RawAccessMut,
K: BinaryKey,
V: BinaryValue,
[src]
impl<T, K: ?Sized, V> MapIndex<T, K, V> where
T: RawAccessMut,
K: BinaryKey,
V: BinaryValue,
[src]pub fn put(&mut self, key: &K, value: V)
[src]
pub fn put(&mut self, key: &K, value: V)
[src]Inserts a key-value pair into a map.
Examples
use matterdb::{access::CopyAccessExt, TemporaryDB, Database, MapIndex}; let db = TemporaryDB::default(); let fork = db.fork(); let mut index = fork.get_map("name"); index.put(&1, 2); assert!(index.contains(&1));
pub fn remove<Q: ?Sized>(&mut self, key: &Q) where
K: Borrow<Q>,
Q: BinaryKey,
[src]
pub fn remove<Q: ?Sized>(&mut self, key: &Q) where
K: Borrow<Q>,
Q: BinaryKey,
[src]Removes a key from a map.
Examples
use matterdb::{access::CopyAccessExt, TemporaryDB, Database, MapIndex}; let db = TemporaryDB::default(); let fork = db.fork(); let mut index = fork.get_map("name"); index.put(&1, 2); assert!(index.contains(&1)); index.remove(&1); assert!(!index.contains(&1));
pub fn clear(&mut self)
[src]
pub fn clear(&mut self)
[src]Clears a map, removing all entries.
Notes
Currently, this method is not optimized to delete a large set of data. During the execution of this method, the amount of allocated memory is linearly dependent on the number of elements in the index.
Examples
use matterdb::{access::CopyAccessExt, TemporaryDB, Database, MapIndex}; let db = TemporaryDB::default(); let fork = db.fork(); let mut index = fork.get_map("name"); index.put(&1, 2); assert!(index.contains(&1)); index.clear(); assert!(!index.contains(&1));
Trait Implementations
impl<T, K: ?Sized, V> FromAccess<T> for MapIndex<T::Base, K, V> where
T: Access,
K: BinaryKey,
V: BinaryValue,
[src]
impl<T, K: ?Sized, V> FromAccess<T> for MapIndex<T::Base, K, V> where
T: Access,
K: BinaryKey,
V: BinaryValue,
[src]fn from_access(access: T, addr: IndexAddress) -> Result<Self, AccessError>
[src]
fn from_access(access: T, addr: IndexAddress) -> Result<Self, AccessError>
[src]Constructs the object at the given address. Read more
fn from_root(access: T) -> Result<Self, AccessError>
[src]
fn from_root(access: T) -> Result<Self, AccessError>
[src]Constructs the object from the root of the access
. Read more
impl<T, K: ?Sized, V> IndexIterator for MapIndex<T, K, V> where
T: RawAccess,
K: BinaryKey,
V: BinaryValue,
[src]
impl<T, K: ?Sized, V> IndexIterator for MapIndex<T, K, V> where
T: RawAccess,
K: BinaryKey,
V: BinaryValue,
[src]impl<'a, T, K: ?Sized, V> IntoIterator for &'a MapIndex<T, K, V> where
T: RawAccess,
K: BinaryKey,
V: BinaryValue,
[src]
impl<'a, T, K: ?Sized, V> IntoIterator for &'a MapIndex<T, K, V> where
T: RawAccess,
K: BinaryKey,
V: BinaryValue,
[src]Auto Trait Implementations
impl<T, K: ?Sized, V> RefUnwindSafe for MapIndex<T, K, V> where
K: RefUnwindSafe,
T: RefUnwindSafe,
V: RefUnwindSafe,
<T as RawAccess>::Changes: RefUnwindSafe,
K: RefUnwindSafe,
T: RefUnwindSafe,
V: RefUnwindSafe,
<T as RawAccess>::Changes: RefUnwindSafe,
impl<T, K: ?Sized, V> Send for MapIndex<T, K, V> where
K: Send,
T: Send,
V: Send,
<T as RawAccess>::Changes: Send,
K: Send,
T: Send,
V: Send,
<T as RawAccess>::Changes: Send,
impl<T, K: ?Sized, V> Sync for MapIndex<T, K, V> where
K: Sync,
T: Sync,
V: Sync,
<T as RawAccess>::Changes: Sync,
K: Sync,
T: Sync,
V: Sync,
<T as RawAccess>::Changes: Sync,
impl<T, K: ?Sized, V> Unpin for MapIndex<T, K, V> where
K: Unpin,
T: Unpin,
V: Unpin,
<T as RawAccess>::Changes: Unpin,
K: Unpin,
T: Unpin,
V: Unpin,
<T as RawAccess>::Changes: Unpin,
impl<T, K: ?Sized, V> UnwindSafe for MapIndex<T, K, V> where
K: UnwindSafe,
T: UnwindSafe,
V: UnwindSafe,
<T as RawAccess>::Changes: UnwindSafe,
K: UnwindSafe,
T: UnwindSafe,
V: UnwindSafe,
<T as RawAccess>::Changes: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T