Code example for TreeMap

Methods: firstKey, putAll

0
 
    /* Returns position of timer, that has a minimal time to alarm 
     * TreeMap sorted by value 
     */ 
    private synchronized int getLeastTimerPosition() { 
        TreeMap<Integer, Long> sorted = new TreeMap<Integer, Long>(comparator);
        sorted.putAll(alarms);
        return sorted.firstKey();
    } 
 
    private void doStart(int position) {
        Log.d(LOG_TAG, "doStart() on position " + position);
         
        if (startedRecipeId == NONE) {
            startedRecipeId = currentRecipeId;
            for (int i = 0; i < getStartedRecipeSteps().size(); i++) {
                isTimerStarted.add(Boolean.FALSE);
            } 
        } 
 
        // if this timer has a minimal time to start