Skip to content

Commit 910498d

Browse files
committed
fix: get correct implementation of iterator
1 parent 3538f17 commit 910498d

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

src/neighbours.jl

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -307,38 +307,37 @@ end
307307

308308
function Base.iterate(neighbour_list::LinkedIterator, state=-1)
309309

310-
#@inbounds for c2 in neighbour_cells
311-
# j = neighbour_list.head[c2]
310+
#@inbounds for c in neighbour_list.neighbour_cells
311+
# j = neighbour_list.head[c]
312312
# while (j != -1)
313+
# do stuff
313314
# j = neighbour_list.list[j]
314315
# end
315316
#end
316317

317318
# First time in
318319
if state == -1
319-
c, c_state = iterate(neighbour_list.neighbour_cells)
320-
j = neighbour_list.head[c]
321-
state = (c_state, j)
322-
return j, state
323-
end
324-
325-
c_state, j = state
326-
if j == -1
327-
next = iterate(neighbour_cells, c_state)
320+
next = iterate(neighbour_list.neighbour_cells)
328321
if next == nothing
329322
return nothing
330323
end
331324
c, c_state = next
332325
j = neighbour_list.head[c]
326+
else
327+
c_state, j = state
328+
j = neighbour_list.list[j]
333329
if j == -1
334-
return nothing
330+
next = iterate(neighbour_list.neighbour_cells, c_state)
331+
if next == nothing
332+
return nothing
333+
end
334+
c, c_state = next
335+
j = neighbour_list.head[c]
335336
end
336-
state = (c_state, j)
337-
return j, state
338337
end
339-
j = neighbour_list.list[j]
338+
340339
if j == -1
341-
return nothing
340+
return nothing
342341
end
343342
state = (c_state, j)
344343
return j, state

0 commit comments

Comments
 (0)