aboutsummaryrefslogtreecommitdiff
path: root/crates/profile/src/tree.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/profile/src/tree.rs')
-rw-r--r--crates/profile/src/tree.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/profile/src/tree.rs b/crates/profile/src/tree.rs
index 096f58511..3fac1f36c 100644
--- a/crates/profile/src/tree.rs
+++ b/crates/profile/src/tree.rs
@@ -4,15 +4,15 @@ use std::ops;
4use arena::Arena; 4use arena::Arena;
5 5
6#[derive(Default)] 6#[derive(Default)]
7pub struct Tree<T> { 7pub(crate) struct Tree<T> {
8 nodes: Arena<Node<T>>, 8 nodes: Arena<Node<T>>,
9 current_path: Vec<(Idx<T>, Option<Idx<T>>)>, 9 current_path: Vec<(Idx<T>, Option<Idx<T>>)>,
10} 10}
11 11
12pub type Idx<T> = arena::Idx<Node<T>>; 12pub(crate) type Idx<T> = arena::Idx<Node<T>>;
13 13
14impl<T> Tree<T> { 14impl<T> Tree<T> {
15 pub fn start(&mut self) 15 pub(crate) fn start(&mut self)
16 where 16 where
17 T: Default, 17 T: Default,
18 { 18 {
@@ -30,19 +30,19 @@ impl<T> Tree<T> {
30 self.current_path.push((me, None)); 30 self.current_path.push((me, None));
31 } 31 }
32 32
33 pub fn finish(&mut self, data: T) { 33 pub(crate) fn finish(&mut self, data: T) {
34 let (me, _last_child) = self.current_path.pop().unwrap(); 34 let (me, _last_child) = self.current_path.pop().unwrap();
35 self.nodes[me].data = data; 35 self.nodes[me].data = data;
36 } 36 }
37 37
38 pub fn root(&self) -> Option<Idx<T>> { 38 pub(crate) fn root(&self) -> Option<Idx<T>> {
39 self.nodes.iter().next().map(|(idx, _)| idx) 39 self.nodes.iter().next().map(|(idx, _)| idx)
40 } 40 }
41 41
42 pub fn children(&self, idx: Idx<T>) -> impl Iterator<Item = Idx<T>> + '_ { 42 pub(crate) fn children(&self, idx: Idx<T>) -> impl Iterator<Item = Idx<T>> + '_ {
43 NodeIter { nodes: &self.nodes, next: self.nodes[idx].first_child } 43 NodeIter { nodes: &self.nodes, next: self.nodes[idx].first_child }
44 } 44 }
45 pub fn clear(&mut self) { 45 pub(crate) fn clear(&mut self) {
46 self.nodes.clear(); 46 self.nodes.clear();
47 self.current_path.clear(); 47 self.current_path.clear();
48 } 48 }
@@ -55,7 +55,7 @@ impl<T> ops::Index<Idx<T>> for Tree<T> {
55 } 55 }
56} 56}
57 57
58pub struct Node<T> { 58pub(crate) struct Node<T> {
59 data: T, 59 data: T,
60 first_child: Option<Idx<T>>, 60 first_child: Option<Idx<T>>,
61 next_sibling: Option<Idx<T>>, 61 next_sibling: Option<Idx<T>>,