// file: ngram_list.h
//
// this is the header file for the Ngram_list class
//

// make sure definitions are made only once
//
#ifndef __ISIP_NGRAM_LIST
#define __ISIP_NGRAM_LIST

// isip include files
//
#ifndef __ISIP_INTEGRAL
#include <integral.h>
#endif

#ifndef __ISIP_NGRAM_NODE
#include <ngram_node.h>
#endif

#ifndef __ISIP_LINK_LIST
#include <link_list.h>
#endif

// ngram_list: a class that is used to store ngram nodes at a
// particular level
//
class Ngram_list {

  //---------------------------------------------------------------------------
  //
  // protected data
  //
  //---------------------------------------------------------------------------
protected:

  // array of ngram node pointers
  //
  Ngram_node** nodes_d;
  int_4 num_d;
  
  //---------------------------------------------------------------------------
  //
  // public methods
  //
  //---------------------------------------------------------------------------
public:
  
  // required methods
  //
  char_1* name_cc();
  volatile void error_handler_cc(char_1* mname, char_1* msg);
  logical_1 debug_cc(FILE* fp, char_1* message);
  int_4 size_cc();
  
  // destructors/constructors
  //
  ~Ngram_list();                                     // destructor
  Ngram_list();                                      // default constructor
  Ngram_list(int_4 num);                             // overloaded
  Ngram_list(Ngram_list& ngram_list);                // copy constructor
  
  // set methods
  //
  logical_1 set_num_cc(int_4 num);
  logical_1 set_nodes_cc(Ngram_node** nodes);
  logical_1 set_node_cc(int_4 index, Ngram_node* node);
  
  // get methods
  //
  int_4 get_num_cc() {
    return num_d;
  }

  Ngram_node** get_nodes_cc() {
    return nodes_d;
  }
  
  Ngram_node* get_node_cc(int_4 index);

  // ngram node manipulation methods
  //
  logical_1 get_node_cc(Word* word, Ngram_node**& node);
  logical_1 add_node_cc(int_4 index, Word* word, Ngram_node** hist,
			float_4 lmscore, float_4 backoff);
  Ngram_node** get_node_index_cc(Ngram_node* node);
  logical_1 adjust_num_cc(int_4 num);
  
  // clear the contents of the ngram node
  //
  logical_1 clear_cc();
  
  //---------------------------------------------------------------------------
  //
  // private methods
  //
  //---------------------------------------------------------------------------
private:

  // search for the ngram node with the given word in the specified
  // range in the list
  //
  Ngram_node** search_node_cc(Ngram_node** start, Ngram_node** end,
			      Word* word);
  Ngram_node** search_node_cc(Ngram_node** start, Ngram_node** end,
			      Ngram_node* node);
  
};

// end of file
// 
#endif
