[−][src]Struct exonum_merkledb::indexes::KeySetIndex
A set of key items.
KeySetIndex
implements a set that stores the elements as keys with empty values.
KeySetIndex
requires that elements should implement the BinaryKey
trait.
Methods
impl<T, K: ?Sized> KeySetIndex<T, K> where
T: RawAccess,
K: BinaryKey,
[src]
T: RawAccess,
K: BinaryKey,
pub fn contains(&self, item: &K) -> bool
[src]
Returns true
if the set contains the indicated value.
Examples
use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, KeySetIndex}; let db = TemporaryDB::new(); let fork = db.fork(); let mut index = fork.get_key_set("name"); assert!(!index.contains(&1)); index.insert(&1); assert!(index.contains(&1));
pub fn iter(&self) -> Keys<K>
[src]
Returns an iterator over set elements.
Examples
use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, KeySetIndex}; let db = TemporaryDB::new(); let fork = db.fork(); let index = fork.get_key_set::<_, u8>("name"); for val in index.iter() { println!("{}", val); }
pub fn iter_from(&self, from: &K) -> Keys<K>
[src]
Returns an iterator over set elements starting from the specified value.
Examples
use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, KeySetIndex}; let db = TemporaryDB::new(); let fork = db.fork(); let index = fork.get_key_set::<_, u8>("name"); for val in index.iter_from(&2) { println!("{}", val); }
impl<T, K: ?Sized> KeySetIndex<T, K> where
T: RawAccessMut,
K: BinaryKey,
[src]
T: RawAccessMut,
K: BinaryKey,
pub fn insert(&mut self, item: &K)
[src]
Adds a key to the set.
Examples
use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, KeySetIndex}; let db = TemporaryDB::new(); let fork = db.fork(); let mut index = fork.get_key_set("name"); index.insert(&1); assert!(index.contains(&1));
pub fn remove(&mut self, item: &K)
[src]
Removes a key from the set.
Examples
use exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, KeySetIndex}; let db = TemporaryDB::new(); let fork = db.fork(); let mut index = fork.get_key_set("name"); index.insert(&1); assert!(index.contains(&1)); index.remove(&1); assert!(!index.contains(&1));
pub fn clear(&mut self)
[src]
Clears the set, removing all values.
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 exonum_merkledb::{access::CopyAccessExt, TemporaryDB, Database, KeySetIndex}; let db = TemporaryDB::new(); let fork = db.fork(); let mut index = fork.get_key_set("name"); index.insert(&1); assert!(index.contains(&1)); index.clear(); assert!(!index.contains(&1));
Trait Implementations
impl<T: Debug + RawAccess, K: Debug + ?Sized> Debug for KeySetIndex<T, K>
[src]
impl<T, K: ?Sized> FromAccess<T> for KeySetIndex<T::Base, K> where
T: Access,
K: BinaryKey,
[src]
T: Access,
K: BinaryKey,
fn from_access(access: T, addr: IndexAddress) -> Result<Self, AccessError>
[src]
fn from_root(access: T) -> Result<Self, AccessError>
[src]
impl<T, K: ?Sized> IndexIterator for KeySetIndex<T, K> where
T: RawAccess,
K: BinaryKey,
[src]
T: RawAccess,
K: BinaryKey,
type Key = K
Type encompassing index keys.
type Value = ()
Type encompassing index values.
fn index_iter(&self, from: Option<&K>) -> Entries<K, ()>
[src]
impl<'a, T, K: ?Sized> IntoIterator for &'a KeySetIndex<T, K> where
T: RawAccess,
K: BinaryKey,
[src]
T: RawAccess,
K: BinaryKey,
Auto Trait Implementations
impl<T, K: ?Sized> RefUnwindSafe for KeySetIndex<T, K> where
K: RefUnwindSafe,
T: RefUnwindSafe,
<T as RawAccess>::Changes: RefUnwindSafe,
K: RefUnwindSafe,
T: RefUnwindSafe,
<T as RawAccess>::Changes: RefUnwindSafe,
impl<T, K: ?Sized> Send for KeySetIndex<T, K> where
K: Send,
T: Send,
<T as RawAccess>::Changes: Send,
K: Send,
T: Send,
<T as RawAccess>::Changes: Send,
impl<T, K: ?Sized> Sync for KeySetIndex<T, K> where
K: Sync,
T: Sync,
<T as RawAccess>::Changes: Sync,
K: Sync,
T: Sync,
<T as RawAccess>::Changes: Sync,
impl<T, K: ?Sized> Unpin for KeySetIndex<T, K> where
K: Unpin,
T: Unpin,
<T as RawAccess>::Changes: Unpin,
K: Unpin,
T: Unpin,
<T as RawAccess>::Changes: Unpin,
impl<T, K: ?Sized> UnwindSafe for KeySetIndex<T, K> where
K: UnwindSafe,
T: UnwindSafe,
<T as RawAccess>::Changes: UnwindSafe,
K: UnwindSafe,
T: UnwindSafe,
<T as RawAccess>::Changes: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,