コード例 #1
0
  public HashMap<CoordinatePair, Integer> analyzeNoString(CoreLog log) {
    HashMap<CoordinatePair, Integer> sentMessages = new HashMap<>();

    for (int i = 0; i < log.logSize(); i++) {
      LogEntry entry = log.getEntry(i);

      Coordinate sourceCoord = new Coordinate(entry.sourceX(), entry.sourceY());
      Coordinate destCoord = new Coordinate(entry.destX(), entry.destY());
      CoordinatePair pair = coordinatePairEquivalence(sourceCoord, destCoord);

      // If the key already exists update the value, timesOccured
      // otherwise put a new entry in for the key
      if (sentMessages.containsKey(pair)) {
        int timesOccured = sentMessages.remove(pair);
        sentMessages.put(pair, ++timesOccured);
      } else {
        sentMessages.put(pair, 1);
      }
    }
    return sentMessages;
  }
コード例 #2
0
  @Override
  public String analyze(CoreLog log) {
    HashMap<CoordinatePair, Integer> sentMessages = new HashMap<>();

    for (int i = 0; i < log.logSize(); i++) {
      LogEntry entry = log.getEntry(i);

      Coordinate sourceCoord = new Coordinate(entry.sourceX(), entry.sourceY());
      Coordinate destCoord = new Coordinate(entry.destX(), entry.destY());
      CoordinatePair pair = coordinatePairEquivalence(sourceCoord, destCoord);

      // If the key already exists update the value, timesOccured
      // otherwise put a new entry in for the key
      if (sentMessages.containsKey(pair)) {
        int timesOccured = sentMessages.remove(pair);
        sentMessages.put(pair, ++timesOccured);
      } else {
        sentMessages.put(pair, 1);
      }
    }
    List<Map.Entry<CoordinatePair, Integer>> sortedList =
        SortingHelper.SortHashMapByValue(sentMessages); // analyze sentMessages
    return sortMapEntriesByDescendingValue(sortedList);
  }