EssaysForStudent.com - Free Essays, Term Papers & Book Notes
Search

Baseball

By:   •  Study Guide  •  949 Words  •  January 7, 2010  •  930 Views

Page 1 of 4

Join now to read essay Baseball

#include

#include

#include

using namespace std;

class List;

class Iterator;

class Node

{

public:

/*

Constructs a node with a given data value.

@param s the data to store in this node

*/

Node(string s);

private:

string data;

Node* previous;

Node* next;

friend class List;

friend class Iterator;

};

class List

{

public:

/**

Constructs an empty list;

*/

List();

/**

Appends an element to the list.

@param s the value to append

*/

void push_back(string s);

/**

Inserts an element into the list.

@param iter the position before which to insert

@param s the value to append

*/

void insert(Iterator iter, string s);

/**

Removes an element from the list.

@param i the position to remove

@return an iterator pointing to the element after the

erased element

*/

Iterator erase(Iterator i);

/**

Gets the beginning position of the list.

@return an iterator pointing to the beginning of the list

*/

Iterator begin();

/**

Gets the past-the-end position of the list.

@return an iterator pointing past the end of the list

*/

Iterator end();

void reverse();

private:

Node* first;

Node* last;

};

class Iterator

{

public:

/**

Constructs an iterator that does not point into any list.

*/

Iterator();

/**

Looks up the value at a position.

@return the value of the node to which the iterator points

*/

string get() const;

/**

Advances the iterator to the next node.

*/

void next();

/**

Moves the iterator to the previous node.

*/

void previous();

/**

Compares two iterators

@param b the iterator to compare with this iterator

@return true if this iterator and b are equal

Download as (for upgraded members)  txt (4.3 Kb)   pdf (108.9 Kb)   docx (12.1 Kb)  
Continue for 3 more pages »