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-2009 Kevin Rosenberg
11 ** This program is free software; you can redistribute it and/or modify
12 ** it under the terms of the GNU General Public License (version 2) as
13 ** published by the Free Software Foundation.
15 ** This program is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ** GNU General Public License for more details.
20 ** You should have received a copy of the GNU General Public License
21 ** along with this program; if not, write to the Free Software
22 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 ******************************************************************************/
29 class KeywordCodeEntry
32 std::string m_strKeyword;
34 class KeywordCodeEntry *m_pNext;
38 KeywordCodeEntry (const char* const pszKeyword, int iCode);
40 const char* const getKeyword() const
41 { return m_strKeyword.c_str(); }
43 bool matchesKeyword (const char* const pszMatch) const;
48 void setCode (int iCode)
51 void setNext (KeywordCodeEntry* pNext)
54 KeywordCodeEntry* getNext ()
59 class KeywordCodeHashTable {
65 KeywordCodeHashTable()
68 ~KeywordCodeHashTable()
71 void installKeywordCode (const char* const pszKeyword, int iCode);
72 KeywordCodeEntry* lookup (const char* const pszKeyword);
75 KeywordCodeEntry* m_hashTable[HASHSIZE];
77 int hash (const char* s);