Exemplo n.º 1
0
        public void MapTree()
        {
            var mapper = new BTreeNodeMapper(Head);
            _nodeList = mapper.BeginMap();

            var rowCount = _nodeList.OrderByDescending(n => n.Map.MapCol).FirstOrDefault().Map.MapCol;
            var center = Convert.ToInt32(Math.Pow(2, (rowCount - 1)));

            var numList = new List<int>();

            for (int row = 1; row <= rowCount; row++)
            {
                var nodesInRow = _nodeList.Where(n => n.Map.MapRow == row).ToList();
            
                foreach (var node in nodesInRow)
                {
                    var col = node.Map.MapCol;

                    var position = Convert.ToInt32(((center / Math.Pow(2, (row-1))) + ((center / (Math.Pow(2, row-2))) * (col-1))));
                    numList.Add(position);
                }

            }

            numList.OrderBy(n => n);

          
            numList.ForEach(n => Console.WriteLine(n));
        }
Exemplo n.º 2
0
        public void MapTree()
        {
            var mapper = new BTreeNodeMapper(Head);

            _nodeList = mapper.BeginMap();

            var rowCount = _nodeList.OrderByDescending(n => n.Map.MapCol).FirstOrDefault().Map.MapCol;
            var center   = Convert.ToInt32(Math.Pow(2, (rowCount - 1)));

            var numList = new List <int>();

            for (int row = 1; row <= rowCount; row++)
            {
                var nodesInRow = _nodeList.Where(n => n.Map.MapRow == row).ToList();

                foreach (var node in nodesInRow)
                {
                    var col = node.Map.MapCol;

                    var position = Convert.ToInt32(((center / Math.Pow(2, (row - 1))) + ((center / (Math.Pow(2, row - 2))) * (col - 1))));
                    numList.Add(position);
                }
            }

            numList.OrderBy(n => n);


            numList.ForEach(n => Console.WriteLine(n));
        }