// file: train_hash_table.h
//
// this is the header file for the Train_Hash_table class
//

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

// isip include files
//
#ifndef __ISIP_TRAIN_HASH_CELL
#include <train_hash_cell.h>
#endif

#ifndef __TRAIN_HASH_TABLE_CONSTANTS
#include "train_hash_table_constants.h"
#endif

// Train_Hash_table: a class that defines a hash table of objects
//

class Train_Hash_table {

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

  //declare a variable for debugging
  //
  int_4 debug_level_d;
  
  // contents of the hash_table
  //
  Train_Hash_cell** cells_d;            // the hash_cell stored in hash_table 
  int_4 size_d;                         // size of the hash table
  char_1 mode_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);
  logical_1 set_debug_cc(int_4 debug_level_a);
  int_4 size_cc();
  
  // destructors/constructors
  //
  // destructors/constructors
  //
  ~Train_Hash_table();                                 // destructor
  Train_Hash_table(char_1 mode = TRAIN_HASH_TABLE_DEF_MODE);  
  Train_Hash_table(int_4 num, char_1 mode = TRAIN_HASH_TABLE_DEF_MODE);
  Train_Hash_table(Train_Hash_table& table);                 // copy

  // set methods
  //
  logical_1 set_size_cc(int_4 size);
  logical_1 set_cells_cc(Train_Hash_cell** cells_a);

  // get methods
  //
  int_4 get_size_cc();
  Train_Hash_cell** get_cells_cc();
 
  // hash table insert methods
  //
  Train_Hash_cell* hash_insert_cc(Train_Hash_cell* hash_cell);

  // hash table lookup methods
  //
  Train_Hash_cell* hash_lookup_cc(char_1* str);
  Train_Hash_cell* hash_lookup_cc(int_4* vec, int_4 size);
  
  //---------------------------------------------------------------------------
  //
  // private methods
  //
  //---------------------------------------------------------------------------
private:

  // hash table index method for string entry
  //
  int_4 hash_string_cc(char_1* str);
 
  // hash table index method for vector entry
  //
  int_4 hash_vector_cc(int_4* vec, int_4 size);
 
};

// end of file
//
# endif
