Example #1
0
        private List<LeafDataType> TraverseTree(ListTreeNode Root, ref long FoundLeafDataCount, ref long FoundNodesCount, LeafDataFetchEventHandler leafDataFetch, long depth)
        {
            List<LeafDataType> foundElements = new List<LeafDataType>();

            // int depth = _depth + 1;

            for (int i = 0; i < 16; i++)
            {
                if (Root.Children[i] != null)
                {
                    /////////////////////////////////////

                    FoundNodesCount++;

                    if (Root.Hash != null)
                    {
                        //DisplayUtils.Display("ID : " + HexUtil.ToString(Root.Hash.Hex) + " : " + depth);
                    }
                    else
                    {
                        //DisplayUtils.Display("ID: NULL --------------- =============== ------------- :");
                    }

                    ////////////////////////////////

                    if (!Root.Children[i].IsLeaf)
                    {
                        //DisplayUtils.Display("Intermediate Traversed : " + Root.Children[i].Hash.ToString() + " : " + depth);

                        TraverseTree(Root.Children[i], ref FoundLeafDataCount, ref FoundNodesCount, leafDataFetch, depth + 1);
                    }
                    else
                    {
                        ListTreeLeafNode Leaf = (ListTreeLeafNode)Root.Children[i];

                        LeafDataType[] ldts = Leaf.GetAllItems();

                        if (leafDataFetch != null)
                            leafDataFetch(ldts);

                        foundElements.AddRange(ldts);

                        // TotalMoney += ((AccountInfo)Leaf.).Money;
                        //DisplayUtils.Display("\nLeaf Node Traversed: " + HexUtil.ToString(Leaf.GetHash().Hex) + " - " +
                        //AccountInfo.CalculateTotalMoney(ldts));

                        /*foreach (LeafDataType ld in ldts)
                        {
                            //DisplayUtils.Display("          --- ID: " + HexUtil.ToString(ld.GetID().Hex) + " - Money " + ((AccountInfo)ld).Money);
                            TotalMoney += ((AccountInfo)ld).Money;
                        }*/

                        FoundLeafDataCount += ldts.Length;
                    }
                }
            }

            return foundElements;
        }
Example #2
0
 public void TraverseAllNodes(ref long FoundLeafDataCount, ref long FoundNodesCount, LeafDataFetchEventHandler leafDataFetch)
 {
     //int nodes = 0;
     //int elements = 0;
     int depth = 0;
     //_TraversedNodes = 0;
     //TotalMoney = 0;
     TraverseTree(Root, ref FoundLeafDataCount, ref FoundNodesCount, leafDataFetch, depth);
     //_TraversedNodes = nodes;
     //_TraversedElements = elements;
     //TraverseLevelOrder(Root, ref nodes);
     //return nodes;
 }