Beispiel #1
0
        public void WeightAfterFill()
        {
            var map = InitTestMap();

            tree.Fill(map);

            long weight = 0;

            map.ToList().ForEach(pair => weight += pair.Value);

            Assert.True(weight == tree.Root.Weight);
        }
Beispiel #2
0
        public static Archive Deserialize(this Stream encoded)
        {
            var tree = new Tree();
            var map  = new Dictionary <char, long>();

            using (var reader = new BinaryReader(encoded))
            {
                var sequencesCount = reader.ReadByte();

                for (byte i = 0; i < sequencesCount; i++)
                {
                    map.Add(reader.ReadChar(), reader.ReadByte());
                }
            }

            tree.Fill(map);

            return(new Archive(encoded, tree.ToPriceMap()));
        }