00001 00027 // 00028 // File int_name_table.h 00029 // 00030 // Defines the class IntNameTable for a table of names, 00031 // where insert returns an integer rather than char* 00032 // 00033 // made from NameTable, 13/05/2000, flight Manchester-Atlanta 00034 // 00035 00036 00037 #ifndef __int_name_table__ 00038 #define __int_name_table__ 00039 00040 00041 #include <iostream> 00042 00043 00044 #include "List.hpp" 00045 #include "Pair.hpp" 00046 00047 00048 typedef Pair <int,char*,CID_ENTRY> Entry; 00049 typedef List <Entry*,CID_ENTRY_LIST> EntryList; 00050 00051 00052 // ****************** class IntNameTable ********************** 00053 00054 class IntNameTable 00055 { 00056 public: 00057 00058 IntNameTable (); 00059 ~IntNameTable (); 00060 int insert ( const char* str ); 00061 const char* operator[] ( int num ) const; 00062 int numberOfSymbols (); 00063 00064 // friend ostream& operator << (ostream &stream,IntNameTable& table); 00065 static IntNameTable* vars; 00066 00067 private: 00068 00069 static const int _noOfBuckets; 00070 EntryList ** _buckets; 00071 int _nextNumber; 00072 00073 // hashing 00074 static int hash ( const char* ); // hashing function 00075 }; // class NameTable 00076 00077 00078 // ostream& operator << (ostream &stream,IntNameTable& table); 00079 00080 00081 00082 #endif 00083 00084