D
deneb.dizajn
I'm writing this sorting just to understand how exactly works methods
in CObList. Iteration works fine, but it won't change pointers.
CObList myList;
CPerson* first, second;
POSITION next, position;
int size = myList.GetCount();
for (int i = 0; i < size; i++) {
for (position = myList.GetHeadPosition(); next != NULL
{
first = (CPerson*)myList.GetNext(position);
next = position;
second = (CPerson*)myList.GetNext(next);
if (first->get_Number() > second->get_Number())
{
temp = first;
myList.SetAt(position, second);
myList.SetAt(next, temp);
}
}
}
Thanks!
in CObList. Iteration works fine, but it won't change pointers.
CObList myList;
CPerson* first, second;
POSITION next, position;
int size = myList.GetCount();
for (int i = 0; i < size; i++) {
for (position = myList.GetHeadPosition(); next != NULL
{
first = (CPerson*)myList.GetNext(position);
next = position;
second = (CPerson*)myList.GetNext(next);
if (first->get_Number() > second->get_Number())
{
temp = first;
myList.SetAt(position, second);
myList.SetAt(next, temp);
}
}
}
Thanks!