// file: tr_tr_back_2.cc
//

// isip include files
//
#include "train_trace.h"
#include "train_trace_constants.h"

// method: set_back_ptr_cc
//
// arguments:
//  Train_Trace** trace: (input) the path back pointer to be set
//
// return: a logical_1 indicating status
//
// this method sets the input trace array as the path back pointer array
//
logical_1 Train_Trace::set_back_ptr_cc(Train_Trace** traces_a) {

  // if the backpointer array is already allocated
  //
  if (back_ptr_d != (Train_Trace**)NULL) {
    delete [] back_ptr_d;
  }

  // if the input is a null array
  //
  if (traces_a == (Train_Trace**)NULL) {
    back_ptr_d = (Train_Trace**)NULL;
  }
  
  // otherwise copy the new back pointer array
  //
  else {
    
    // allocate and initialize
    //
    back_ptr_d = new Train_Trace*[backptr_size_d];
    for (int_4 i = 0; i < backptr_size_d; i++) {
      back_ptr_d[i] = (Train_Trace*)NULL;
    }

    // copy pointers
    //
    for (int_4 i = 0; (i < backptr_size_d) &&
	   (traces_a[i] != (Train_Trace*)NULL); i++) {
      back_ptr_d[i] = traces_a[i];
    }
  } // end else

  // exit gracefully
  //
  return ISIP_TRUE;
}
