Code example for TreeMap

Methods: containsKey, headMap

0
     * exists, returns the entry for the greatest key less than the specified 
     * key; if no such entry exists, returns {@code null}. 
     */ 
    final Integer floorKey(Integer time) {
    	 
    	if(events.containsKey(time)) {
    		return time;
    	} 
    	 
    	SortedMap<Integer, Event> map = events.headMap(time);    	
    	return map.isEmpty() ? null : map.lastKey();    	
    }     
     
    /** 
     *	Returns the least key greater than or equal to the given key,  
     *	or null if there is no such key. 
     */ 
    final Integer ceilingKey(Integer time) {
    	 
    	if(events.containsKey(time)) {
    		return time;