// file: ngrl_clear_0.cc
//

// isip include files
//
#include "ngram_list.h"
#include "ngram_list_constants.h"

// method: clear_cc
//
// arguments: none
//
// return: a logical_1 indicating success
//
// this method clears the contents of the ngram array and returns all
// nodes to the memory manager
//
logical_1 Ngram_list::clear_cc() {

  // the memory manager
  //
  Memory_manager* manager = Link_list::get_manager_cc();
  
  // remove node pointers and return them to the manager
  //
  for (int_4 i = 0; i < num_d; i++) {
    manager->delete_cc(nodes_d[i]);
    nodes_d[i] = (Ngram_node*)NULL;
  }

  // reset size
  //
  num_d = NGRAM_LIST_DEFAULT_NUM;
  
  // delete the array
  //
  if (nodes_d != (Ngram_node**)NULL) {
    delete [] nodes_d;
    nodes_d = (Ngram_node**)NULL;
  }
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
