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

        Functor head = clause.getHead();
        Functor[] body = clause.getBody();

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

        // For the head functor, set the top-level flag, set in head context.
        if (head != null)
        {
            head.setReversable(createHeadOperator(head, clause));
            head.setTermTraverser(this);
            queue.offer(head);
        }

        // For the body functors, set the top-level flag, clear in head context.
        if (body != null)
        {
            for (int i = leftToRightClauseBodies ? 0 : (body.length - 1);
                    leftToRightClauseBodies ? (i < body.length) : (i >= 0); i = i + (leftToRightClauseBodies ? 1 : -1))
            {
                Functor bodyFunctor = body[i];

                bodyFunctor.setReversable(createBodyOperator(bodyFunctor, i, body, clause));
                bodyFunctor.setTermTraverser(this);
                queue.offer(bodyFunctor);
            }
        }

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

        Functor head = clause.getHead();
        Functor[] body = clause.getBody();

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

        // For the head functor, set the top-level flag, set in head context.
        if (head != null)
        {
            head.setReversable(createHeadOperator(head, clause));
            head.setTermTraverser(this);
            queue.offer(head);
        }

        // For the body functors, set the top-level flag, clear in head context.
        if (body != null)
        {
            for (int i = leftToRightClauseBodies ? 0 : (body.length - 1);
                    leftToRightClauseBodies ? (i < body.length) : (i >= 0); i = i + (leftToRightClauseBodies ? 1 : -1))
            {
                Functor bodyFunctor = body[i];

                bodyFunctor.setReversable(createBodyOperator(bodyFunctor, i, body, clause));
                bodyFunctor.setTermTraverser(this);
                queue.offer(bodyFunctor);
            }
        }

        return queue.iterator();
    }
public Iterator < Operator < Term > > traverse ( Clause clause , boolean reverse ) { /*log.fine("Traversing clause " + clause.toString());*/ Functor head = clause . getHead ( ) ; Functor [ ] body = clause . getBody ( ) ; Queue < Operator < Term > > queue = ( ! reverse ) ? new StackQueue < Operator < Term > > ( ) : new LinkedList < Operator < Term > > ( ) ; // For the head functor, set the top-level flag, set in head context. if ( head != null ) { head . setReversable ( createHeadOperator ( head , clause ) ) ; head . setTermTraverser ( this ) ; queue . offer ( head ) ; } // For the body functors, set the top-level flag, clear in head context. if ( body != null ) { for ( int i = leftToRightClauseBodies ? 0 : ( body . length - 1 ) ; leftToRightClauseBodies ? ( i < body . length ) : ( i >= 0 ) ; i = i + ( leftToRightClauseBodies ? 1 : - 1 ) ) { Functor bodyFunctor = body [ i ] ; bodyFunctor . setReversable ( createBodyOperator ( bodyFunctor , i , body , clause ) ) ; bodyFunctor . setTermTraverser ( this ) ; queue . offer ( bodyFunctor ) ; } } return queue . iterator ( ) ; }
{@inheritDoc}
{