net.datastructures - version 5.0

net.datastructures
Interface Map<K,V>

All Known Subinterfaces:
DecorablePosition<E>, Edge<E>, Vertex<E>
All Known Implementing Classes:
AdjacencyListGraph.MyEdge, AdjacencyListGraph.MyPosition, AdjacencyListGraph.MyVertex, AVLTreeMap, BinarySearchTreeMap, HashTableMap, RBTreeMap

public interface Map<K,V>

An interface for a map which binds a key uniquely to a value.

Author:
Michael Goodrich

Method Summary
 Iterable<Entry<K,V>> entrySet()
          Returns an iterable object containing all the entries in the map.
 V get(K key)
          Returns the value of the entry containing the given key.
 boolean isEmpty()
          Returns whether the map is empty.
 Iterable<K> keySet()
          Returns an iterable object containing all the keys in the map.
 V put(K key, V value)
          If there is an entry with the specified key, replaces the value of this entry with the specified value and returns the old value.
 V remove(K key)
          If there is an entry with the specified key, removes this entry and returns its value.
 int size()
          Returns the number of items in the map.
 Iterable<V> values()
          Returns an iterable object containing all the values in the map.
 

Method Detail

size

int size()
Returns the number of items in the map.


isEmpty

boolean isEmpty()
Returns whether the map is empty.


put

V put(K key,
      V value)
      throws InvalidKeyException
If there is an entry with the specified key, replaces the value of this entry with the specified value and returns the old value. Else, adds a new entry with the specified key and value and returns null.

Throws:
InvalidKeyException

get

V get(K key)
      throws InvalidKeyException
Returns the value of the entry containing the given key. Returns null if no such entry exists.

Throws:
InvalidKeyException

remove

V remove(K key)
         throws InvalidKeyException
If there is an entry with the specified key, removes this entry and returns its value. Else, returns null.

Throws:
InvalidKeyException

keySet

Iterable<K> keySet()
Returns an iterable object containing all the keys in the map.


values

Iterable<V> values()
Returns an iterable object containing all the values in the map.


entrySet

Iterable<Entry<K,V>> entrySet()
Returns an iterable object containing all the entries in the map.


net.datastructures - version 5.0