This commit was manufactured by cvs2svn to create tag 'buildscript'.
[IRC.git] /
1 package Interface;
2
3 class HashStrings {
4   Pair p[];   // entries in the hash table
5   int f;      // number of full entries
6   public HashStrings() {
7     p = new Pair[38]; f = 0;
8   }
9
10   public void put(String key, String value) {
11     int n = p.length;
12     if (f  == n-1) return;     // cheese -- a diary product
13     int i = key.hashCode() % n;
14     while (p[i] != null) {
15       if (key.equals(p[i].key)) {
16         p[i] = new Pair(key, value);
17         return;
18       }
19       i = (i+1) % n;
20     }
21     p[i] = new Pair(key, value);
22     f = f + 1;
23   }
24
25   public String get(String key) {
26     int n = p.length;
27     int i = key.hashCode() % n;
28     while (p[i] != null) {
29       if (key.equals(p[i].key))
30         return p[i].value;
31       i = (i+1) % n;
32     }
33     return null;
34   }
35
36 }
37
38 class Pair {
39   String key, value;
40   Pair (String key, String value) {
41     this.key = key; this.value = value;
42   }
43 }