Case Study: Immutable Finite Functions, Part 1

In this case study, we design and implement an immutable abstract data type of finite functions.

The IMap<K,V> interface extends the Map<K,V> interface defined in Java's java.util package. That is possible only because all operations of the Map<K,V> interface that have side effects are optional: classes that implement those optional operations are allowed to implement them by defining methods that throw an UnsupportedOperationException if those methods are ever called.

Our first implementation of the IMap<K,V> interface relies on inheritance by extending two abstract base classes defined in Java's java.util package: AbstractMap<K,V> and AbstractSet<K,V>.


Creative Commons License © Mitchell Wand, 2012-2015
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
The work has been modified by William D Clinger in these ways and more: conversion from PowerPoint to HTML, and from Racket to Java.

For debugging: Click here to validate.