lojix/logic/src/main/com/thesett/aima/logic/fol/compiler/BasicTraverser.java
public Iterator<Operator<Term>> traverse(Functor functor, boolean reverse)
    {
        /*log.fine("Traversing functor " + functor.toString());*/

        Queue<Operator<Term>> queue = (!reverse) ? new StackQueue<Operator<Term>>() : new LinkedList<Operator<Term>>();

        Term[] arguments = functor.getArguments();

        // For a top-level functor clear top-level flag, so that child functors are not taken as top-level.
        if (arguments != null)
        {
            for (int i = leftToRightFunctorArgs ? 0 : (arguments.length - 1);
                    leftToRightFunctorArgs ? (i < arguments.length) : (i >= 0);
                    i = i + (leftToRightFunctorArgs ? 1 : -1))
            {
                Term argument = arguments[i];
                argument.setReversable(createTermOperator(argument, i, functor));
                argument.setTermTraverser(this);
                queue.offer(argument);
            }
        }

        return queue.iterator();
    }
public Iterator<Operator<Term>> traverse(Functor functor, boolean reverse)
    {
        /*log.fine("Traversing functor " + functor.toString());*/

        Queue<Operator<Term>> queue = (!reverse) ? new StackQueue<Operator<Term>>() : new LinkedList<Operator<Term>>();

        Term[] arguments = functor.getArguments();

        // For a top-level functor clear top-level flag, so that child functors are not taken as top-level.
        if (arguments != null)
        {
            for (int i = leftToRightFunctorArgs ? 0 : (arguments.length - 1);
                    leftToRightFunctorArgs ? (i < arguments.length) : (i >= 0);
                    i = i + (leftToRightFunctorArgs ? 1 : -1))
            {
                Term argument = arguments[i];
                argument.setReversable(createTermOperator(argument, i, functor));
                argument.setTermTraverser(this);
                queue.offer(argument);
            }
        }

        return queue.iterator();
    }
{@inheritDoc}