Message9946

Author stefan.richthofer
Recipients jmadden, stefan.richthofer
Date 2015-04-24.00:26:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1429835178.22.0.271369277052.issue2337@psf.upfronthosting.co.za>
In-reply-to
Content
Until now I actually did not look into the detailes of PyDequeue and just wrote traverseprocs to catch all non-static fields somehow.
However. Since it appears to be a doubly linked, circular list-structure, simply watching out for header is probably more efficient than using general purpose reflection-based traversal. I would add some improvement to your variant though. The iteration should be done in a non-recursive way to avoid bothering Java's stack unnecessarily:

    @Override
    public int traverse(Visitproc visit, Object arg) {
        if (header == null) {
            return 0;
        }
        int retVal = 0;
        if (header.data != null) {
            retVal = visit.visit(header.data, arg);
            if (retVal != 0) {
                return retVal;
            }
        }
        Node tmp = header.right;
        while (tmp != header) {
            if (tmp.data != null) {
                retVal = visit.visit(tmp.data, arg);
                if (retVal != 0) {
                    return retVal;
                }
            }
            tmp = tmp.right;
        }
        return retVal;
    }

This seems to work, but I'd appreciate if you could review this iteration to make sure I did not mess up anything.
History
Date User Action Args
2015-04-24 00:26:18stefan.richthofersetmessageid: <1429835178.22.0.271369277052.issue2337@psf.upfronthosting.co.za>
2015-04-24 00:26:18stefan.richthofersetrecipients: + stefan.richthofer, jmadden
2015-04-24 00:26:18stefan.richthoferlinkissue2337 messages
2015-04-24 00:26:17stefan.richthofercreate