listtools

listtools - Iterator:Iterator position = NULL last = NULL...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/** @file listtools.cpp @author William Duncan @date 2005-10-01 Description: implementation for the listtools interface Course: CS1254.02 Logon ID: cs1254xx Lab #: 5 Instructor: William Duncan */ /* YOUR TASK: templatize these functions so that they work with any type. As defined, they work with only string. Your templatization must conform to the interfaces provided in listtools.h after you templatize both classes. */ #include "listtools.h" Node::Node(string s) { data = s; previous = NULL; next = NULL;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } Iterator::Iterator() { position = NULL; last = NULL; } string Iterator::get() const { assert(position != NULL); return position->data; } void Iterator::next() { assert(position != NULL); position = position->next; } void Iterator::previous() { if (position == NULL) position = last; else position = position->previous; assert(position != NULL); } bool Iterator::equals(Iterator b) const { return position == b.position; } // end listtools.cpp...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online