list - Node* remove = iter.position; Node* before =...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/** @file list.cpp @author William Duncan @date 2005-10-01 Description: implementation for the complex class Course: CS1254.02 Logon ID: cs1254xx Lab #: 5 Instructor: William Duncan */ /* YOUR TASK: templatize these functions so that they conform to the interface provided in list.h after you templatize the list class. Two of the functions have not been completed. You will complete the definitions of those functions in the function stubs provided. */ #include "list.h" List::List() { first = NULL; last = NULL; length = 0; } void List::insert(string s) { /* YOUR TASK: implement this function so that it inserts s in the correct position in a sorted list. Assume that <, >, <=, >=, == and != are all overloaded for whatever abitrary type is used after templatization. */ } Iterator List::erase(Iterator i) { Iterator iter = i; assert(iter.position != NULL);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Node* remove = iter.position; Node* before = remove-&gt;previous; Node* after = remove-&gt;next; if (remove == first) first = after; else before-&gt;next = after; if (remove == last) last = before; else after-&gt;previous = before; iter.position = after; delete remove; length--; return iter; } Iterator List::erase(string s) { /* YOUR TASK: implement this function so that it inserts s in the correct position in a sorted list. Assume that &lt;, &gt;, &lt;=, &gt;=, == and != are all overloaded for whatever abitrary type is used after templatization. */ } Iterator List::begin() { Iterator iter; iter.position = first; iter.last = last; return iter; } Iterator List::end() { Iterator iter; iter.position = NULL; iter.last = last; return iter; } long List::size() const { return length; } // end list.cpp...
View Full Document

This note was uploaded on 01/17/2012 for the course CSC 1254 taught by Professor Blanks,l during the Fall '08 term at LSU.

Page1 / 2

list - Node* remove = iter.position; Node* before =...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online