// file: $isip/class/search/StackSearch/ssrch_13.cc
// version: $Id: ssrch_13.cc 9144 2003-05-16 21:59:27Z jelinek $
//

// isip include files
//
#include "StackSearch.h"

// method: getTraces
//
// arguments:
//  DoubleLinkedList<Trace>& trace_list: (output) traces at particular level
//  long level: (input) level of the traces to output
//
// return: logical error status
//
// returns all traces active at particular level
//
boolean StackSearch::getTraces(DoubleLinkedList<Trace>& trace_list_a,
			       long level_a) {

  // loop over all traces at the top level and put them
  // in the top_trace_list_a list
  //
  Trace* curr_trace = NULL;
  while (trace_lists_d(level_a).removeFirst(curr_trace)) {
    trace_list_a.insertLast(curr_trace);
  }

  if (level_a == 0) {
    // get also valid hypotheses
    //
    while (!valid_hyps_d.isEmpty()) {
      curr_trace = valid_hyps_d.pop();
      trace_list_a.insertLast(curr_trace);
    }
  }

  // make sure there is at least one trace in the list
  //
  if ((trace_list_a.length() < 1)) {

    // exit ungracefully
    //
    return false;
  }
  else {

    // exit gracefully
    //
    return true;
  }
}

// method: setTraces
//
// arguments:
//  DoubleLinkedList<Trace>& trace_list: (input) traces to put on certain level
//  long level: (input) level to put the traces on
//
// return: logical error status
//
// set the list of traces to be on the top level
//
boolean StackSearch::setTraces(
                       DoubleLinkedList<Trace>& trace_list_a, long level_a) {

  // make sure there is at least one trace in the list
  //
  Trace* curr_trace = NULL;
  while (trace_list_a.removeFirst(curr_trace)) {
    trace_lists_d(level_a).insertLast(curr_trace);
  }

  // exit gracefully
  //
  return true;
}

