Commit 5eb716f4 authored by Jonathan Michalon's avatar Jonathan Michalon

libovcc/ovcc-board implement foreach with an iterator

We can't break HashTable foreach, so implement our foreach with a HashTableIter
instead of calling GLib's so that the table may be modified while iterating
and iteration stopped immediately.
parent 975b7612
......@@ -466,13 +466,18 @@ namespace OVCC
*/
public bool @foreach (BoardForeachFunc f)
{
bool keep_going = true;
this._board.foreach ((k, v) => {
if (keep_going) {
keep_going = f (this, k, v);
HashTableIter<Position?,Tile> iter = HashTableIter<Position?,Tile> (this._board);
Position? pos;
Tile tile;
bool went_through = true;
while (iter.next (out pos, out tile)) {
if (f (this, pos, tile) == false) {
went_through = false;
break;
}
});
return keep_going;
}
return went_through;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment