Add Index trait impls

next
Sayan Nandan 2 years ago
parent 29a4cceea1
commit ae516b7168
No known key found for this signature in database
GPG Key ID: 8BC07A0A4D41DD52

@ -67,14 +67,14 @@ impl<T: Clone> AsValue for T {
}
}
pub trait MTIndex<K, V>
/// The base spec for any index. Iterators have meaningless order, and that is intentional and oftentimes
/// consequential. For more specialized impls, use the [`STIndex`], [`MTIndex`] or [`STIndexSeq`] traits
pub trait IndexBaseSpec<K, V>
where
K: AsKey,
V: AsValue,
{
/// State whether the underlying structure provides any ordering on the iterators
const HAS_ORDER: bool;
/// Base support prealloc?
/// Index supports prealloc?
const PREALLOC: bool;
/// An iterator over the keys and values
type IterKV<'a>: Iterator<Item = (&'a K, &'a V)>
@ -92,10 +92,26 @@ where
where
Self: 'a,
V: 'a;
/// Initialize an empty instance of the MTIndex
fn mt_init() -> Self;
/// Initialize a pre-loaded instance of the MTIndex
fn mt_init_with(s: Self) -> Self;
// init
/// Initialize an empty instance of the index
fn idx_init() -> Self;
/// Initialize a pre-loaded instance of the index
fn idx_init_with(s: Self) -> Self;
// iter
/// Returns an iterator over a tuple of keys and values
fn idx_iter_kv<'a>(&'a self) -> Self::IterKV<'a>;
/// Returns an iterator over the keys
fn idx_iter_key<'a>(&'a self) -> Self::IterKey<'a>;
/// Returns an iterator over the values
fn idx_iter_value<'a>(&'a self) -> Self::IterValue<'a>;
}
/// An unordered MTIndex
pub trait MTIndex<K, V>: IndexBaseSpec<K, V>
where
K: AsKey,
V: AsValue,
{
/// Clears all the entries in the MTIndex
fn mt_clear(&self);
// write
@ -104,71 +120,47 @@ where
fn mt_insert(&self, key: K, val: V) -> bool;
/// Updates or inserts the given value
fn mt_upsert(&self, key: K, val: V);
// read
/// Returns a reference to the value corresponding to the key, if it exists
fn mt_get<Q>(&self, key: &Q) -> Option<&K>
fn mt_get<Q>(&self, key: &Q) -> Option<&V>
where
K: Borrow<Q>;
K: Borrow<Q>,
Q: ?Sized + AsKeyRef;
/// Returns a clone of the value corresponding to the key, if it exists
fn mt_get_cloned<Q>(&self, key: &Q) -> Option<K>
fn mt_get_cloned<Q>(&self, key: &Q) -> Option<V>
where
K: Borrow<Q>;
K: Borrow<Q>,
Q: ?Sized + AsKeyRef;
// update
/// Returns true if the entry is updated
fn mt_update<Q>(&self, key: &Q, val: V) -> bool
where
K: Borrow<Q>;
K: Borrow<Q>,
Q: ?Sized + AsKeyRef;
/// Updates the entry and returns the old value, if it exists
fn mt_update_return<Q>(&self, key: &Q, val: V) -> Option<K>
fn mt_update_return<Q>(&self, key: &Q, val: V) -> Option<V>
where
K: Borrow<Q>;
K: Borrow<Q>,
Q: ?Sized + AsKeyRef;
// delete
/// Returns true if the entry was deleted
fn mt_delete<Q>(&self, key: &Q) -> bool
where
K: Borrow<Q>;
K: Borrow<Q>,
Q: ?Sized + AsKeyRef;
/// Removes the entry and returns it, if it exists
fn mt_delete_return<Q>(&self, key: &Q) -> Option<K>
fn mt_delete_return<Q>(&self, key: &Q) -> Option<V>
where
K: Borrow<Q>;
// iter
/// Returns an iterator over a tuple of keys and values
fn mt_iter_kv<'a>(&'a self) -> Self::IterKV<'a>;
/// Returns an iterator over the keys
fn mt_iter_k<'a>(&'a self) -> Self::IterKey<'a>;
/// Returns an iterator over the values
fn mt_iter_v<'a>(&'a self) -> Self::IterValue<'a>;
K: Borrow<Q>,
Q: ?Sized + AsKeyRef;
}
pub trait STIndex<K, V> {
/// State whether the underlying structure provides any ordering on the iterators
const HAS_ORDER: bool;
/// Base support prealloc?
const PREALLOC: bool;
/// An iterator over the keys and values
type IterKV<'a>: Iterator<Item = (&'a K, &'a V)>
where
Self: 'a,
K: 'a,
V: 'a;
/// An iterator over the keys
type IterKey<'a>: Iterator<Item = &'a K>
where
Self: 'a,
K: 'a;
/// An iterator over the values
type IterValue<'a>: Iterator<Item = &'a V>
where
Self: 'a,
V: 'a;
/// Initialize an empty instance of the MTIndex
fn st_init() -> Self;
/// Initialize a pre-loaded instance of the MTIndex
fn st_init_with(s: Self) -> Self;
/// An unordered STIndex
pub trait STIndex<K, V>: IndexBaseSpec<K, V>
where
K: AsKey,
V: AsValue,
{
/// Clears all the entries in the STIndex
fn st_clear(&mut self);
// write
@ -177,42 +169,66 @@ pub trait STIndex<K, V> {
fn st_insert(&mut self, key: K, val: V) -> bool;
/// Updates or inserts the given value
fn st_upsert(&mut self, key: K, val: V);
// read
/// Returns a reference to the value corresponding to the key, if it exists
fn st_get<Q>(&self, key: &Q) -> Option<&K>
fn st_get<Q>(&self, key: &Q) -> Option<&V>
where
K: Borrow<Q>;
K: Borrow<Q>,
Q: ?Sized + AsKeyRef;
/// Returns a clone of the value corresponding to the key, if it exists
fn st_get_cloned<Q>(&self, key: &Q) -> Option<K>
fn st_get_cloned<Q>(&self, key: &Q) -> Option<V>
where
K: Borrow<Q>;
K: Borrow<Q>,
Q: ?Sized + AsKeyRef;
// update
/// Returns true if the entry is updated
fn st_update<Q>(&mut self, key: &Q, val: V) -> bool
where
K: Borrow<Q>;
K: Borrow<Q>,
Q: ?Sized + AsKeyRef;
/// Updates the entry and returns the old value, if it exists
fn st_update_return<Q>(&mut self, key: &Q, val: V) -> Option<K>
fn st_update_return<Q>(&mut self, key: &Q, val: V) -> Option<V>
where
K: Borrow<Q>;
K: Borrow<Q>,
Q: ?Sized + AsKeyRef;
// delete
/// Returns true if the entry was deleted
fn st_delete<Q>(&mut self, key: &Q) -> bool
where
K: Borrow<Q>;
K: Borrow<Q>,
Q: ?Sized + AsKeyRef;
/// Removes the entry and returns it, if it exists
fn st_delete_return<Q>(&mut self, key: &Q) -> Option<K>
fn st_delete_return<Q>(&mut self, key: &Q) -> Option<V>
where
K: Borrow<Q>;
K: Borrow<Q>,
Q: ?Sized + AsKeyRef;
}
// iter
/// Returns an iterator over a tuple of keys and values
fn st_iter_kv<'a>(&'a self) -> Self::IterKV<'a>;
/// Returns an iterator over the keys
fn st_iter_k<'a>(&'a self) -> Self::IterKey<'a>;
/// Returns an iterator over the values
fn st_iter_v<'a>(&'a self) -> Self::IterValue<'a>;
pub trait STIndexSeq<K, V>: STIndex<K, V>
where
K: AsKey,
V: AsValue,
{
/// An ordered iterator over the keys and values
type IterOrdKV<'a>: Iterator<Item = (&'a K, &'a V)> + DoubleEndedIterator<Item = (&'a K, &'a V)>
where
Self: 'a,
K: 'a,
V: 'a;
/// An ordered iterator over the keys
type IterOrdKey<'a>: Iterator<Item = &'a K> + DoubleEndedIterator<Item = &'a K>
where
Self: 'a,
K: 'a;
/// An ordered iterator over the values
type IterOrdValue<'a>: Iterator<Item = &'a V> + DoubleEndedIterator<Item = &'a V>
where
Self: 'a,
V: 'a;
/// Returns an ordered iterator over the KV pairs
fn stseq_ord_kv<'a>(&'a self) -> Self::IterOrdKV<'a>;
/// Returns an ordered iterator over the keys
fn stseq_ord_key<'a>(&'a self) -> Self::IterOrdKey<'a>;
/// Returns an ordered iterator over the values
fn stseq_ord_value<'a>(&'a self) -> Self::IterOrdValue<'a>;
}

