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
use crate::{id, IdentifyAll, IndexedNode, StrippedIndexedNode};
use std::collections::HashSet;

/// Result of the document flattening algorithm.
///
/// It is just an alias for a set of (indexed) nodes.
pub type FlattenedDocument<T, B, M> = Vec<IndexedNode<T, B, M>>;

impl<T, B, M> IdentifyAll<T, B, M> for FlattenedDocument<T, B, M> {
	#[inline(always)]
	fn identify_all_with<N, G: id::Generator<T, B, N, M>>(
		&mut self,
		vocabulary: &mut N,
		mut generator: G,
	) where
		M: Clone,
	{
		for node in self {
			node.identify_all_with(vocabulary, &mut generator)
		}
	}

	#[inline(always)]
	fn identify_all<G: id::Generator<T, B, (), M>>(&mut self, generator: G)
	where
		M: Clone,
	{
		self.identify_all_with(&mut (), generator)
	}
}

pub type UnorderedFlattenedDocument<T, B, M> = HashSet<StrippedIndexedNode<T, B, M>>;