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

Constructor and Purge Methods

Program gif defines the QueueAsLinkedList constructor and Purge methods. In the case of the linked list implementation, it is not necessary to preallocate storage. The constructor simply initializes the list object as an empty list. The running time of the constructor is O(1).

   program6801
Program: QueueAsLinkedList class constructor and Purge methods.

The Purge method empties the queue by invoking the Purge method provided by the LinkedList class and then sets the count field to zero. Since a linked-list can be purged in constant time, the total running time for the Purge method is O(1).


next up previous contents index

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