A model C++ tree iterator class for binary search trees
- 1 March 1997
- journal article
- Published by Association for Computing Machinery (ACM) in ACM SIGCSE Bulletin
- Vol. 29 (1) , 72-76
- https://doi.org/10.1145/268085.268114
Abstract
In object-oriented design, the concept of a container class that holds a collection of similar objects is fundamental. To use a container class most effectively, it is helpful to define one or more associated iterator classes that can return the objects in the container class in a specified order. An iterator is a bridge that permits the caller to use the objects in a container without knowledge of the details of how the objects are stored in the container. Although the concept of iterator is discussed in a number of books on C++ and/or object-oriented design, it is difficult to find a complete example that is both elegant and sophisticated. In this article, we provide such an example by developing an iterator class for binary search trees that is capable of doing all standard traversals: inorder, preorder, and postorder.This publication has 0 references indexed in Scilit: