Exemple #1
0
        public PersistNode <TK, TV, TI> ToPersistable(ITrieNode <TK, TV, TI> node)
        {
            var persistable = new PersistNode <TK, TV, TI>
            {
                Children = node.Children().Select(p =>
                {
                    var c = ToPersistable(p.Value);
                    c.Key = p.Key;
                    return(c);
                }).ToList(),
                Values = node.Pairs().ToList()
            };

            return(persistable);
        }
Exemple #2
0
        public ITrieNode <TK, TV, TI> ToTrieNode(PersistNode <TK, TV, TI> node)
        {
            var trie = Settings.TrieBuilder();

            foreach (var v in node.Values)
            {
                trie.AppendValue(v.Key, v.Value);
            }

            foreach (var c in node.Children)
            {
                var child = ToTrieNode(c);
                trie.AppendChild(c.Key, child);
            }

            return(trie);
        }
Exemple #3
0
        public void Save(Stream stream, PersistNode <TK, TV, TI> node, TrieSettings <TK, TV, TI> settings)
        {
            var bf = new BinaryFormatter();

            bf.Serialize(stream, node);
        }