Quote Originally Posted by babaliaris View Post
I fixed the remove method. (Yes I wasn't handling the disconnection of the deleted node from the list).

Well about the for loop, it works if the size does not change. if you do something like this:
Code:
for (int i = 0; i < list.size; i++)
{
    list.pop_front();
}
it will cause bugs, because in each pop the size changes. But the same thing happens if you use an std::vector.

So this is why I prefer doing something like this:
Code:
while (list.notEmpty())
    list.pop_front();
Or if I want to go through all the elements of the list and remove some of them.

Code:
//This goes through the list untill it finds the tail of the list.
while (list.hasNext())
{
    if (condition)
        list.remove(remove_somthing_here);
}
If you do this like this:
Code:
for (int i = 0; i < list.size; i++)
{
    if (condition)
        list.remove(remove_somthing_here);
}
This will break since the size changes as I remove stuff. It will probably cause an overflow.
You need to cycle through the list using an enumerator if you wish to remove items. See the std::list<> implementation.