Hi All,
I'm making a sorted double linked list in the following way:
class Item
{
int time_stamp;
Item * prev;
Item * next;
}
class SortedList ()
{
Item * tail;
Item * head;
}
head should be the smallest item and tail is the largest.
Sorted list constructor:
_tail = new jitter_item () ;
jitter_item * curr = _tail, *tmp ;
for ( int i = 0; i < BUFFER_SIZE -1; i++ )
{
tmp = curr->_next = new jitter_item () ;
tmp->_previous = curr ;
curr = tmp ;
}
curr->_next = _head = new jitter_item ();
Now, my problem is that after the head is used I want to re-use it by making it the new tail and making head->prev the new head. I tried:
tmp1 = _head;
_head = _head->_previous ;
_head->_next = NULL ;
tmp2 = _tail->_next ;
_tail = tmp1;
tmp2->_previous = _tail;
_tail->_next = tmp2;
_tail->_previous = NULL;
But it has a bug.
Can some please help me?
Thanks,
Nahum
SortedList contructor:
