Project 2: ConstIterator and ReverseIterator

Open for comment in the discussion forum.

Educational Objectives: After completion of this assignment, the student should be able to accomplish the following:

Background Knowledge Required: Be sure that you have mastered the material in these chapters before beginning the project: Templates , Positional Containers , Algorithm Complexity , ADTs: Stack and Queue , Function Classes and Objects , Iterators , Generic Algorithms , and Lists .

Operational Objectives: Create files constiter.h and reviter.h that contain class templates adapting any X::Iterator into X::ConstIterator and X::ReverseIterator, respectively, conforming to the type definitions in the files vector_fast_reverse.h, vector_safe_reverse.h, deque_reverse.h and list_reverse.h. (These files are in LIB/tcpp, where LIB = ~cop5517p/spring12.)

Deliverables: Five code files:

constiter.h         # ConstRAIterator
reviter.h           # ReverseRRAIterator
vector_reverse.cpp  # implements Vector reverse iterator support
deque_reverse.cpp   # implements Deque reverse iterator support
list_reverse.cpp    # implements List reverse iterator support
Plus report.pdf submitted to Blackboard.

Procedural Requirements:

  1. Copy the files LIB/proj2/* into your working directory.

  2. Create your files constiter.h and reviter.h containing the class templates ConstRAIterator<I> and ReverseRAIterator<I>, respectively.

  3. One container at a time (starting with fsu::List), create files list_reverse.cpp, deque_reverse.cpp, and vector_reverse.cpp that implement the container support for reverse iterators. Note that the Vector case is the most complex and subtle, because this one file must support two different versions: fsu::fast::Vector and fsu::safe::Vector.

  4. Test as you create, using fConstIter.cpp, fConstReverseIter.cpp, fTraverse.cpp, and fTraverseReverse.cpp (appropriately configured).

  5. When all containers are supported, test again with fConstIter5.cpp, fConstReverseIter4.cpp, fTraverse5.cpp, and fTraverseReverse4.cpp. You may want to create several more test clients by copying and modifying the ones that are distributed in LIB/tests for the basic containers (fvector.cpp, fdeque.cpp, flist.cpp, mlist.cpp.

  6. Write a report on your work and findings submitted as report.pdf.

  7. Turn in the five code files using the proj2submit.sh submit script.

    Warning: Submit scripts do not work on the program and linprog servers. Use shell.cs.fsu.edu to submit projects. If you do not receive the second confirmation with the contents of your project, there has been a malfunction.

  8. Turn in your report to Blackboard.

Technical Requirements and Specifications

  1. Conform to the system of slave files as defined in the main header files.
    1. The last few lines of list_reverse.h:
      ...
      #include <list.cpp>           // basic list implementations
      #include <list_reverse.cpp>   // added functionality for reverse iterators
      } // namespace fsu
      #endif
      
      which shows that the bulk of implementation of List and List::Iterator is re-used. Only the added functionality is implemented in list_reverse.cpp.
    2. The last few lines of deque_reverse.h:
      ...
      #include <deque.cpp>          // basic deque implementations
      #include <deque_reverse.cpp>  // added functionality for reverse iterators
      } // namespace fsu
      #endif
      
      which shows that the bulk of implementation of Deque and Deque::Iterator is re-used. Only the added functionality is implemented in deque_reverse.cpp.
    3. The last few lines of vector_fast_reverse.h:
      ...
      #include <vector_base.cpp>    // basic vector implementations
      #include <vector_fast.cpp>    // fast iterator implementations
      #include <vector_reverse.cpp> // reverse iterator implementations
      }}   // namespace fsu::fast
      #endif
      
      and the last few lines of vector_safe_reverse.h:
      ...
      #include <vector_base.cpp>    // basic vector implementations
      #include <vector_safe.cpp>    // safe iterator implementations
      #include <vector_reverse.cpp> // reverse iterator implementations
      }}   // namespace fsu::safe
      #endif
      
      which shows that the bulk of implementation of fast::Vector and safe::Vector are re-used from vector_base.cpp, vector_fast.cpp, and vector_safe.cpp (all of which are library files). This also shows that fast::Vector and safe::Vector share the same code for supporting reverse iterators! This code (which you supply) is in vector_reverse.cpp.

  2. Be sure that your project builds without any of the library files (other than tests) copied to the project directory.

Hints