Beispiel #1
0
        public void Merge(LeftHeap <T> other)
        {
            if (this == other)
            {
                return;
            }
            Node otherRoot = null;

            if (other != null)
            {
                otherRoot = other.root;
            }
            root = MergeHeap(root, otherRoot);
        }
Beispiel #2
0
        static void LeftHeapTest()
        {
            int[]          values  = { 3, 10, 8, 21, 14, 23, 17, 26 };
            int[]          values2 = { 37, 33, 24, 18, 18, 12, 7, 6 };
            LeftHeap <int> heap1   = new LeftHeap <int>();
            LeftHeap <int> heap2   = new LeftHeap <int>();

            foreach (var v in values)
            {
                heap1.Add(v);
            }
            foreach (var v in values2)
            {
                heap2.Add(v);
            }
            heap1.Merge(heap2);
        }