1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
//Author: Chris ******
//Date: 4/20/2011
//Purpose: header file for closed lab 11: list container
#include <iostream>
#include <vector>
#ifndef LIST
#define LIST
using namespace std;
template <typename T>
class List
{
public:
void InputList(ostream & out, list<T> & L);
void fillIn(const list<T> & L, vector<T>& V);
void changeValue(const list<T> & L, T item1, T item2);
private:
const List<T>& L;
const vector<T>& V;
};
//end of class declaration
//Definition of void inputList
template <typename T>
void List<T>::InputList(ostream & out, const list<T> & L)
{
ifstream in;
while (in.open() || !in.eof())
{
for (int i = 0; i != in.eof(); i++)
{
L[i];
L.push_back(i);
}
}
return out;
}
//Definition of FillIn()
template <typename T>
void List::fillIn(const list<T>& L, vector<T> & V)
{
for (int i = 0; i < L.end(); i++)
{
L[V[i]];
L.push_back(v[i]);
}
}
//Definition of changeValue
template <typename T>
void List::changeValue(const list<T>& L, T item1, T item2)
{
double item1, item2;
cout << "Enter values to swap: ";
cin >> item1 >> item2;
double found1 = find(L.begin(), L.end(), item1);
double found2 = find(L.begin(), L.end(), item2);
while (!empty())
{
L.insert(found1, 1, found2);
L.erase(found);
}
cout << "Swapped " << found1 << "with " << found2 << endl;
}
#endif
| |