1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use crate::{noderef::NodeRefId, IndexedTree, Tree, TreeNode, TreeNodeRef, UniqueGenerator};
/// Tree Comparison
impl<R, G> PartialEq for Tree<R, G>
where
R: TreeNodeRef + 'static,
G: UniqueGenerator<Output = NodeRefId<R>> + 'static,
{
fn eq(&self, other: &Self) -> bool {
self.node().get_subtree_hash() == other.node().get_subtree_hash()
/*
let mut hasher_self = Xxh64::new(0);
let mut hasher_other = Xxh64::new(0);
for node in self.root().into_iter() {
node.node().hash_children(&mut hasher_self);
node.node().hash(&mut hasher_self);
}
for node in other.root().into_iter() {
node.node().hash_children(&mut hasher_other);
node.node().hash(&mut hasher_other);
}
let self_hash = hasher_self.finish();
let other_hash = hasher_other.finish();
self_hash == other_hash
*/
}
}
impl<R, G> PartialEq for IndexedTree<R, G>
where
R: TreeNodeRef + std::fmt::Debug,
G: UniqueGenerator<Output = NodeRefId<R>> + 'static,
{
fn eq(&self, other: &Self) -> bool {
self.tree() == other.tree()
}
}
impl<R, G> Eq for IndexedTree<R, G>
where
R: TreeNodeRef + std::hash::Hash + PartialEq + 'static,
G: UniqueGenerator<Output = NodeRefId<R>> + 'static,
{
}