// file: hist_cstr_0.cc
//

// isip include files
//
#include "history.h"
#include "history_constants.h"

// method: destructor
//
// arguments: none
//
// return: none
//
// this is the default destructor
//
History::~History() {

  // local variables
  //
  Link_node* pd = (Link_node*)NULL;
  History* hist = (History*)NULL;
  
  // remove the path history information
  //
  if (prev_d != (Link_list*)NULL) {
    for (Link_node* node = prev_d->get_head_cc(); node != (Link_node*)NULL;
	 node = pd) {
      pd = node->get_next_cc();
      hist = (History*)(node->get_item_cc());
      if (hist != (History*)NULL) {
	hist->decr_ref_count_cc();
      }
      prev_d->remove_cc(node);
    }
    delete prev_d;
    prev_d = (Link_list*)NULL;
  }

  // remove the path score information
  //
  if (prevsc_d != (float_4*)NULL) {
    delete [] prevsc_d;
    prevsc_d = (float_4*)NULL;
  }

  // reset number of histories
  //
  hist_num_d = (int_4)0;
  
  // remove the history words information
  //
  if (histwords_d != (void_p*)NULL) {
    delete [] histwords_d;
    histwords_d = (void_p*)NULL;
  }
  
  // reset the parameters
  //
  type_d = HISTORY_WORDGRAPH;
  level_d = HISTORY_DEFAULT_INDEX;
  phone_index_d = HISTORY_DEFAULT_INDEX;
  state_index_d = HISTORY_DEFAULT_INDEX;
  ref_count_d = (int_4)0;
  frame_index_d = (int_4)0;
  score_d = HISTORY_DEFAULT_SCORE;

  // exit gracefully
  //
}
