Exemplo n.º 1
0
        public BinaryIndexedTree <K, V> BuildIndex()
        {
            var count = 0u;

            iterate(Root, node =>
            {
                node.Offset = count++;
            });
            var nodes = new BinaryIndexedTree <K, V> .Node[count];

            iterate(Root, node =>
            {
                nodes[node.Offset].Index = node.Index;
                var left = node.Left;
                nodes[node.Offset].Left = left != null ? left.Offset : 0;
                var right = node.Right;
                nodes[node.Offset].Right = right != null ? right.Offset : 0;
            });
            return(new BinaryIndexedTree <K, V>(nodes, Values.ToArray()));
        }
Exemplo n.º 2
0
 public SubnetTree(BinaryIndexedTree <Subnet, V> tree)
     : base(tree.Nodes, tree.Values)
 {
     OffsetIPv4 = 0;
     FindOffset(new Subnet(IPAddress.Any, 0, mapToIPv6: true), ref OffsetIPv4);
 }