// file: hash_cell.h
//

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

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

#ifndef __ISIP_INTEGRAL_CONSTANTS
#include <integral_constants.h>
#endif

// Hash_cell: a class that defines a cell of a Hash_table 
//
class Hash_cell {

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

  // contents of the Hash_cell
  //
  // if the hash is operating in STRING_KEY mode then key_str_d is the
  // hash key, if it is operating in INTEGER_KEY mode then key_vec_d is
  // the hash key
  //
  char_1* key_str_d;                        // the hash key
  int_4* key_vec_d;
  int_4 key_size_d;

  void_p item_d;                            // the hashed item pointer 
  Hash_cell* next_d;                        // the hash_cell with the
                                            // same index as this one
                                     
  //---------------------------------------------------------------------------
  //
  // 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
  //
  ~Hash_cell();                                 // destructor
  Hash_cell();                                  // default
  Hash_cell(void_p item, char_1* key_str);      // overloaded
  Hash_cell(void_p item, int_4* key_vec,
	    int_4 key_size);                  // overloaded
  Hash_cell(Hash_cell& cell);                   // copy

  // set methods
  //
  logical_1 set_key_cc(char_1* key_str);
  logical_1 set_key_cc(int_4* key_vec, int_4 key_size);

  logical_1 set_item_cc(void_p item) {
    item_d = item;
    return ISIP_TRUE;
  }
  
  logical_1 set_next_cc(Hash_cell* cell) {
    next_d = cell;
    return ISIP_TRUE;
  }

  logical_1 set_cc(char_1* key_str, void_p item);
  logical_1 set_cc(int_4* key_vec, int_4 key_size, void_p item);

  // get methods
  //
  logical_1 get_key_cc(char_1*& key_str) {
    key_str = key_str_d;
    return ISIP_TRUE;
  }

  logical_1 get_key_cc(int_4*& key_vec, int_4& key_size) {
    key_vec = key_vec_d;
    key_size = key_size_d;
    return ISIP_TRUE;
  }

  void_p get_item_cc() {
    return item_d;
  }
  
  Hash_cell* get_next_cc() {
    return next_d;
  }

  // clear the contents of the cell
  //
  logical_1 clear_cc();
  
  //---------------------------------------------------------------------------
  //
  // private methods
  //
  //---------------------------------------------------------------------------
private:

};

// end of file
//
# endif
