1use crate::sum_tree::{self, SumTree};
2use parking_lot::Mutex;
3use std::sync::Arc;
4
5use crate::ElementBox;
6
7pub struct List {
8 state: ListState,
9}
10
11pub struct ListState(Arc<Mutex<StateInner>>);
12
13struct StateInner {
14 elements: Vec<ElementBox>,
15 element_heights: SumTree<ElementHeight>,
16}
17
18#[derive(Clone, Debug)]
19enum ElementHeight {
20 Pending,
21 Ready(f32),
22}
23
24#[derive(Clone, Debug, Default)]
25struct ElementHeightSummary {
26 pending_count: usize,
27 height: f32,
28}
29
30impl sum_tree::Item for ElementHeight {
31 type Summary = ElementHeightSummary;
32
33 fn summary(&self) -> Self::Summary {
34 todo!()
35 }
36}
37
38impl sum_tree::Summary for ElementHeightSummary {
39 type Context = ();
40
41 fn add_summary(&mut self, summary: &Self, cx: &Self::Context) {
42 self.pending_count += summary.pending_count;
43 self.height += summary.height;
44 }
45}