Data Structures and Algorithms with Object-Oriented Design Patterns in C#
next up previous contents index

Implementation

This section describes an implementation of a scatter table using open addressing with linear probing. Program gif introduces the OpenScatterTable class. The OpenScatterTable class extends the AbstractHashTable class introduced in Program gif. The scatter table is implemented as an array of elements of the nested struct Entry. Each Entry instance has two fields--obj and state. The former is refers to a ComparableObject. The latter is an EntryState enum the value of which is either EMPTY, OCCUPIED or DELETED.

   program13284
Program: OpenScatterTable fields, OpenScatterTable.EntryState enum, and OpenScatterTable.Entry struct.

Initially, all entries are empty. When an object recorded in an entry, the state of that entry is changed to OCCUPIED. The purpose of the third state, DELETED, will be discussed in conjunction with the Withdraw method below.




next up previous contents index

Bruno Copyright © 2001 by Bruno R. Preiss, P.Eng. All rights reserved.