Java Reference
In-Depth Information
120
public
Object data;
121
public
Node next;
122 }
123
124
private class
HashSetIterator
implements
Iterator
125 {
126 /**
127
Constructs a hash set iterator that points to the
128
first element of the hash set.
129 */
130
public
HashSetIterator()
131 {
132 current =
null
;
133 bucket =
Ċ1
;
134 previous =
null
;
135 previousBucket =
Ċ1
;
136 }
137
138
public boolean
hasNext()
139 {
140
if
(current !=
null
&& current.next !
=
null
)
141
return true
;
142
for
(
int
b = bucket +
1
; b <
buckets.length; b++)
143
if
(buckets[b] !=
null
)
return
true
;
144
return false
;
145 }
146
147
public
Object next()
148 {
149 previous = current;
150 previousBucket = bucket;
151
if
(current ==
null
| | current.next
==
null
)
152 {
153
//
Move to next bucket
154 bucket++;
155
156
while
(bucket < buckets.length
712
713