Beispiel #1
0
        static int MapNode(BiDictionary <HmmOnlineNode, int> map, HmmOnlineNode node)
        {
            if (node == null)
            {
                return(-1);
            }
            int value;

            if (!map.TryGetValue(node, out value))
            {
                value = map.Count;
                map.Add(node, value);
                return(value);
            }
            return(value);
        }
Beispiel #2
0
        public static HmmOnlineNode Read(BiDictionary <HmmOnlineNode, int> map, BinaryReader input)
        {
            bool first = input.ReadBoolean();
            int  index = input.ReadInt32();

            if (first)
            {
                HmmOnlineNode node = new HmmOnlineNode();
                node.Position    = input.ReadInt32();
                node.State       = input.ReadInt32();
                node.ChildNumber = input.ReadInt32();
                map.Add(node, index);
                node.Parent = Read(map, input);
                return(node);
            }
            if (index == -1)
            {
                return(null);
            }

            return(map.Reverse[index]);
        }