Message9951
I like that approach much better. It works in both the simple and complex tests, with one slight modification: A separate `traverseNode` function is called by an active iterator (the inner class PyDequeIter), to traverse beginning with its current position, so that still needs to exist (well, and a null check). I'm not sure if this is an optimization (since eventually it may wind up traversing the full ring anyway) or has semantic implications.
This is the code I've been testing with (the last example just split into two functions for the sake of PyDequeIter plus a null check):
private int traverseNode(Node node, Visitproc visit, Object arg) {
int retVal = 0;
while (node != header && node != null) {
if (node.data != null) {
retVal = visit.visit(node.data, arg);
if (retVal != 0) {
return retVal;
}
}
node = node.right;
}
return retVal;
}
@Override
public int traverse(Visitproc visit, Object arg) {
int retVal = 0;
if (header.data != null) {
retVal = visit.visit(header.data, arg);
if (retVal != 0) {
return retVal;
}
}
return traverseNode(header.right, visit, arg);
} |
|
Date |
User |
Action |
Args |
2015-04-24 13:14:55 | jmadden | set | messageid: <1429881295.22.0.11299099557.issue2337@psf.upfronthosting.co.za> |
2015-04-24 13:14:55 | jmadden | set | recipients:
+ jmadden, stefan.richthofer |
2015-04-24 13:14:55 | jmadden | link | issue2337 messages |
2015-04-24 13:14:54 | jmadden | create | |
|