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

Constructor, Length Property, and Purge Methods

Program gif defines the constructor, Length property, and Purge methods of the OpenScatterTable class. The OpenScatterTable constructor takes a single argument which specifies the size of scatter table desired. It creates an array of the desired length and initializes each element of the array by assigning to it an new Entry instance. Consequently, the running time for the OpenScatterTable constructor is O(M) where M is the size of the scatter table.

   program13309
Program: OpenScatterTable class constructor, Length property, and Purge methods.

The Length property provides a get accessor that returns the length of the array field. Clearly, its running time is O(1).

The Purge method empties the scatter table by nulling out all the Entrys in the array. The time required to purge the scatter table is O(M), where M is the length of the table.


next up previous contents index

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