Example #1
0
 int getSeparatorCount(Tree right, Tree left) {
   if (right == null || left == null) {
     return 0;
   }
   int leftHead = ShiftReduceUtils.headIndex(left);
   int rightHead = ShiftReduceUtils.headIndex(right);
   Integer nextSeparator = separators.higherKey(leftHead);
   int count = 0;
   while (nextSeparator != null && nextSeparator < rightHead) {
     ++count;
     nextSeparator = separators.higherKey(nextSeparator);
   }
   return count;
 }
Example #2
0
  /** Return the lowest token that is greater than the given token */
  BigInteger getTokenAfter(BigInteger token) {
    BigInteger k = tokenToEndPointMap_.higherKey(token);

    if (k != null) return k;

    // Wrap around
    return tokenToEndPointMap_.firstKey();
  }
Example #3
0
  /**
   * @param indeks - indeks ścieżki w mapie
   * @return Szukana ścieżka lub null jeśli ścieżka o podanym indeksie nie istnieje
   */
  public Const.Direction getNewDirection(final int indeks) {
    if (indeks > paths.size()) {
      return null;
    }

    Const.Direction direction = paths.firstKey();

    for (int i = 0; i < indeks; ++i) {
      direction = paths.higherKey(direction);
    }

    return direction;
  }
Example #4
0
  /**
   * Returns the time the price changes after t
   *
   * @param t time after price will change
   * @return null if there is no next price change
   */
  public Long getNextPriceChange(long t) {
    if (t >= priceUnknownAtAndAfter) {
      return null;
    }

    compress();

    Long key = prices.higherKey(t);
    if (key == null /* && t < priceUnknownAfter */) {
      return priceUnknownAtAndAfter;
    } else {
      return key;
    }
  }
Example #5
0
 public static void main(String[] args) {
   TreeMap tm = new TreeMap();
   tm.put(new R(3), "轻量级Java EE企业应用实战");
   tm.put(new R(-5), "疯狂Java讲义");
   tm.put(new R(9), "疯狂Android讲义");
   System.out.println(tm);
   // 返回该TreeMap的第一个Entry对象
   System.out.println(tm.firstEntry());
   // 返回该TreeMap的最后一个key值
   System.out.println(tm.lastKey());
   // 返回该TreeMap的比new R(2)大的最小key值。
   System.out.println(tm.higherKey(new R(2)));
   // 返回该TreeMap的比new R(2)小的最大的key-value对。
   System.out.println(tm.lowerEntry(new R(2)));
   // 返回该TreeMap的子TreeMap
   System.out.println(tm.subMap(new R(-1), new R(4)));
 }
Example #6
0
 public K higherKey(K key) {
   return realMap.higherKey(key);
 }
 public void next() {
   curLine = code.higherKey(curLine);
 }
  public ExportHelperController(TreeMap<Integer, Arbeitsblock> t) {

    // Initalisierung vom File Objekt und der Dateiendung
    File file = null;
    String extension = null;
    try {

      // Erzeugen des FileChooser Objektes und Festsetzen der Startansicht des Choosers
      JFileChooser fileChooser = new JFileChooser();
      fileChooser.setCurrentDirectory(new File(System.getProperty("user.home")));

      // Dialog öffnen und File aussuchen bzw. den Filenamen manuell eintragen
      int result = fileChooser.showOpenDialog(null);
      if (result == JFileChooser.APPROVE_OPTION) {
        file = fileChooser.getSelectedFile();
        extension = file.getAbsolutePath();
        // Wenn die Endung nicht CSV ist
        if (file.getAbsolutePath()
                .substring(file.getAbsolutePath().lastIndexOf(".") + 1)
                .equals("csv")
            == false) {

          // Überprüfe, ob überhaupt eine Endung exisitiert, falls nicht, dann ".csv" als Dateiende
          // hinzufügen
          if (file.getAbsolutePath().lastIndexOf('.') < 1) {
            extension = file.getAbsolutePath() + ".csv";
          }
          // Wenn die Endung nicht ".csv" ist, die aktuelle Endung entfernen und ".csv" ans Ende
          // fügen
          else {
            extension =
                (file.getAbsolutePath().substring(0, file.getAbsolutePath().lastIndexOf(".")))
                    + ".csv";
          }
        }
        // Erstellen der File mit dem richtigen Pfad + Endung
        file = new File(extension);
        BufferedWriter bw = new BufferedWriter(new FileWriter(file));

        Integer k = 0;
        // Iterieren durch die Treemap und jeden Eintrag in das CSV Dokument schreiben mit Hilfe der
        // toString Methode in Arbeitsblock
        bw.write(" ID, Projekt, Tätigkeit, Startzeit, Endzeit");
        bw.newLine();
        while ((k = t.higherKey(k)) != null) {
          bw.write(t.get(k).toString());
          bw.newLine();
        }
        bw.close();
      }

    } catch (IOException e) {
      Object[] options = {"OK"};
      int n =
          JOptionPane.showOptionDialog(
              null,
              "Export fehlgeschlagen, bitte erneut versuchen",
              "Fehler beim Export",
              JOptionPane.PLAIN_MESSAGE,
              JOptionPane.QUESTION_MESSAGE,
              null,
              options,
              options[0]);
    }
  }