001    /*
002     *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003     *
004     *  This file is licensed to You under the Eclipse Public License (EPL);
005     *  You may not use this file except in compliance with the License. You
006     *  may obtain a copy of the License at
007     *
008     *      http://www.opensource.org/licenses/eclipse-1.0.php
009     *
010     *  See the COPYRIGHT.txt file distributed with this work for information
011     *  regarding copyright ownership.
012     */
013    package org.jikesrvm.compilers.opt.util;
014    
015    
016    /**
017     * Interface to allow building top-sort, by calling TopSort.buildTopSort()
018     */
019    public interface TopSortInterface {
020    
021      /**
022       * Return the start node if forward = true for forward topsort,
023       * and return the end node if forward = false for backward topsort.
024       * @param forward whether we are viewing the graph in the forward direction
025       * @return the start node if forward = true for forward topsort,
026       *         the end node if forward = false for backward topsort.
027       */
028      SortedGraphNode startNode(boolean forward);
029    
030      /**
031       * Return the number of nodes in the graph
032       * @return the number of nodes in the graph
033       */
034      int numberOfNodes();
035    
036      /**
037       * Return true if no resetTopSorted(forward) has been executed
038       * since the last setTopSorted(forward) has been executed
039       * @param forward whether we are viewing the graph in the forward direction
040       * @return true if no resetTopSorted(forward) has been executed
041       * since the last setTopSorted(forward) has been executed
042       */
043      boolean isTopSorted(boolean forward);
044    
045      /**
046       * Should have a side effect such that isTopSorted(forward)
047       * returns the correct value.
048       * @param forward whether we are viewing the graph in the forward direction
049       */
050      void setTopSorted(boolean forward);
051    
052      /**
053       * Should have a side effect such that isTopSorted(forward)
054       * returns the correct value.
055       */
056      void resetTopSorted();
057    }
058    
059    
060