KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thaiopensource > validate > nrl > Hashset


1 package com.thaiopensource.validate.nrl;
2
3 import java.util.Hashtable;
4 import java.util.Enumeration;
5
6 class Hashset {
7   private final Hashtable table = new Hashtable();
8
9   boolean contains(Object key) {
10     return table.get(key) != null;
11   }
12
13   void add(Object key) {
14     table.put(key, key);
15   }
16
17   void addAll(Hashset set) {
18     for (Enumeration enum = set.table.keys(); enum.hasMoreElements();)
19       add(enum.nextElement());
20   }
21
22   void clear() {
23     table.clear();
24   }
25
26   Enumeration members() {
27     return table.keys();
28   }
29 }
30
Popular Tags