#include <clst.h>
List of all members.
Detailed Description
Definition at line 70 of file clst.h.
Constructor & Destructor Documentation
CLIST::CLIST |
( |
| ) |
[inline] |
CLIST::~CLIST |
( |
| ) |
[inline] |
Member Function Documentation
bool CLIST::add_sorted |
( |
int |
comparatorconst void *, const void *, |
|
|
bool |
unique, |
|
|
void * |
new_data |
|
) |
| |
Definition at line 199 of file clst.cpp.
{
if (last == NULL || comparator(&last->data, &new_data) < 0) {
CLIST_LINK* new_element = new CLIST_LINK;
new_element->data = new_data;
if (last == NULL) {
new_element->next = new_element;
} else {
new_element->next = last->next;
last->next = new_element;
}
last = new_element;
return true;
} else if (!unique || last->data != new_data) {
CLIST_ITERATOR it(this);
for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
void* data = it.data();
if (data == new_data && unique)
return false;
if (comparator(&data, &new_data) > 0)
break;
}
if (it.cycled_list())
it.add_to_end(new_data);
else
it.add_before_then_move(new_data);
return true;
}
return false;
}
Definition at line 109 of file clst.cpp.
{
const ERRCODE LIST_NOT_EMPTY =
"Destination list must be empty before extracting a sublist";
#ifndef NDEBUG
if (!this)
NULL_OBJECT.error ("CLIST::assign_to_sublist", ABORT, NULL);
#endif
if (!empty ())
LIST_NOT_EMPTY.error ("CLIST.assign_to_sublist", ABORT, NULL);
last = start_it->extract_sublist (end_it);
}
bool CLIST::empty |
( |
| ) |
const [inline] |
void CLIST::internal_deep_clear |
( |
void(*)(void *) |
zapper | ) |
|
inT32 CLIST::length |
( |
| ) |
const |
void CLIST::set_subtract |
( |
int |
comparatorconst void *, const void *, |
|
|
bool |
unique, |
|
|
CLIST * |
minuend, |
|
|
CLIST * |
subtrahend |
|
) |
| |
Definition at line 237 of file clst.cpp.
{
shallow_clear();
CLIST_ITERATOR m_it(minuend);
CLIST_ITERATOR s_it(subtrahend);
for (m_it.mark_cycle_pt(); !m_it.cycled_list(); m_it.forward()) {
void* minu = m_it.data();
void* subtra = NULL;
if (!s_it.empty()) {
subtra = s_it.data();
while (!s_it.at_last() &&
comparator(&subtra, &minu) < 0) {
s_it.forward();
subtra = s_it.data();
}
}
if (subtra == NULL || comparator(&subtra, &minu) != 0)
add_sorted(comparator, unique, minu);
}
}
void CLIST::shallow_clear |
( |
| ) |
|
void CLIST::shallow_copy |
( |
CLIST * |
from_list | ) |
[inline] |
Definition at line 103 of file clst.h.
{
last = from_list->last;
}
bool CLIST::singleton |
( |
| ) |
const [inline] |
void CLIST::sort |
( |
int |
comparatorconst void *, const void * | ) |
|
Definition at line 155 of file clst.cpp.
{
CLIST_ITERATOR it(this);
inT32 count;
void **base;
void **current;
inT32 i;
#ifndef NDEBUG
if (!this)
NULL_OBJECT.error ("CLIST::sort", ABORT, NULL);
#endif
count = length ();
base = (void **) malloc (count * sizeof (void *));
current = base;
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
*current = it.extract ();
current++;
}
qsort ((char *) base, count, sizeof (*base), comparator);
current = base;
for (i = 0; i < count; i++) {
it.add_to_end (*current);
current++;
}
free(base);
}
Friends And Related Function Documentation
The documentation for this class was generated from the following files: