Struct zerovec::map2d::cursor::ZeroMap2dCursor

source ·
pub struct ZeroMap2dCursor<'l, 'a, K0, K1, V>
where K0: ZeroMapKV<'a> + ?Sized, K1: ZeroMapKV<'a> + ?Sized, V: ZeroMapKV<'a> + ?Sized,
{ keys0: &'l K0::Slice, joiner: &'l ZeroSlice<u32>, keys1: &'l K1::Slice, values: &'l V::Slice, key0_index: usize, }
Expand description

An intermediate state of queries over ZeroMap2d and ZeroMap2dBorrowed.

Fields§

§keys0: &'l K0::Slice§joiner: &'l ZeroSlice<u32>§keys1: &'l K1::Slice§values: &'l V::Slice§key0_index: usize

Implementations§

source§

impl<'a, K0, K1, V> ZeroMap2dCursor<'a, 'a, K0, K1, V>
where K0: ZeroMapKV<'a> + ?Sized, K1: ZeroMapKV<'a> + ?Sized, V: ZeroMapKV<'a> + ?Sized,

source

pub(crate) fn from_borrowed( borrowed: &ZeroMap2dBorrowed<'a, K0, K1, V>, key0_index: usize, ) -> Self

key0_index must be in range

source§

impl<'l, 'a, K0, K1, V> ZeroMap2dCursor<'l, 'a, K0, K1, V>
where K0: ZeroMapKV<'a> + ?Sized, K1: ZeroMapKV<'a> + ?Sized, V: ZeroMapKV<'a> + ?Sized,

source

pub(crate) fn from_cow( cow: &'l ZeroMap2d<'a, K0, K1, V>, key0_index: usize, ) -> Self

key0_index must be in range

source

pub fn key0(&self) -> &'l K0::GetType

Returns the key0 corresponding to the cursor position.

use zerovec::ZeroMap2d;

let mut map = ZeroMap2d::new();
map.insert("one", &1u32, "foo");
assert_eq!(map.get0("one").unwrap().key0(), "one");
source

pub fn iter1( &self, ) -> impl Iterator<Item = (&'l <K1 as ZeroMapKV<'a>>::GetType, &'l <V as ZeroMapKV<'a>>::GetType)> + '_

Borrow an ordered iterator over keys1 and values for a particular key0.

To get the values as copy types, see Self::iter1_copied.

For an example, see ZeroMap2d::iter0().

source

pub fn into_iter1( self, ) -> impl Iterator<Item = (&'l <K1 as ZeroMapKV<'a>>::GetType, &'l <V as ZeroMapKV<'a>>::GetType)>

Transform this cursor into an ordered iterator over keys1 for a particular key0.

source

pub(super) fn get_range(&self) -> Range<usize>

Given key0_index, returns the corresponding range of keys1, which will be valid

source§

impl<'l, 'a, K0, K1, V> ZeroMap2dCursor<'l, 'a, K0, K1, V>
where K0: ZeroMapKV<'a> + ?Sized, K1: ZeroMapKV<'a> + ?Sized, V: ZeroMapKV<'a> + Copy,

source

pub fn iter1_copied( &self, ) -> impl Iterator<Item = (&'l <K1 as ZeroMapKV<'a>>::GetType, V)> + '_

Borrow an ordered iterator over keys1 and values for a particular key0.

The values are returned as copy types.

§Examples
use zerovec::ZeroMap2d;

let zm2d: ZeroMap2d<str, u8, usize> = [
    ("a", 0u8, 1usize),
    ("b", 1u8, 1000usize),
    ("b", 2u8, 2000usize),
]
.into_iter()
.collect();

let mut total_value = 0;

for cursor in zm2d.iter0() {
    for (_, value) in cursor.iter1_copied() {
        total_value += value;
    }
}

assert_eq!(total_value, 3001);
source

fn get1_copied_at(&self, index: usize) -> Option<V>

source§

impl<'l, 'a, K0, K1, V> ZeroMap2dCursor<'l, 'a, K0, K1, V>
where K0: ZeroMapKV<'a> + ?Sized, K1: ZeroMapKV<'a> + Ord + ?Sized, V: ZeroMapKV<'a> + ?Sized,

source

pub fn get1(&self, key1: &K1) -> Option<&'l V::GetType>

Gets the value for a key1 from this cursor, or None if key1 is not in the map.

use zerovec::ZeroMap2d;

let mut map = ZeroMap2d::new();
map.insert("one", &1u32, "foo");
assert_eq!(map.get0("one").unwrap().get1(&1), Some("foo"));
assert_eq!(map.get0("one").unwrap().get1(&2), None);
source

pub fn get1_by( &self, predicate: impl FnMut(&K1) -> Ordering, ) -> Option<&'l V::GetType>

Gets the value for a predicate from this cursor, or None if key1 is not in the map.

use zerovec::ZeroMap2d;

let mut map = ZeroMap2d::new();
map.insert("one", &1u32, "foo");
assert_eq!(map.get0("one").unwrap().get1_by(|v| v.cmp(&1)), Some("foo"));
assert_eq!(map.get0("one").unwrap().get1_by(|v| v.cmp(&2)), None);
source

fn get_key1_index_by( &self, predicate: impl FnMut(&K1) -> Ordering, ) -> Option<usize>

Given key0_index and predicate, returns the index into the values array

source

fn get_key1_index(&self, key1: &K1) -> Option<usize>

Given key0_index and key1, returns the index into the values array

source§

impl<'l, 'a, K0, K1, V> ZeroMap2dCursor<'l, 'a, K0, K1, V>
where K0: ZeroMapKV<'a> + ?Sized, K1: ZeroMapKV<'a> + Ord + ?Sized, V: ZeroMapKV<'a> + Copy,

source

pub fn get1_copied(&self, key1: &K1) -> Option<V>

For cases when V is fixed-size, obtain a direct copy of V instead of V::ULE

use zerovec::ZeroMap2d;

let mut map: ZeroMap2d<u16, u16, u16> = ZeroMap2d::new();
map.insert(&1, &2, &3);
map.insert(&1, &4, &5);
map.insert(&6, &7, &8);

assert_eq!(map.get0(&6).unwrap().get1_copied(&7), Some(8));
source

pub fn get1_copied_by( &self, predicate: impl FnMut(&K1) -> Ordering, ) -> Option<V>

For cases when V is fixed-size, obtain a direct copy of V instead of V::ULE

Trait Implementations§

source§

impl<'l, 'a, K0, K1, V> Debug for ZeroMap2dCursor<'l, 'a, K0, K1, V>
where K0: ZeroMapKV<'a> + ?Sized, K1: ZeroMapKV<'a> + ?Sized, V: ZeroMapKV<'a> + ?Sized, K0::Slice: Debug, K1::Slice: Debug, V::Slice: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'m, 'n, 'a, 'b, K0, K1, V> PartialEq<ZeroMap2dCursor<'n, 'b, K0, K1, V>> for ZeroMap2dCursor<'m, 'a, K0, K1, V>
where K0: for<'c> ZeroMapKV<'c> + ?Sized, K1: for<'c> ZeroMapKV<'c> + ?Sized, V: for<'c> ZeroMapKV<'c> + ?Sized, <K0 as ZeroMapKV<'a>>::Slice: PartialEq<<K0 as ZeroMapKV<'b>>::Slice>, <K1 as ZeroMapKV<'a>>::Slice: PartialEq<<K1 as ZeroMapKV<'b>>::Slice>, <V as ZeroMapKV<'a>>::Slice: PartialEq<<V as ZeroMapKV<'b>>::Slice>,

source§

fn eq(&self, other: &ZeroMap2dCursor<'n, 'b, K0, K1, V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<'l, 'a, K0, K1, V> Freeze for ZeroMap2dCursor<'l, 'a, K0, K1, V>
where K0: ?Sized, K1: ?Sized, V: ?Sized,

§

impl<'l, 'a, K0, K1, V> RefUnwindSafe for ZeroMap2dCursor<'l, 'a, K0, K1, V>
where <K0 as ZeroMapKV<'a>>::Slice: RefUnwindSafe, <K1 as ZeroMapKV<'a>>::Slice: RefUnwindSafe, <V as ZeroMapKV<'a>>::Slice: RefUnwindSafe, K0: ?Sized, K1: ?Sized, V: ?Sized,

§

impl<'l, 'a, K0, K1, V> Send for ZeroMap2dCursor<'l, 'a, K0, K1, V>
where <K0 as ZeroMapKV<'a>>::Slice: Sync, <K1 as ZeroMapKV<'a>>::Slice: Sync, <V as ZeroMapKV<'a>>::Slice: Sync, K0: ?Sized, K1: ?Sized, V: ?Sized,

§

impl<'l, 'a, K0, K1, V> Sync for ZeroMap2dCursor<'l, 'a, K0, K1, V>
where <K0 as ZeroMapKV<'a>>::Slice: Sync, <K1 as ZeroMapKV<'a>>::Slice: Sync, <V as ZeroMapKV<'a>>::Slice: Sync, K0: ?Sized, K1: ?Sized, V: ?Sized,

§

impl<'l, 'a, K0, K1, V> Unpin for ZeroMap2dCursor<'l, 'a, K0, K1, V>
where K0: ?Sized, K1: ?Sized, V: ?Sized,

§

impl<'l, 'a, K0, K1, V> UnwindSafe for ZeroMap2dCursor<'l, 'a, K0, K1, V>
where <K0 as ZeroMapKV<'a>>::Slice: RefUnwindSafe, <K1 as ZeroMapKV<'a>>::Slice: RefUnwindSafe, <V as ZeroMapKV<'a>>::Slice: RefUnwindSafe, K0: ?Sized, K1: ?Sized, V: ?Sized,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> ErasedDestructor for T
where T: 'static,