Exemplo n.º 1
0
 public void setStartAndGoal(int x0, int y0, int xn, int yn)
 {
     _nodeStart = new heapNode(x0, y0);
     _nodeGoal  = new heapNode(xn, yn);
     _heap      = new HeapSort(ref _openList);
     // add a new element, and re-build the heap
     _heap.push_heap(_nodeStart);
 }
Exemplo n.º 2
0
        //a simple test for debug
        public static void debug()
        {
            heapNode a = new heapNode();

            a._f = 9;
            heapNode b = new heapNode();

            b._f = 50;
            heapNode c = new heapNode();

            c._f = 21;
            heapNode d = new heapNode();

            d._f = 98;
            heapNode e = new heapNode();

            e._f = 55;
            List <heapNode> tmpList = new List <heapNode>();

            tmpList.Add(a);
            HeapSort hs = new HeapSort(ref tmpList);

            hs.push_heap(b);
            hs.push_heap(c);
            hs.push_heap(d);
            hs.push_heap(e);

            hs.pruneToSize(2);

            heapNode x = hs.pop_heap();

            Console.WriteLine(x._f);
            x = hs.pop_heap();
            Console.WriteLine(x._f);
            x = hs.pop_heap();
            Console.WriteLine(x._f);
            x = hs.pop_heap();
            Console.WriteLine(x._f);
            x = hs.pop_heap();
            Console.WriteLine(x._f);
        }