3 ** File Name: hashtable.h
4 ** Author: Kevin Rosenberg
5 ** Purpose: Header file for hash table library
6 ** Date Started: Dec. 2000
8 ** This is part of the CTSim program
9 ** Copyright (C) 1983-2000 Kevin Rosenberg
11 ** $Id: hashtable.h,v 1.2 2001/01/02 16:02:12 kevin Exp $
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
32 class KeywordCodeEntry
35 std::string m_strKeyword;
37 class KeywordCodeEntry *m_pNext;
41 KeywordCodeEntry (const char* const pszKeyword, int iCode);
43 const char* const getKeyword() const
44 { return m_strKeyword.c_str(); }
46 bool matchesKeyword (const char* const pszMatch) const;
51 void setCode (int iCode)
54 void setNext (KeywordCodeEntry* pNext)
57 KeywordCodeEntry* getNext ()
62 class KeywordCodeHashTable {
68 KeywordCodeHashTable()
71 ~KeywordCodeHashTable()
74 void installKeywordCode (const char* const pszKeyword, int iCode);
75 KeywordCodeEntry* lookup (const char* const pszKeyword);
78 KeywordCodeEntry* m_hashTable[HASHSIZE];
80 int hash (const char* s);