deleteNode...

i need to replace
victim.erase( -> victim.deleteNode(


#include <algorithm>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <string>
#include <vector>
#include "linkedList.h"
#include "orderedLinkedList.h"
#include "unorderedLinkedList.h"

using namespace std;
template <typename T>

void show(const list<T>& elts, unsigned fwidth = 2, ostream& sout = cout) // victims.erase(it); - > victims.deleteNode(*it);
{ //pg 297
for (int elt : elts)
sout << setw(fwidth) << elt << ' ';
sout << endl;
}

void kill(list<unsigned>& victims)
{

unsigned killcount = 1;
list<unsigned>::iterator it = victims.begin();
while (victims.size() > 2)
{
if (killcount == 3)
{
list<unsigned>::iterator dit = it;
it++;
victims.erase(it);
killcount = 1;
show(victims);
}
else
{
it++;
killcount++;
}
if (it == victims.end()) it = victims.begin();

}
}

void load(list<unsigned>& victims)
{
unsigned id = 1;
for (list<unsigned>::iterator it = victims.begin(); it != victims.end(); it++)
*it = id++;
}


int main()
{
list<unsigned> victims(41);
load(victims);
show(victims);
kill(victims);
system("pause");
return 0;
}
your question is very vague with a lot of info in the header files not shared. either post everything or pare down your question to a self-contained unit
Topic archived. No new replies allowed.