// file: hist_add_2.cc
//

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

// method: remove_score_cc
//
// arguments:
//  int_4 idx: (input) index position to remove score
//
// return: a logical_1 indicating status
//
// this method removes the indexed score from the history score array
//
logical_1 History::remove_score_cc(int_4 idx_a) {
  
  // define local variables
  //
  int_4 len = hist_num_d - 1;

  // check if this was the only score
  //
  if (len == (int_4)0) {
    delete [] prevsc_d;
    prevsc_d = (float_4*)NULL;
    return ISIP_TRUE;
  }
  
  // allocate memory for the new list
  //
  float_4* sclist = new float_4[len];

  // loop over old score list and copy
  //
  if (prevsc_d != (float_4*)NULL) {
    for (int_4 i = 0; i < idx_a; i++) {
      sclist[i] = prevsc_d[i];
    }
  }

  // copy the remaining scores skipping the index
  //
  for (int_4 i = idx_a; i < len; i++) {
    sclist[i] = prevsc_d[i + 1];
  }

  // free old array and copy new one
  //
  if (prevsc_d != (float_4*)NULL) {
    delete [] prevsc_d;
  }
  prevsc_d = sclist;
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
