lojix/wam_prolog/src/main/com/thesett/aima/logic/fol/wam/machine/WAMResolvingJavaMachine.java
private void tidyTrail()
    {
        int i;

        // Check that there is a current choice point to tidy down to, otherwise tidy down to the root of the trail.
        if (bp == 0)
        {
            i = TRAIL_BASE;
        }
        else
        {
            i = data.get(bp + data.get(bp) + 5);
        }

        while (i < trp)
        {
            int addr = data.get(i);

            if ((addr < hbp) || ((hp < addr) && (addr < bp)))
            {
                i++;
            }
            else
            {
                data.put(i, data.get(trp - 1));
                trp--;
            }
        }
    }
private void tidyTrail()
    {
        int i;

        // Check that there is a current choice point to tidy down to, otherwise tidy down to the root of the trail.
        if (bp == 0)
        {
            i = TRAIL_BASE;
        }
        else
        {
            i = data.get(bp + data.get(bp) + 5);
        }

        while (i < trp)
        {
            int addr = data.get(i);

            if ((addr < hbp) || ((hp < addr) && (addr < bp)))
            {
                i++;
            }
            else
            {
                data.put(i, data.get(trp - 1));
                trp--;
            }
        }
    }
Tidies trail when a choice point is being discarded, and a previous choice point it being made the current one.

<p/>Copies trail bindings created since the choice point, into the trail as known to the previous choice point.
That is bindings on the heap created during the choice point (between HB and H).