Message9951

Author jmadden
Recipients jmadden, stefan.richthofer
Date 2015-04-24.13:14:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1429881295.22.0.11299099557.issue2337@psf.upfronthosting.co.za>
In-reply-to
Content
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);
    }
History
Date User Action Args
2015-04-24 13:14:55jmaddensetmessageid: <1429881295.22.0.11299099557.issue2337@psf.upfronthosting.co.za>
2015-04-24 13:14:55jmaddensetrecipients: + jmadden, stefan.richthofer
2015-04-24 13:14:55jmaddenlinkissue2337 messages
2015-04-24 13:14:54jmaddencreate