Esempio n. 1
0
        /*
         * Creates a byte array that represents the structure of a tree.
         * */
        public static byte[] GetTreeStructureAsBytes(Node n)
        {
            byte[] code;
            SimplePriorityQueue <int, Node> queue = new SimplePriorityQueue <int, Node>();

            queue = PatrixiaTrieFileMapper.FillTreePriorityQueue(n, queue, 0);
            code  = PatrixiaTrieFileMapper.GetStructureBytesFromPriorityQueue(queue);
            return(code);
        }
Esempio n. 2
0
        /*
         * Fills a priority queue with all nodes. Priority per node equals its level in the tree. This actually shouldn't be
         * done this way... Recursion is no good.
         * */
        private static SimplePriorityQueue <int, Node> FillTreePriorityQueue(Node n, SimplePriorityQueue <int, Node> queue, int level)
        {
            queue.Enqueue(level, n);
            foreach (Node child in n.getChildren())
            {
                PatrixiaTrieFileMapper.FillTreePriorityQueue(child, queue, level + 1);
            }

            return(queue);
        }