src/lstm/recodebeam.cpp
void RecodeBeamSearch::PushHeapIfBetter(int max_size, RecodeNode *node,
                                        RecodeHeap *heap) {
  if (heap->size() < max_size || node->score > heap->PeekTop().data().score) {
    if (UpdateHeapIfMatched(node, heap)) {
      return;
    }
    RecodePair entry(node->score, *node);
    heap->Push(&entry);
    ASSERT_HOST(entry.data().dawgs == nullptr);
    if (heap->size() > max_size) {
      heap->Pop(&entry);
    }
  }
}
// Adds a RecodeNode to heap if there is room
// or if better than the current worst element if already full.
Adds a RecodeNode to heap if there is room
or if better than the current worst element if already full.
Adds a RecodeNode to heap if there is room or if better than the current worst element if already full .
void RecodeBeamSearch::PushHeapIfBetter(int max_size, RecodeNode *node,
                                        RecodeHeap *heap) {
  if (heap->size() < max_size || node->score > heap->PeekTop().data().score) {
    if (UpdateHeapIfMatched(node, heap)) {
      return;
    }
    RecodePair entry(node->score, *node);
    heap->Push(&entry);
    ASSERT_HOST(entry.data().dawgs == nullptr);
    if (heap->size() > max_size) {
      heap->Pop(&entry);
    }
  }
}
void RecodeBeamSearch :: PushHeapIfBetter ( int max_size , RecodeNode * node , RecodeHeap * heap ) { if ( heap -> size ( ) < max_size || node -> score > heap -> PeekTop ( ) . data ( ) . score ) { if ( UpdateHeapIfMatched ( node , heap ) ) { return ; } RecodePair entry ( node -> score , * node ) ; heap -> Push ( & entry ) ; ASSERT_HOST ( entry . data ( ) . dawgs == nullptr ) ; if ( heap -> size ( ) > max_size ) { heap -> Pop ( & entry ) ; } } }
Adds a RecodeNode to heap if there is room
or if better than the current worst element if already full.
Adds a RecodeNode to heap if there is room or if better than the current worst element if already full .