LROAI3NBBSCU4T2YA6EHJYKKKL75AU5A7C7WIRCGIQ56S6HPLRXQC
KM3JAFGPFV7MP7M2LJIYRVAUTU646B3IRXADTRZKOU2RF7LUB62QC
H3FVSQIQGFCFKCPXVOSFHP4OSUOBBURJESCZNGQTNDAAD3WQSBEQC
6UVFCERMGSGNRWCVC3GWO5HWV6MSWE433DXBJVC7KRPP6LLJLCSQC
OFINGD26ZWCRDVVDI2ZIBLMHXKEMJA6MRNLANJYUHQPIJLPA7J2AC
KX3WVNZW5KHVEH6EOQTZ4RBEFFJ3SGF5I467X3JWZ74PURRK4HVAC
QEUTVAZ4F4EJXRDMWDMYXF6XEDMX7YPVG4IIXEKPIR3K54E5W5OAC
OP6SVMOD2GTQ7VNJ4E5KYFG4MIYA7HBMXJTADALMZH4PY7OQRMZQC
WS4ZQM4RMIHZ6XZKSDQJGHN5SSSWFL4H236USOPUA33S6RC53RFAC
OTWDDJE7TTE73D6BGF4ZN6BH2NFUFLPME2VJ3CPALH463UGWLEIQC
W26CFMAQOXMUK4ZOJMAN4SMBXMWFQHO7HCTEVW73FQSRMJZFGJIQC
UUUVNC4DWEEL7WV5IRPKPZ6HZMYCPA53XM7LJWICUD4E6GN37IRQC
PXF3R6SVXJXN2NMLMWNY5OFV5QYVE2VZTLGIZDZVK5ZVLFTVSSWQC
UAQX27N4PI4LHEW6LSHJETIE5MV7JTEMPLTJFYUBMYVPC43H7VOAC
EYNN7RLSFVBWDLRTLNNFUAF46Q6OX3BR5SUEJIOOHBSNP7FVBXGAC
}
impl<K: Representable + ?Sized, V: Representable + ?Sized, P: BTreePage<K, V>>
core::ops::Index<usize> for Cursor<K, V, P>
{
type Output = PageCursor<K, V, P>;
fn index(&self, i: usize) -> &PageCursor<K, V, P> {
assert!(i <= self.pointer);
unsafe { &*self.stack.index(i).as_ptr() }
}
}
impl<K: Representable + ?Sized, V: Representable + ?Sized, P: BTreePage<K, V>>
core::ops::IndexMut<usize> for Cursor<K, V, P>
{
fn index_mut(&mut self, i: usize) -> &mut PageCursor<K, V, P> {
assert!(i <= self.pointer);
unsafe { &mut *self.stack.index_mut(i).as_mut_ptr() }
}
P::move_prev(current.page.as_page(), &mut current.cursor);
let right = P::right_child(current.page.as_page(), ¤t.cursor);
if right != 0 {
let page = txn.load_page(right)?;
let left = P::left_child(current.page.as_page(), ¤t.cursor);
if left != 0 {
let page = txn.load_page(left)?;
pub fn iter<'a, T, K, V, P>(
txn: &'a T,
db: &super::Db_<K, V, P>,
origin: Option<(&K, Option<&V>)>
) -> Result<Iter<'a, T, K, V, P>, T::Error>
where T: LoadPage, K: Representable + ?Sized, V: Representable + ?Sized, P: BTreePage<K, V> {
let mut cursor = Cursor::new(txn, db)?;
cursor.set(txn, origin)?;
Ok(Iter {
cursor,
txn,
})
impl<'a, T: LoadPage, K: Representable + ?Sized + 'a, V: Representable + ?Sized + 'a, P: BTreePage<K, V> + 'a> Iterator for Iter<'a, T, K, V, P> {
type Item = Result<(&'a K, &'a V), T::Error>;
fn next(&mut self) -> Option<Self::Item> {
self.cursor.next(self.txn).transpose()
}
}
pub struct RevIter<'a, T: LoadPage, K: Representable + ?Sized, V: Representable + ?Sized, P: BTreePage<K, V>> {
txn: &'a T,
cursor: Cursor<K, V, P>,
}
pub fn rev_iter<'a, T, K, V, P>(
txn: &'a T,
db: &super::Db_<K, V, P>,
origin: Option<(&K, Option<&V>)>
) -> Result<RevIter<'a, T, K, V, P>, T::Error>
where T: LoadPage, K: Representable + ?Sized, V: Representable + ?Sized, P: BTreePage<K, V> {
let mut cursor = Cursor::new(txn, db)?;
cursor.set(txn, origin)?;
Ok(RevIter {
cursor,
txn,
})
}
impl<'a, T: LoadPage, K: Representable + ?Sized + 'a, V: Representable + ?Sized + 'a, P: BTreePage<K, V> + 'a> Iterator for RevIter<'a, T, K, V, P> {
type Item = Result<(&'a K, &'a V), T::Error>;
fn next(&mut self) -> Option<Self::Item> {
self.cursor.prev(self.txn).transpose()
}
}
debug!("{:?}", i);
}
for i in (0..75).rev() {
let (k, v) = cursor.prev(&txn).unwrap().unwrap();
debug!("d {:?} {:?}", i, k);
assert_eq!(*k, i);
assert_eq!(v.0[0], i);
}
crate::debug::debug(&txn, &[&db], "debug", true);
let i0 = 30;
for (kv, n) in btree::rev_iter(&txn, &db, Some((&i0, None)))
.unwrap()
.zip((0..=i0).rev())
{
let (k, v) = kv.unwrap();
assert_eq!(*k, n);
debug!("k = {:?}", k);
}
let i0 = 40;
for (kv, n) in btree::iter(&txn, &db, Some((&i0, None))).unwrap().zip(i0..) {
let (k, v) = kv.unwrap();
assert_eq!(*k, n);
debug!("k = {:?}", k);