summaryrefslogtreecommitdiff
path: root/src/hash-table.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/hash-table.h')
-rw-r--r--src/hash-table.h69
1 files changed, 46 insertions, 23 deletions
diff --git a/src/hash-table.h b/src/hash-table.h
index 86438d00f7d6..d6938eb4d1f0 100644
--- a/src/hash-table.h
+++ b/src/hash-table.h
@@ -2,42 +2,65 @@
/* Hash table used to check for duplicate keyword entries.
- Copyright (C) 1989-1998, 2000 Free Software Foundation, Inc.
- written by Douglas C. Schmidt (schmidt@ics.uci.edu)
+ Copyright (C) 1989-1998, 2000, 2002 Free Software Foundation, Inc.
+ Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
+ and Bruno Haible <bruno@clisp.org>.
-This file is part of GNU GPERF.
+ This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+ GNU GPERF is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ GNU GPERF is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with GNU GPERF; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING.
+ If not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef hash_table_h
#define hash_table_h 1
-#include "list-node.h"
+#include "keyword.h"
+
+/* Hash table of KeywordExt* entries.
+ Two entries are considered equal if their _selchars are the same and
+ - if !ignore_length - if their _allchars_length are the same. */
class Hash_Table
{
+public:
+ /* Constructor.
+ size is the maximum number of entries.
+ ignore_length determines a detail in the comparison function. */
+ Hash_Table (unsigned int size, bool ignore_length);
+ /* Destructor. */
+ ~Hash_Table ();
+ /* Attempts to insert ITEM in the table. If there is already an equal
+ entry in it, returns it. Otherwise inserts ITEM and returns NULL. */
+ KeywordExt * insert (KeywordExt *item);
+ /* Print the table's contents. */
+ void dump () const;
+
private:
- List_Node **table; /* Vector of pointers to linked lists of List_Node's. */
- int size; /* Size of the vector. */
- int collisions; /* Find out how well our double hashing is working! */
- int ignore_length;
+ /* Vector of entries. */
+ KeywordExt ** _table;
+ /* Size of the vector. */
+ unsigned int _size;
+ /* log2(_size). */
+ unsigned int _log_size;
+ /* A detail of the comparison function. */
+ bool const _ignore_length;
+ /* Statistics: Number of collisions so far. */
+ unsigned int _collisions;
-public:
- Hash_Table (List_Node **t, int s, int ignore_len);
- ~Hash_Table (void);
- List_Node *insert (List_Node *item);
+ /* Compares two items. */
+ bool equal (KeywordExt *item1, KeywordExt *item2) const;
};
#endif