Code example for SortedMap

Methods: get, headMap

0
    } 
 
    ArrayList<InetSocketAddress> getEnsemble(long entryId) {
        // the head map cannot be empty, since we insert an ensemble for 
        // entry-id 0, right when we start 
        return ensembles.get(ensembles.headMap(entryId + 1).lastKey());
    } 
 
    /** 
     * the entry id > the given entry-id at which the next ensemble change takes 
     * place ( -1 if no further ensemble changes) 
     *  
     * @param entryId 
     * @return 
     */ 
    long getNextEnsembleChange(long entryId) {
        SortedMap<Long, ArrayList<InetSocketAddress>> tailMap = ensembles.tailMap(entryId + 1);
 
        if (tailMap.isEmpty()) {
            return -1; 
        } else {