use crate::containers::FastVec;
use crate::succinct::RankSelectOps;
use crate::StateId;
use crate::containers::specialized::UintVector;
use std::collections::{HashMap, VecDeque};
#[derive(Debug)]
pub(super) enum TrieStorage<R>
where
R: RankSelectOps,
{
Patricia {
nodes: FastVec<PatriciaNode>,
edge_data: FastVec<u8>,
compressed_paths: HashMap<StateId, Vec<u8>>,
},
CriticalBit {
nodes: FastVec<CritBitNode>,
keys: FastVec<Vec<u8>>,
critical_cache: HashMap<usize, u8>,
},
DoubleArray {
base: FastVec<u32>,
check: FastVec<u32>,
free_list: VecDeque<StateId>,
state_count: usize,
},
Louds {
louds: R,
is_link: R,
next_link: UintVector,
label_data: FastVec<u8>,
core_data: FastVec<u8>,
next_trie: Option<Box<super::trie::ZiporaTrie<R>>>,
},
CompressedSparse(crate::fsa::cspp_trie::CsppTrie),
}
#[derive(Debug, Clone, Default)]
pub(super) struct PatriciaNode {
pub(super) children: Vec<(u8, StateId)>,
pub(super) _path_offset: u32,
pub(super) _path_length: u16,
pub(super) is_final: bool,
pub(super) _flags: u8,
}
#[repr(align(64))]
#[derive(Debug, Clone)]
pub(super) struct CritBitNode {
pub(super) _crit_byte: usize,
pub(super) _crit_bit: u8,
pub(super) _left_child: Option<StateId>,
pub(super) _right_child: Option<StateId>,
pub(super) _key_index: Option<u32>,
pub(super) is_final: bool,
}
#[derive(Debug, Clone)]
pub(super) struct SparseNode {
pub(super) children: HashMap<u8, StateId>,
pub(super) _edge_label: Option<u32>,
pub(super) is_final: bool,
}