CSE 222 Lab #3


Objectives

The Problem

The problem is to complete and carefully test implementations of all the operations of abstract template Partial_Map_Kernel, building the data structure representing a Partial_Map object by layering it on top of abstract templates Array_Kernel, Queue_Kernel, and Record. The algorithmic approach is to use hashing to immediately narrow every search to a much smaller Queue than would otherwise be encountered.

Method

Here's what to do:

The Initialize operation is a new one. Its purpose is to construct the representation for an initial value of a Partial_Map object (which is an empty set). Initialize is an operation that you never call explicitly; all calls to it are inserted automatically by the C++ compiler at the appropriate places. But for this case, unlike previous examples of kernel implementations, you do have to write a body for it. The reason is that before Initialize executes, C++ has automatically initialized, to their respective initial values, the fields of the Representation record. If automatic initialization of these fields happens to result in the representation of an initial value of the type being implemented then you don't need to write any code for Initialize. That has been the situation in the previous implementation examples you've done. But here, the representation of an empty Partial_Map object must have the bounds of the Array field (called hash_table) set to 0 and hash_table_size-1, respectively; by default they are initially 1 and 0. Therefore, you need to put (only) the following code into the body of Initialize:

self[hash_table].Set_Bounds (0, hash_table_size-1);

Possible Maintenance Activities

Here are some questions about possible maintenance activities involving this program: Any extra work is strictly optional, for your own benefit, and will not directly affect your grade.