skip to main content
article
Free Access

A model C++ tree iterator class for binary search trees

Published:01 March 1997Publication History
Skip Abstract Section

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.

References

  1. 1 Cline, Marshall P. and Lomow, Greg A., C++ FAQS: Frequently Asked Questions, Addison-Wesley, Reading, MA, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. 2 Coplien, James O., Advanced C++ Programming Styles and idioms, Addison-Wesley, Reading, MA, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. 3 Eckel, Bruce, Thinking in C++, Prentice Hall, Englewood Cliffs, NJ, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. 4 Ellis, Margaret A. and Stroustrup, Bjarne, The Annotated C++ Reference Manual, ANSI Base Document, Addison-Wesley, Reading, MA, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. 5 Murray, Robert B., C++ Strategies and Tactics, Addison-Wesley, Reading, MA, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. 6 Meyers, Scott, Effective C++: 50 Specific Ways to Improve Your Programs and Designs, Addison-Wesley, Reading, MA, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. 7 Musser, David and Saini, Atul, STL Tutorial a~rl Reference Guide: C++ Programming with the Standard Template Library, Addison-Wesley, Reading, MAt 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 8 Stroustrup, Bjarne, The C++ Programmh~g Language, 2nd Edition, Addison-Wesley, Reading, MA, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. 9 Stroustrup, Bjarne, The Design and Evolution of 6'++, Addison-Wesley, Reading, MA, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. A model C++ tree iterator class for binary search trees

          Recommendations

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in

          Full Access

          • Published in

            cover image ACM SIGCSE Bulletin
            ACM SIGCSE Bulletin  Volume 29, Issue 1
            March 1997
            388 pages
            ISSN:0097-8418
            DOI:10.1145/268085
            Issue’s Table of Contents
            • cover image ACM Conferences
              SIGCSE '97: Proceedings of the twenty-eighth SIGCSE technical symposium on Computer science education
              March 1997
              410 pages
              ISBN:0897918894
              DOI:10.1145/268084

            Copyright © 1997 ACM

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 1 March 1997

            Check for updates

            Qualifiers

            • article

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader
          About Cookies On This Site

          We use cookies to ensure that we give you the best experience on our website.

          Learn more

          Got it!