// file: tok_trace_2.cc
//

// isip include files
//
#include "token.h"
#include "token_constants.h"
 
// method: prune_cc
//
// arguments:
//  float_4 beam: (input) the beam threshold for pruning
//  logical_1 flag: (input) alignment mode flag
//  int_4& ndel: (output) number of deleted traces
//
// return: a logical_1 indicating success
//
// this method prunes the trace in the token
//
logical_1 Token::prune_cc(float_4 beam_a, logical_1 flag_a, int_4& ndel_a) {

  // memory manager
  //
  Memory_manager* manager = Link_list::get_manager_cc();

  // check if this token has been populated with traces
  //
  if (trace_d != (Trace*)NULL) {
  
    // compare the trace score
    //
    if (trace_d->get_score_cc() < beam_a) {
      
      // adjust ref counts if needed
      //
      if (flag_a == ISIP_TRUE) {
	trace_d->decr_ref_cc();
      }
      
      // prune the trace
      //
      manager->delete_cc(trace_d);
      trace_d = (Trace*)NULL;
      
      // increment deletion count
      //
      ndel_a++;
    }
  }
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
