Ocronet.Dynamic.OcroFST.Heap.Pop C# (CSharp) Method

Pop() public method

public Pop ( ) : int
return int
        public int Pop()
        {
            heapswap(0, heap.Length() - 1);
            int result = heap.Pop();
            costs.Pop();
            heapify_down(0);
            heapback[result] = -1;
            return result;
        }

Usage Example

コード例 #1
0
ファイル: AStarSearch.cs プロジェクト: liaoheping/OCRonet
        public bool Step()
        {
            int node = heap.Pop();

            if (node == n)
            {
                return(true);  // accept has popped up
            }
            // get outbound arcs
            Intarray   inputs  = new Intarray();
            Intarray   targets = new Intarray();
            Intarray   outputs = new Intarray();
            Floatarray costs   = new Floatarray();

            fst.Arcs(inputs, targets, outputs, costs, node);
            for (int i = 0; i < targets.Length(); i++)
            {
                int t = targets[i];
                if (came_from[t] == -1 || g[node] + costs[i] < g[t])
                {
                    // relax the edge
                    came_from[t] = node;
                    g[t]         = g[node] + costs[i];
                    heap.Push(t, g[t] + Convert.ToSingle(Heuristic(t)));
                }
            }
            if (accepted_from == -1 ||
                g[node] + fst.GetAcceptCost(node) < g_accept)
            {
                // relax the accept edge
                accepted_from = node;
                g_accept      = g[node] + fst.GetAcceptCost(node);
                heap.Push(n, g_accept);
            }
            return(false);
        }