1 public class HashSet implements Set {
6 HashSet(int initialCapacity) {
7 map=new HashMap(initialCapacity);
9 HashSet(int initialCapacity, float loadFactor) {
10 map=new HashMap(initialCapacity, loadFactor);
12 public boolean add(Object o) {
13 return (map.put(o, this)==null);
15 public boolean addAll(Collection c) {
16 Iterator it = c.iterator();
18 if(!this.add(it.next())) {
24 public boolean remove(Object o) {
25 return (map.remove(o)!=null);
27 boolean removeAll(Collection c) {
28 Iterator it = c.iterator();
30 if(!this.remove(it.next())) {
36 public boolean isEmpty() {
42 public boolean contains(Object o) {
43 return map.containsKey(o);
45 public boolean containsAll(Collection c) {
46 Iterator it = c.iterator();
48 if(!this.contains(it.next())) {
57 public Iterator iterator() {
58 return map.iterator(0);