Java Reference
In-Depth Information
79
80 Node current = buckets[h];
81 Node previous = null ;
82 while (current ! = null )
83 {
84 if (current.data.equals(x))
85 {
86 if (previous == null ) buckets[h]
= current.next;
87 else previous.next = current.next;
88 size--;
89 return true ;
90 }
91 previous = current;
92 current = current.next;
93 }
94 return false ;
95 }
96
97 /**
98 Returns an iterator that traverses the elements of this set.
99 @return a hash set iterator
100 */
101 public Iterator iterator()
102 {
103 return new HashSetIterator();
104 }
105
106 /**
107 Gets the number of elements in this set.
108 @return the number of elements
109 */
110 public int size()
111 {
112 return size;
113 }
114
115 private Node[] buckets;
116 private int size;
117
118 private class Node
119 {
Search WWH ::




Custom Search