1 use crate::{page, shard}; 2 use std::slice; 3 4 #[derive(Debug)] 5 pub struct UniqueIter<'a, T, C: crate::cfg::Config> { 6 pub(super) shards: shard::IterMut<'a, Option<T>, C>, 7 pub(super) pages: slice::Iter<'a, page::Shared<Option<T>, C>>, 8 pub(super) slots: Option<page::Iter<'a, T, C>>, 9 } 10 11 impl<'a, T, C: crate::cfg::Config> Iterator for UniqueIter<'a, T, C> { 12 type Item = &'a T; next(&mut self) -> Option<Self::Item>13 fn next(&mut self) -> Option<Self::Item> { 14 test_println!("UniqueIter::next"); 15 loop { 16 test_println!("-> try next slot"); 17 if let Some(item) = self.slots.as_mut().and_then(|slots| slots.next()) { 18 test_println!("-> found an item!"); 19 return Some(item); 20 } 21 22 test_println!("-> try next page"); 23 if let Some(page) = self.pages.next() { 24 test_println!("-> found another page"); 25 self.slots = page.iter(); 26 continue; 27 } 28 29 test_println!("-> try next shard"); 30 if let Some(shard) = self.shards.next() { 31 test_println!("-> found another shard"); 32 self.pages = shard.iter(); 33 } else { 34 test_println!("-> all done!"); 35 return None; 36 } 37 } 38 } 39 } 40