コード例 #1
0
  /**
   * Compares this LTS to another for debugging purposes.
   *
   * @param other the other LTS to compare to
   * @return <code>true</code> if these are equivalent
   */
  public boolean compare(LetterToSound other) {

    // compare letter index table
    //
    for (Iterator i = letterIndex.keySet().iterator(); i.hasNext(); ) {
      String key = (String) i.next();
      Integer thisIndex = (Integer) letterIndex.get(key);
      Integer otherIndex = (Integer) other.letterIndex.get(key);
      if (!thisIndex.equals(otherIndex)) {
        if (RiTa.PRINT_LTS_INFO) System.err.println("[WARN] LTSengine -> Bad index: " + key);
        return false;
      }
    }

    // compare states
    //
    for (int i = 0; i < stateMachine.length; i++) {
      State state = getState(i);
      State otherState = other.getState(i);
      if (!state.compare(otherState)) {
        if (RiTa.PRINT_LTS_INFO) System.err.println("[WARN] LTSengine -> Bad state: " + i);
        return false;
      }
    }

    return true;
  }