/* (non-Javadoc)
   * @see org.sosy_lab.ccvisu.readers.filter.Filter#apply(org.sosy_lab.ccvisu.graph.Relation)
   */
  @Override
  public Relation apply(Relation relation) {
    assert (relation != null);
    Relation newRel = new Relation();

    for (Tuple tuple : relation) {
      if (nameIsWhitelisted(tuple.getRelationName())) {
        newRel.addTuple(tuple);
      }
    }

    return newRel;
  }
Exemple #2
0
    @Override
    public int compare(final Tuple leftTuple, final Tuple rightTuple) {
      assert (leftTuple != null && rightTuple != null);

      if (!leftTuple.getRelationName().equals(rightTuple.getRelationName())) {
        return leftTuple.getRelationName().compareTo(rightTuple.getRelationName());

      } else {
        Iterator<String> leftIterator = leftTuple.getTupleElements().iterator();
        Iterator<String> rightIterator = rightTuple.getTupleElements().iterator();

        while (leftIterator.hasNext() && rightIterator.hasNext()) {
          String str0 = leftIterator.next();
          String str1 = rightIterator.next();

          if (!str0.equals(str1)) {
            return str0.compareTo(str1);
          }
        }

        if (leftIterator.hasNext()) {
          // leftTuple is longer
          return 1;

        } else if (rightIterator.hasNext()) {
          // rightTuple is longer
          return -1;

        } else {
          // both are exactly equal
          return 0;
        }
      }
    }