net.walend.collection
Interface Map

All Superinterfaces:
HasState
All Known Subinterfaces:
MapToFreezables, MutableMap, MutableMapToFreezables
All Known Implementing Classes:
AbstractFreezerHashMap, AbstractHashMap, AbstractHashMapToFreezables, MutableFreezerHashMap, MutableHashMap, MutableHashMapToFreezables, SoftHashMap

public interface Map
extends HasState

A container that maps keys to values. A Map does not contain duplicate keys but can contain duplicate values. Any key maps to zero or one value.

Map implementations should provide two copy constructors: one should take another Map and perform a shallow copy. The other should take a java.util.Map and perform a shallow copy.

Unlike java.util.Map, this interface does not override hashcode and eqauals. Instead it provides the containsAll() and sameContentsAs() methods.

Since:
20010705
Author:
David Walend

Field Summary
static Map EMPTY
           
 
Method Summary
 boolean containsAll(Map c)
          Returns true if this collection contains all of the Objects in the specified collection.
 boolean containsKey(java.lang.Object key)
          Returns true if this map contains an entry for key.
 boolean containsValue(java.lang.Object value)
          Returns true if this map contains value.
 java.lang.Object get(java.lang.Object key)
          Returns the value for the key.
 Identitor getIdentitor()
          Returns the Identitor for this Map.
 java.util.Map getJavaMap()
          Return a java.util.Collection of these Objects.
 Set getKeys()
          Returns an immutable shallow copy of the Set of keys.
 Collection getValues()
          Returns an immutable shallow copy of the Collection of values.
 boolean isEmpty()
          Returns true if this Map has no entries.
 java.util.Iterator keyIterator()
          Returns an iterator over the keys.
 boolean sameContentsAs(Map c)
          Returns true if this Collection's contents are equal to c's.
 int size()
          Returns the number of key-value pairs in this map.
 java.util.Iterator valueIterator()
          Returns an iterator over the values.
 
Methods inherited from interface net.walend.collection.HasState
getPrincipleInterface, sameStateAs
 

Field Detail

EMPTY

public static final Map EMPTY
Method Detail

getIdentitor

public Identitor getIdentitor()
Returns the Identitor for this Map.


size

public int size()
Returns the number of key-value pairs in this map.


isEmpty

public boolean isEmpty()
Returns true if this Map has no entries.


containsKey

public boolean containsKey(java.lang.Object key)
Returns true if this map contains an entry for key.

Throws:
java.lang.NullPointerException - if key is null.

containsValue

public boolean containsValue(java.lang.Object value)
Returns true if this map contains value.

Throws:
java.lang.NullPointerException - if value is null.

get

public java.lang.Object get(java.lang.Object key)
Returns the value for the key. Returns null if the Map contains no value for key.

Throws:
java.lang.NullPointerException - if the key is null.

getKeys

public Set getKeys()
Returns an immutable shallow copy of the Set of keys.


getValues

public Collection getValues()
Returns an immutable shallow copy of the Collection of values.


keyIterator

public java.util.Iterator keyIterator()
Returns an iterator over the keys.


valueIterator

public java.util.Iterator valueIterator()
Returns an iterator over the values.


containsAll

public boolean containsAll(Map c)
Returns true if this collection contains all of the Objects in the specified collection. This method uses the contains() method.


sameContentsAs

public boolean sameContentsAs(Map c)
Returns true if this Collection's contents are equal to c's.


getJavaMap

public java.util.Map getJavaMap()
Return a java.util.Collection of these Objects.



Copyright (c) 2000, 2001, David Walend