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

Constructor and Destructor

Program gif defines the QueueAsLinkedList constructor and destructor functions. 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).

   program7327
Program: QueueAsLinkedList Class Constructor, Destructor and Purge Member Function Definitions

The QueueAsLinkedList destructor simply calls the Purge member function The Purge function deletes the contained objects one-by-one by traversing the linked list. Assuming that the running time of the destructor for each the contained objects is a constant, the total running time for the QueueAsLinkedList destructor is O(n), where tex2html_wrap_inline61308 is the number of items in the queue.


next up previous contents index

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