CTCLHashTableItem --  Encapsulation of an entry in a Tcl Hash table as encapsulated in CTCLHashTable


#include <TCLHashTableItem.h>

template <class T>              // T Must have copy ctor & Assignment defined.
class CTCLHashTableItem
  CTCLHashTableItem (T am_Item );
  CTCLHashTableItem (const CTCLHashTableItem& aCTCLHashTableItem );
  virtual ~CTCLHashTableItem ( );

  CTCLHashTableItem operator= (const CTCLHashTableItem& aCTCLHashTableItem);
   int operator== (const CTCLHashTableItem& aCTCLHashTableItem);
  T getItem() const;
  T* operator-> ();

Provides an object oriented interface to elements of a hash table. See CTCLHashTable(3), and the first REFERENCE below for more information about hash tables.

Note that this is a templated class. The template parameter is the type of the item to be stored in the hash table. Suppose, for example, we have a bunch of named calibration parameters (floating point) that are stored in a hash table. A calibration The following code creates the calibration table, and inserts an element named george in it with the initial value of 0.0:

        CTCLHashTable<float>  calibrationTable;
        CTCLHashTableItem<float> entry(0.0);
        calibrationTable.Enter(std::string("george"), entry);


CTCLHashTableItem (T Item );
CTCLHashTableItem (const CTCLHashTableItem& hashItem );

Constructs a CTCLHashTableItem either from the underlying type (Item) or from an existing CTCLHashTableItem (hashItem).

CTCLHashTableItem operator=(const CTCLHashTableItem& rhs);
int operator== (const CTCLHashTableItem& rhs);

operator= allows you to assign the value of one CTCLHashTableItem to another. The underlying templated type must be capable of assignment.

operator== allows you to compare two CTCLHashTableItems to each other. The underlying templated type must be capable of equality comparison.

T getItem() const;

Returns the value of the item wrapped by the CTCLHashTableItem The underlying type must be capable of copy construction.

T* operator-> ();       

Returns the address of the contents of the CTCLHashTableItem. This is most useful if T is a structure or class as it can be used to dereference member (data or functions) of the structure or class. For example:

                struct complex {
                                 double real;
                                 double imaginary;
                                 complex(double r, double i) :
                                    real(r), imaginary(i) {}
                                } complex;
                CTCLHashTableItem<complex> v(1.0, 2.0);
                double real = v->real;             // real = 1.0
                double imag = v->imaginary;        // imag = 2.0


CTCLHashTable(3), CTCLHashTableIterator(3)


Niklaus Wirth Algorithms + Data Structures = Programs
Prentice Hall Series in Automatic Computation 1976 See section 4.6