@ -24,7 +24,7 @@
*
*/
use super::def::{AsKey, AsKeyRef, AsValue};
use super::def::{AsKey, AsKeyRef, AsValue, IndexBaseSpec, STIndex, STIndexSeq};
use std::{
alloc::{alloc as std_alloc, dealloc as std_dealloc, Layout},
borrow::Borrow,
@ -462,12 +462,12 @@ impl<K: AsKey, V: AsValue, S: BuildHasher> IndexSTSeqDll<K, V, S> {
IndexSTSeqDllIterUnordKV::new(&self.m)
}
#[inline(always)]
fn _iter_unord_k<'a>(&'a self) -> IndexSTSeqDllIterUnordK<'a, K, V> {
IndexSTSeqDllIterUnordK::new(&self.m)
fn _iter_unord_k<'a>(&'a self) -> IndexSTSeqDllIterUnordKey<'a, K, V> {
IndexSTSeqDllIterUnordKey::new(&self.m)
}
#[inline(always)]
fn _iter_unord_v<'a>(&'a self) -> IndexSTSeqDllIterUnordV<'a, K, V> {
IndexSTSeqDllIterUnordV::new(&self.m)
fn _iter_unord_v<'a>(&'a self) -> IndexSTSeqDllIterUnordValue<'a, K, V> {
IndexSTSeqDllIterUnordValue::new(&self.m)
}
#[inline(always)]
fn _iter_ord_kv<'a>(&'a self) -> IndexSTSeqDllIterOrdKV<'a, K, V> {
@ -476,14 +476,14 @@ impl<K: AsKey, V: AsValue, S: BuildHasher> IndexSTSeqDll<K, V, S> {
}
}
#[inline(always)]
fn _iter_ord_k<'a>(&'a self) -> IndexSTSeqDllIterOrdK<'a, K, V> {
IndexSTSeqDllIterOrdK {
fn _iter_ord_k<'a>(&'a self) -> IndexSTSeqDllIterOrdKey<'a, K, V> {
IndexSTSeqDllIterOrdKey {
i: IndexSTSeqDllIterOrdBase::new(self),
}
}
#[inline(always)]
fn _iter_ord_v<'a>(&'a self) -> IndexSTSeqDllIterOrdV<'a, K, V> {
IndexSTSeqDllIterOrdV {
fn _iter_ord_v<'a>(&'a self) -> IndexSTSeqDllIterOrdValue<'a, K, V> {
IndexSTSeqDllIterOrdValue {
i: IndexSTSeqDllIterOrdBase::new(self),
}
}
@ -503,6 +503,162 @@ impl<K, V, S> Drop for IndexSTSeqDll<K, V, S> {
}
}
impl<K: AsKey, V: AsValue, S: BuildHasher + Default> FromIterator<(K, V)>
for IndexSTSeqDll<K, V, S>
{
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self {
let mut slf = Self::with_hasher(S::default());
iter.into_iter()
.for_each(|(k, v)| assert!(slf._insert(k, v)));
slf
}
}
impl<K, V, S: BuildHasher + Default> IndexBaseSpec<K, V> for IndexSTSeqDll<K, V, S>
where
K: AsKey,
V: AsValue,
{
const PREALLOC: bool = true;
type IterKV<'a> = IndexSTSeqDllIterUnordKV<'a, K, V>
where
Self: 'a,
K: 'a,
V: 'a;
type IterKey<'a> = IndexSTSeqDllIterUnordKey<'a, K, V>
where
Self: 'a,
K: 'a;
type IterValue<'a> = IndexSTSeqDllIterUnordValue<'a, K, V>
where
Self: 'a,
V: 'a;
fn idx_init() -> Self {
Self::with_hasher(S::default())
}
fn idx_init_with(s: Self) -> Self {
Self::from(s)
}
fn idx_iter_kv<'a>(&'a self) -> Self::IterKV<'a> {
self._iter_unord_kv()
}
fn idx_iter_key<'a>(&'a self) -> Self::IterKey<'a> {
self._iter_unord_k()
}
fn idx_iter_value<'a>(&'a self) -> Self::IterValue<'a> {
self._iter_unord_v()
}
}
impl<K, V, S: BuildHasher + Default> STIndex<K, V> for IndexSTSeqDll<K, V, S>
where
K: AsKey,
V: AsValue,
{
fn st_clear(&mut self) {
self._clear()
}
fn st_insert(&mut self, key: K, val: V) -> bool {
self._insert(key, val)
}
fn st_upsert(&mut self, key: K, val: V) {
let _ = self._upsert(key, val);
}
fn st_get<Q>(&self, key: &Q) -> Option<&V>
where
K: Borrow<Q>,
Q: ?Sized + AsKeyRef,
{
self._get(key)
}
fn st_get_cloned<Q>(&self, key: &Q) -> Option<V>
where
K: Borrow<Q>,
Q: ?Sized + AsKeyRef,
{
self._get(key).cloned()
}
fn st_update<Q>(&mut self, key: &Q, val: V) -> bool
where
K: Borrow<Q>,
Q: ?Sized + AsKeyRef,
{
self._update(key, val).is_none()
}
fn st_update_return<Q>(&mut self, key: &Q, val: V) -> Option<V>
where
K: Borrow<Q>,
Q: ?Sized + AsKeyRef,
{
self._update(key, val)
}
fn st_delete<Q>(&mut self, key: &Q) -> bool
where
K: Borrow<Q>,
Q: ?Sized + AsKeyRef,
{
self._remove(key).is_none()
}
fn st_delete_return<Q>(&mut self, key: &Q) -> Option<V>
where
K: Borrow<Q>,
Q: ?Sized + AsKeyRef,
{
self._remove(key)
}
}
impl<K, V, S> STIndexSeq<K, V> for IndexSTSeqDll<K, V, S>
where
K: AsKey,
V: AsValue,
S: BuildHasher + Default,
{
type IterOrdKV<'a> = IndexSTSeqDllIterOrdKV<'a, K, V>
where
Self: 'a,
K: 'a,
V: 'a;
type IterOrdKey<'a> = IndexSTSeqDllIterOrdKey<'a, K, V>
where
Self: 'a,
K: 'a;
type IterOrdValue<'a> = IndexSTSeqDllIterOrdValue<'a, K, V>
where
Self: 'a,
V: 'a;
fn stseq_ord_kv<'a>(&'a self) -> Self::IterOrdKV<'a> {
self._iter_ord_kv()
}
fn stseq_ord_key<'a>(&'a self) -> Self::IterOrdKey<'a> {
self._iter_ord_k()
}
fn stseq_ord_value<'a>(&'a self) -> Self::IterOrdValue<'a> {
self._iter_ord_v()
}
}
unsafe impl<K: Send, V: Send, S: Send> Send for IndexSTSeqDll<K, V, S> {}
unsafe impl<K: Sync, V: Sync, S: Sync> Sync for IndexSTSeqDll<K, V, S> {}
@ -564,27 +720,27 @@ impl<'a, K: 'a + Debug, V: 'a + Debug> Debug for IndexSTSeqDllIterUnordKV<'a, K,
}
}
pub struct IndexSTSeqDllIterUnordK<'a, K: 'a, V: 'a> {
pub struct IndexSTSeqDllIterUnordKey<'a, K: 'a, V: 'a> {
k: StdMapIterKey<'a, IndexSTSeqDllKeyptr<K>, IndexSTSeqDllNodePtr<K, V>>,
}
// UNSAFE(@ohsayan): aliasing guarantees correctness
unsafe_marker_impl!(unsafe impl for IndexSTSeqDllIterUnordK<'a, K, V>);
unsafe_marker_impl!(unsafe impl for IndexSTSeqDllIterUnordKey<'a, K, V>);
impl<'a, K: 'a, V: 'a> IndexSTSeqDllIterUnordK<'a, K, V> {
impl<'a, K: 'a, V: 'a> IndexSTSeqDllIterUnordKey<'a, K, V> {
#[inline(always)]
fn new<S>(m: &'a StdMap<IndexSTSeqDllKeyptr<K>, NonNull<IndexSTSeqDllNode<K, V>>, S>) -> Self {
Self { k: m.keys() }
}
}
impl<'a, K, V> Clone for IndexSTSeqDllIterUnordK<'a, K, V> {
impl<'a, K, V> Clone for IndexSTSeqDllIterUnordKey<'a, K, V> {
fn clone(&self) -> Self {
Self { k: self.k.clone() }
}
}
impl<'a, K, V> Iterator for IndexSTSeqDllIterUnordK<'a, K, V> {
impl<'a, K, V> Iterator for IndexSTSeqDllIterUnordKey<'a, K, V> {
type Item = &'a K;
fn next(&mut self) -> Option<Self::Item> {
self.k.next().map(|k| {
@ -599,41 +755,41 @@ impl<'a, K, V> Iterator for IndexSTSeqDllIterUnordK<'a, K, V> {
}
}
impl<'a, K, V> ExactSizeIterator for IndexSTSeqDllIterUnordK<'a, K, V> {
impl<'a, K, V> ExactSizeIterator for IndexSTSeqDllIterUnordKey<'a, K, V> {
fn len(&self) -> usize {
self.k.len()
}
}
impl<'a, K, V> FusedIterator for IndexSTSeqDllIterUnordK<'a, K, V> {}
impl<'a, K, V> FusedIterator for IndexSTSeqDllIterUnordKey<'a, K, V> {}
impl<'a, K: Debug, V> Debug for IndexSTSeqDllIterUnordK<'a, K, V> {
impl<'a, K: Debug, V> Debug for IndexSTSeqDllIterUnordKey<'a, K, V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_list().entries(self.clone()).finish()
}
}
pub struct IndexSTSeqDllIterUnordV<'a, K: 'a, V: 'a> {
pub struct IndexSTSeqDllIterUnordValue<'a, K: 'a, V: 'a> {
v: StdMapIterVal<'a, IndexSTSeqDllKeyptr<K>, IndexSTSeqDllNodePtr<K, V>>,
}
// UNSAFE(@ohsayan): aliasing guarantees correctness
unsafe_marker_impl!(unsafe impl for IndexSTSeqDllIterUnordV<'a, K, V>);
unsafe_marker_impl!(unsafe impl for IndexSTSeqDllIterUnordValue<'a, K, V>);
impl<'a, K: 'a, V: 'a> IndexSTSeqDllIterUnordV<'a, K, V> {
impl<'a, K: 'a, V: 'a> IndexSTSeqDllIterUnordValue<'a, K, V> {
#[inline(always)]
fn new<S>(m: &'a StdMap<IndexSTSeqDllKeyptr<K>, NonNull<IndexSTSeqDllNode<K, V>>, S>) -> Self {
Self { v: m.values() }
}
}
impl<'a, K, V> Clone for IndexSTSeqDllIterUnordV<'a, K, V> {
impl<'a, K, V> Clone for IndexSTSeqDllIterUnordValue<'a, K, V> {
fn clone(&self) -> Self {
Self { v: self.v.clone() }
}
}
impl<'a, K, V> Iterator for IndexSTSeqDllIterUnordV<'a, K, V> {
impl<'a, K, V> Iterator for IndexSTSeqDllIterUnordValue<'a, K, V> {
type Item = &'a V;
fn next(&mut self) -> Option<Self::Item> {
self.v.next().map(|n| {
@ -648,15 +804,15 @@ impl<'a, K, V> Iterator for IndexSTSeqDllIterUnordV<'a, K, V> {
}
}
impl<'a, K, V> ExactSizeIterator for IndexSTSeqDllIterUnordV<'a, K, V> {
impl<'a, K, V> ExactSizeIterator for IndexSTSeqDllIterUnordValue<'a, K, V> {
fn len(&self) -> usize {
self.v.len()
}
}
impl<'a, K, V> FusedIterator for IndexSTSeqDllIterUnordV<'a, K, V> {}
impl<'a, K, V> FusedIterator for IndexSTSeqDllIterUnordValue<'a, K, V> {}
impl<'a, K, V: Debug> Debug for IndexSTSeqDllIterUnordV<'a, K, V> {
impl<'a, K, V: Debug> Debug for IndexSTSeqDllIterUnordValue<'a, K, V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_list().entries(self.clone()).finish()
}
@ -667,11 +823,12 @@ trait IndexSTSeqDllIterOrdConfig<K, V> {
where
K: 'a,
V: 'a;
/// ## Safety
/// Ptr must be non-null
unsafe fn read_ret<'a>(ptr: *const IndexSTSeqDllNode<K, V>) -> Option<Self::Ret<'a>>
where
K: 'a,
V: 'a;
fn def_ret<'a>() -> Option<Self::Ret<'a>>;
}
struct IndexSTSeqDllIterOrdConfigFull;
@ -686,10 +843,6 @@ impl<K, V> IndexSTSeqDllIterOrdConfig<K, V> for IndexSTSeqDllIterOrdConfigFull {
{
Some((&(*ptr).k, &(*ptr).v))
}
#[inline(always)]
fn def_ret<'a>() -> Option<Self::Ret<'a>> {
None
}
}
struct IndexSTSeqDllIterOrdConfigKey;
@ -707,14 +860,6 @@ impl<K, V> IndexSTSeqDllIterOrdConfig<K, V> for IndexSTSeqDllIterOrdConfigKey {
{
Some(&(*ptr).k)
}
#[inline(always)]
fn def_ret<'a>() -> Option<&'a K>
where
K: 'a,
V: 'a,
{
None
}
}
struct IndexSTSeqDllIterOrdConfigValue;
@ -732,14 +877,6 @@ impl<K, V> IndexSTSeqDllIterOrdConfig<K, V> for IndexSTSeqDllIterOrdConfigValue
{
Some(&(*ptr).v)
}
#[inline(always)]
fn def_ret<'a>() -> Option<&'a V>
where
K: 'a,
V: 'a,
{
None
}
}
struct IndexSTSeqDllIterOrdBase<'a, K: 'a, V: 'a, C: IndexSTSeqDllIterOrdConfig<K, V>> {
@ -769,7 +906,7 @@ impl<'a, K: 'a, V: 'a, C: IndexSTSeqDllIterOrdConfig<K, V>> IndexSTSeqDllIterOrd
#[inline(always)]
fn _next(&mut self) -> Option<C::Ret<'a>> {
if self.h == self.t {
C::def_ret()
None
} else {
self.r -= 1;
unsafe {
@ -780,6 +917,20 @@ impl<'a, K: 'a, V: 'a, C: IndexSTSeqDllIterOrdConfig<K, V>> IndexSTSeqDllIterOrd
}
}
}
#[inline(always)]
fn _next_back(&mut self) -> Option<C::Ret<'a>> {
if self.h == self.t {
None
} else {
self.r -= 1;
unsafe {
// UNSAFE(@ohsayan): legal init, then ok
self.t = (*self.t).n;
// UNSAFE(@ohsayan): non-null (sentinel)
C::read_ret(self.t)
}
}
}
}
impl<'a, K: 'a, V: 'a, C: IndexSTSeqDllIterOrdConfig<K, V>> Debug
@ -804,6 +955,14 @@ impl<'a, K: 'a, V: 'a, C: IndexSTSeqDllIterOrdConfig<K, V>> Iterator
}
}
impl<'a, K: 'a, V: 'a, C: IndexSTSeqDllIterOrdConfig<K, V>> DoubleEndedIterator
for IndexSTSeqDllIterOrdBase<'a, K, V, C>
{
fn next_back(&mut self) -> Option<Self::Item> {
self._next_back()
}
}
impl<'a, K, V, C: IndexSTSeqDllIterOrdConfig<K, V>> ExactSizeIterator
for IndexSTSeqDllIterOrdBase<'a, K, V, C>
{
@ -838,6 +997,12 @@ impl<'a, K: 'a, V: 'a> Iterator for IndexSTSeqDllIterOrdKV<'a, K, V> {
}
}
impl<'a, K: 'a, V: 'a> DoubleEndedIterator for IndexSTSeqDllIterOrdKV<'a, K, V> {
fn next_back(&mut self) -> Option<Self::Item> {
self.i.next_back()
}
}
impl<'a, K, V> ExactSizeIterator for IndexSTSeqDllIterOrdKV<'a, K, V> {
fn len(&self) -> usize {
self.i.len()
@ -851,14 +1016,14 @@ impl<'a, K, V> Clone for IndexSTSeqDllIterOrdKV<'a, K, V> {
}
#[derive(Debug)]
pub struct IndexSTSeqDllIterOrdK<'a, K: 'a, V: 'a> {
pub struct IndexSTSeqDllIterOrdKey<'a, K: 'a, V: 'a> {
i: IndexSTSeqDllIterOrdBase<'a, K, V, IndexSTSeqDllIterOrdConfigKey>,
}
// UNSAFE(@ohsayan): aliasing guarantees correctness
unsafe_marker_impl!(unsafe impl for IndexSTSeqDllIterOrdK<'a, K, V>);
unsafe_marker_impl!(unsafe impl for IndexSTSeqDllIterOrdKey<'a, K, V>);
impl<'a, K: 'a, V: 'a> Iterator for IndexSTSeqDllIterOrdK<'a, K, V> {
impl<'a, K: 'a, V: 'a> Iterator for IndexSTSeqDllIterOrdKey<'a, K, V> {
type Item = &'a K;
fn next(&mut self) -> Option<Self::Item> {
self.i.next()
@ -868,27 +1033,33 @@ impl<'a, K: 'a, V: 'a> Iterator for IndexSTSeqDllIterOrdK<'a, K, V> {
}
}
impl<'a, K, V> ExactSizeIterator for IndexSTSeqDllIterOrdK<'a, K, V> {
impl<'a, K: 'a, V: 'a> DoubleEndedIterator for IndexSTSeqDllIterOrdKey<'a, K, V> {
fn next_back(&mut self) -> Option<Self::Item> {
self.i.next_back()
}
}
impl<'a, K, V> ExactSizeIterator for IndexSTSeqDllIterOrdKey<'a, K, V> {
fn len(&self) -> usize {
self.i.len()
}
}
impl<'a, K, V> Clone for IndexSTSeqDllIterOrdK<'a, K, V> {
impl<'a, K, V> Clone for IndexSTSeqDllIterOrdKey<'a, K, V> {
fn clone(&self) -> Self {
Self { i: self.i.clone() }
}
}
#[derive(Debug)]
pub struct IndexSTSeqDllIterOrdV<'a, K: 'a, V: 'a> {
pub struct IndexSTSeqDllIterOrdValue<'a, K: 'a, V: 'a> {
i: IndexSTSeqDllIterOrdBase<'a, K, V, IndexSTSeqDllIterOrdConfigValue>,
}
// UNSAFE(@ohsayan): aliasing guarantees correctness
unsafe_marker_impl!(unsafe impl for IndexSTSeqDllIterOrdV<'a, K, V>);
unsafe_marker_impl!(unsafe impl for IndexSTSeqDllIterOrdValue<'a, K, V>);
impl<'a, K: 'a, V: 'a> Iterator for IndexSTSeqDllIterOrdV<'a, K, V> {
impl<'a, K: 'a, V: 'a> Iterator for IndexSTSeqDllIterOrdValue<'a, K, V> {
type Item = &'a V;
fn next(&mut self) -> Option<Self::Item> {
self.i.next()
@ -898,13 +1069,19 @@ impl<'a, K: 'a, V: 'a> Iterator for IndexSTSeqDllIterOrdV<'a, K, V> {
}
}
impl<'a, K, V> ExactSizeIterator for IndexSTSeqDllIterOrdV<'a, K, V> {
impl<'a, K: 'a, V: 'a> DoubleEndedIterator for IndexSTSeqDllIterOrdValue<'a, K, V> {
fn next_back(&mut self) -> Option<Self::Item> {
self.i.next_back()
}
}
impl<'a, K, V> ExactSizeIterator for IndexSTSeqDllIterOrdValue<'a, K, V> {
fn len(&self) -> usize {
self.i.len()
}
}
impl<'a, K, V> Clone for IndexSTSeqDllIterOrdV<'a, K, V> {
impl<'a, K, V> Clone for IndexSTSeqDllIterOrdValue<'a, K, V> {
fn clone(&self) -> Self {
Self { i: self.i.clone() }
}

Loading…
Cancel
Save