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

Push() public method

Push the node in the heap if it's not already there, otherwise promote.
public Push ( int node, float cost ) : bool
node int
cost float
return bool
        public bool Push(int node, float cost)
        {
            int i = heapback[node];
            if (i != -1)
            {
                if (cost < costs[i])
                {
                    costs[i] = cost;
                    heapify_up(i);
                    return true;
                }
                return false;
            }
            else
            {
                heap.Push(node);
                costs.Push(cost);
                heapback[node] = heap.Length() - 1;
                heapify_up(heap.Length() - 1);
                return true;
            }
        }

Usage Example

コード例 #1
0
ファイル: AStarSearch.cs プロジェクト: nickun/OCRonet
        int n; // the number of nodes; also the virtual accept index

        #endregion Fields

        #region Constructors

        public AStarSearch(IGenericFst fst)
        {
            this.fst = fst;
            this.accepted_from = -1;
            this.heap = new Heap(fst.nStates() + 1);
            this.n = fst.nStates();
            this.came_from = new Intarray(n);
            this.came_from.Fill(-1);
            this.g = new Floatarray(n);
            // insert the start node
            int s = fst.GetStart();
            g[s] = 0;
            came_from[s] = s;
            heap.Push(s, Convert.ToSingle(Heuristic(s)));
        }