Mercurial > ~dholland > hg > ag > index.cgi
comparison oldclasslib/include/strdict.h @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children | 607e3be6bad8 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 /* | |
2 * AnaGram, a System for Syntax Directed Programmng | |
3 * String Dictionary Class Definition | |
4 * | |
5 * Copyright 1993 Parsifal Software. All Rights Reserved. | |
6 * | |
7 * This software is provided 'as-is', without any express or implied | |
8 * warranty. In no event will the authors be held liable for any damages | |
9 * arising from the use of this software. | |
10 * | |
11 * Permission is granted to anyone to use this software for any purpose, | |
12 * including commercial applications, and to alter it and redistribute it | |
13 * freely, subject to the following restrictions: | |
14 * | |
15 * 1. The origin of this software must not be misrepresented; you must not | |
16 * claim that you wrote the original software. If you use this software | |
17 * in a product, an acknowledgment in the product documentation would be | |
18 * appreciated but is not required. | |
19 * 2. Altered source versions must be plainly marked as such, and must not be | |
20 * misrepresented as being the original software. | |
21 * 3. This notice may not be removed or altered from any source distribution. | |
22 */ | |
23 | |
24 #ifndef STRDICT_H | |
25 #define STRDICT_H | |
26 | |
27 class string_dictionary { | |
28 unsigned *sxs; // Storage for string indices | |
29 char *cs; // Storage for character strings | |
30 unsigned csx; // Next available location in cs | |
31 unsigned csxmax; // Size of cs | |
32 unsigned ns; // Number of strings in dictionary | |
33 unsigned nsmax; // Max number of strings | |
34 unsigned *ht; // Hash table storage | |
35 unsigned htl; // Size of hash table | |
36 unsigned htmask; // Hash table mask | |
37 unsigned hash(const char *); // Hash function | |
38 unsigned n_calls; // Number of calls | |
39 unsigned n_collisions; // Number of collisions | |
40 int copy_flag; // Is it live or is it memorex? | |
41 public: | |
42 | |
43 | |
44 // Constructors | |
45 | |
46 string_dictionary(unsigned size, unsigned word_length = 10); | |
47 | |
48 string_dictionary(string_dictionary &); | |
49 | |
50 | |
51 // Destructor | |
52 | |
53 ~string_dictionary(); | |
54 | |
55 | |
56 // Reset String Dictionary | |
57 | |
58 friend string_dictionary &reset(string_dictionary &); | |
59 | |
60 | |
61 // Enter a String in Dictionary | |
62 | |
63 unsigned operator << (const char *); // Insert string | |
64 | |
65 | |
66 // Look up a String in Dictionary | |
67 | |
68 unsigned operator [] (const char *); // Look up string | |
69 | |
70 | |
71 // Recover String from Dictionary Index | |
72 | |
73 char * operator [] (unsigned); // Find string | |
74 | |
75 | |
76 // Find Number of Entries in Dictionary | |
77 | |
78 friend unsigned size(string_dictionary &); | |
79 }; | |
80 | |
81 #endif |