public int next() { while (!BaseUtils.is_heap_empty(heap_queue)) { var top = BaseUtils.heap_delete_min(heap_queue); var rnode = top.node; if (rnode.x == 0) { for (var n = top; n != null; n = n.next) { result_[n.node.x] = n.node.y; } cost_ = top.gx; return(0); } for (int index = 0; index < rnode.lpathList.Count; index++) { var p = rnode.lpathList[index]; var n = BaseUtils.allc_from_heap(heap_queue); var x_num = (rnode.x) - 1; n.node = p.lnode; n.gx = -p.lnode.cost - p.cost + top.gx; n.fx = -p.lnode.bestCost - p.cost + top.gx; // | h(x) | | g(x) | n.next = top; if (BaseUtils.heap_insert(n, heap_queue) < 0) { return(BaseUtils.RETURN_INSERT_HEAP_FAILED); } } } return(0); }
public int initNbest() { var k = (int)word_num - 1; for (var i = 0; i < ysize_; ++i) { var eos = BaseUtils.allc_from_heap(heap_queue); eos.node = node_[k, i]; eos.fx = -node_[k, i].bestCost; eos.gx = -node_[k, i].cost; eos.next = null; if (BaseUtils.heap_insert(eos, heap_queue) < 0) { return(BaseUtils.RETURN_INSERT_HEAP_FAILED); } } return(BaseUtils.RETURN_SUCCESS); }