CITS2200
Interface Map


public interface Map

Interface for a Map ADT


Method Summary
 void assign(Object d, Object c)
          assign an image for a domain object.
 Object deassign(Object d)
          if an image is defined for the domain object deassign it (that is, remove the pair from the Map) and return the image, otherwise throw an exception.
 Object image(Object d)
          return the image of a domain object if defined, otherwise throw an exception.
 boolean isDefined(Object d)
          check if a codomain image is defined for a domain object
 boolean isEmpty()
          check if the map is empty
 

Method Detail

isEmpty

boolean isEmpty()
check if the map is empty

Returns:
true if the map contains no assignments, false otherwise

isDefined

boolean isDefined(Object d)
check if a codomain image is defined for a domain object

Parameters:
d - the domain object
Returns:
true if an image is defined, false otherwise

assign

void assign(Object d,
            Object c)
assign an image for a domain object. If the object already has an image, replace the image with the new image, otherwise add a new object-image pair.

Parameters:
d - the domain object
c - the codomain image

image

Object image(Object d)
             throws ItemNotFound
return the image of a domain object if defined, otherwise throw an exception.

Parameters:
d - the domain object
Returns:
the image
Throws:
ItemNotFound - if no image exists for this object

deassign

Object deassign(Object d)
                throws ItemNotFound
if an image is defined for the domain object deassign it (that is, remove the pair from the Map) and return the image, otherwise throw an exception.

Parameters:
d - the domain object
Returns:
the codomain image
Throws:
ItemNotFound - if the object has no image