Code example for Deque

Methods: peek

0
 
  /** 
   * Retrieves the first item in the stack, but does not remove it. 
   */ 
  public Entry<K, V> peek() {
    K key = stack.peek();
    V value = map.get(key);
    return new StackMapEntry<>(key, value);
  } 
 
  /** 
   * Retrieves the first item in the stack and removes it. 
   */ 
  public Entry<K, V> pop() {
    K key = stack.pop();
    V value = map.remove(key);
    return new StackMapEntry<>(key, value);
  } 
 
}