Project2_Q2 -...

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

View Full Document Right Arrow Icon
#include<iostream> #include<string> #include<fstream> using namespace std; u #define MAX_ITEMS 10 typedef float ItemType; t class SortedList { private: int length; ItemType values[MAX_ITEMS]; int currentPos; public: SortedList(); // default constructor: lenght=0, currentPos=-1 void MakeEmpty(); // let length=0 void InsertItem(ItemType x); // insert x into the list void DeleteItem(ItemType x); // delete x from the list bool IsFull( ); // test if the list is full int LengthIs( ); // return length void RetrieveItem(ItemType x, bool &found); // retrieve x from the list, the // boolean result is stored in found void ResetList( ); // currentPos=-1 void GetNextItem(ItemType &x); // get the next element from the list with // respect to the currentPos }; } SortedList::SortedList() { length = 0; currentPos = -1; } void SortedList::MakeEmpty() { length = 0; } void SortedList::InsertItem(ItemType item) { bool moreToSearch; int location = 0; moreToSearch = (location < length); while(moreToSearch) { if(item < values[location])
Background image of page 1

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

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

This note was uploaded on 04/25/2010 for the course CECS CIS 200 taught by Professor Jieshen during the Winter '08 term at University of Michigan-Dearborn.

Page1 / 4

Project2_Q2 -...

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