10#include "wvlinklist.h"
12WvLink::WvLink(
void *_data,
WvLink *prev,
WvLink *&tail,
bool _autofree,
17 if (!next) tail =
this;
29 for (l = head.next; l; l = l->next)
37 WvLink *prev, *curr, *next;
39 if (!head.next || !head.next->next)
61 if (link->data == data)
70 if (link->data == data)
73 for (rewind(); next(); )
74 if (link->data == data)
82static WvListBase::SorterBase::CompareFunc *actual_compare = NULL;
84static int magic_compare(
const void *_a,
const void *_b)
87 return actual_compare(a->data, b->data);
90void WvListBase::SorterBase::rewind(CompareFunc *cmp)
96 int n = list->count();
97 array =
new WvLink * [n+1];
105 for (i.rewind(); i.next(); )
115 CompareFunc *old_compare = actual_compare;
116 actual_compare = cmp;
117 qsort(array, n,
sizeof(
WvLink *), magic_compare);
118 actual_compare = old_compare;
WvLink is one element of a WvList<T>.
void rewind()
Rewinds the iterator to make it point to an imaginary element preceeding the first element of the lis...
WvLink * find_next(const void *data)
Repositions the iterator over the element that matches the specified value.
WvLink * next()
Moves the iterator along the list to point to the next element.
WvLink * find(const void *data)
Rewinds the iterator and repositions it over the element that matches the specified value.
void reverse()
Reverses the order of elements in the list.
size_t count() const
Returns the number of elements in the list.