luaur_common/records/
const_iterator.rs1use crate::records::dense_hash_table::{DenseEq, DenseHashTable, DenseHasher, ItemInterface};
7
8pub struct ConstIterator<'a, K, I, Iface, H, E> {
9 pub(crate) table: &'a DenseHashTable<K, I, Iface, H, E>,
10 pub(crate) index: usize,
11}
12
13impl<'a, K, I, Iface, H, E> Iterator for ConstIterator<'a, K, I, Iface, H, E>
14where
15 K: Clone,
16 Iface: ItemInterface<K, I>,
17 H: DenseHasher<K> + Default,
18 E: DenseEq<K> + Default,
19{
20 type Item = &'a I;
21
22 fn next(&mut self) -> Option<&'a I> {
23 if self.index >= self.table.capacity {
24 return None;
25 }
26 let item = &self.table.data[self.index];
27 self.index = self.table.next_occupied(self.index);
28 Some(item)
29 }
30}