private class Iterator<G> : Object, Gee.Traversable<G>, Gee.Iterator<G>, ListIterator<G> {
public Iterator (Node<G> head) {
- _started = false;
_removed = false;
_index = -1;
_prev = null;
bool success = Node.proceed<G> (ref _prev, ref _curr);
if (success) {
if (_removed)
- _prev = _old_prev;
+ _prev = (owned)_old_prev;
_removed = false;
- _started = true;
_index++;
}
return success;
public bool has_next () {
HazardPointer.Context ctx = new HazardPointer.Context ();
Node<G>? prev = _prev;
- Node<G>? curr = _curr;
+ Node<G> curr = _curr;
return Node.proceed<G> (ref prev, ref curr);
}
}
public bool valid {
- get { return _started && !_removed && _curr != null; }
+ get {
+ assert (_curr != null);
+ return _prev != null && !_removed;
+ }
}
public bool read_only { get { return false; } }
public new bool foreach (ForallFunc<G> f) {
HazardPointer.Context ctx = new HazardPointer.Context ();
- if (_started && !_removed) {
+ if (_prev != null && !_removed) {
if (!f (HazardPointer.get_pointer<G> (&_curr._data))) {
return false;
}
Node<G>? _old_prev = _removed ? _prev : null;
while (Node.proceed<G> (ref _prev, ref _curr)) {
if (_removed)
- _prev = _old_prev;
+ _prev = (owned)_old_prev;
_removed = false;
- _started = true;
_index++;
if (!f (HazardPointer.get_pointer<G> (&_curr._data))) {
return false;
return true;
}
- private bool _started;
private bool _removed;
private int _index;
- private Node<G> _prev;
- private Node<G>? _curr;
+ private Node<G>? _prev;
+ private Node<G> _curr;
}
private class Node<G> {