📄 ht_insert_1.cc
字号:
// file: ht_insert_1.cc//// isip include files//#include "hmm_train.h"#include "hmm_train_constants.h"// method: insert_trace_cc//// arguments:// Train_Link_list*& tr_list : (input) the trace linked list// Train_Trace* trace : (input) the trace to insert// Train_Link_node* marker : (input) the trace position marker// int_4& ref : (output) the reference count for input trace// int_4& ngen : (output) the number of new traces generated// int_4& nact : (output) the number of active traces// float_8& max_score : (output) the max path score so far//// return: a logical_1 to indicate status//// this method inserts the given trace in the active trace list after// pruning away inferior traces. if the trace needs to create a node,// return true. if the trace gets pruned or prunes another trace,// returns false to indicate no growth in number of traces//logical_1 insert_trace_cc(Train_Link_list*& tr_list_a, Train_Trace* trace_a, Train_Link_node* marker_a, int_4& ref_a, int_4& ngen_a, int_4& nact_a, float_8& max_score_a) { // dummy variables // float_8 score = (float_8)0; logical_1 flag = ISIP_TRUE; Train_Trace* tr = (Train_Trace*)NULL; Train_Trace* betr = (Train_Trace*)NULL; // memory manager // Train_Memory_manager* manager = Train_Link_list::get_manager_cc(); // loop over all active traces for this frame // for (Train_Link_node* nd = marker_a; nd != (Train_Link_node*)NULL; nd = nd->get_next_cc()) { // get the trace in this node // tr = (Train_Trace*)(nd->get_item_cc()); // compare this trace with the input trace and determine which is // better // betr = trace_a->compare_cc(tr); // if this was a valid comparison // if (betr != (Train_Trace*)NULL) { // update score // score = betr->get_score_cc(); if (score > max_score_a) { max_score_a = score; } // if the input trace is the better path // if (betr == trace_a) { // substitute input trace and update ref count // nd->set_item_cc(trace_a); ref_a++; // delete old trace // // tr->incr_ref_path_cc((int_4)-1); manager->delete_cc(tr); } // if the other trace is the better path // else { // remove new trace // manager->delete_cc(trace_a); } // mark flag // flag = ISIP_FALSE; break; } } // insert trace if okay // if (flag == ISIP_TRUE) { // allocate trace list if one doesn't exist yet // if (tr_list_a == (Train_Link_list*)NULL) { tr_list_a = new Train_Link_list(); } // insert the trace and update counts // tr_list_a->insert_cc(trace_a); ref_a++; ngen_a++; nact_a++; // update score // score = trace_a->get_score_cc(); if (score > max_score_a) { max_score_a = score; } } // exit gracefully // return ISIP_TRUE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -