#include <clst.h>
List of all members.
Detailed Description
Definition at line 70 of file clst.h.
Constructor & Destructor Documentation
Member Function Documentation
bool CLIST::add_sorted |
( |
int |
comparatorconst void *, const void *, |
|
|
bool |
unique, |
|
|
void * |
new_data |
|
) |
| |
Definition at line 198 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 108 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);
}
Definition at line 41 of file clst.cpp.
{
CLIST_LINK *ptr;
CLIST_LINK *next;
#ifndef NDEBUG
if (!this)
NULL_OBJECT.error ("CLIST::internal_deep_clear", ABORT, NULL);
#endif
if (!empty ()) {
ptr = last->next;
last->next = NULL;
last = NULL;
while (ptr) {
next = ptr->next;
zapper (ptr->data);
delete(ptr);
ptr = next;
}
}
}
Definition at line 132 of file clst.cpp.
{
CLIST_ITERATOR it(const_cast<CLIST*>(this));
inT32 count = 0;
#ifndef NDEBUG
if (!this)
NULL_OBJECT.error ("CLIST::length", ABORT, NULL);
#endif
for (it.mark_cycle_pt(); !it.cycled_list(); it.forward())
count++;
return count;
}
Definition at line 236 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);
}
}
Definition at line 74 of file clst.cpp.
{
CLIST_LINK *ptr;
CLIST_LINK *next;
#ifndef NDEBUG
if (!this)
NULL_OBJECT.error ("CLIST::shallow_clear", ABORT, NULL);
#endif
if (!empty ()) {
ptr = last->next;
last->next = NULL;
last = NULL;
while (ptr) {
next = ptr->next;
delete(ptr);
ptr = next;
}
}
}
Definition at line 103 of file clst.h.
{
last = from_list->last;
}
Definition at line 99 of file clst.h.
{
return last != NULL ? (last == last->next) : false;
}
void CLIST::sort |
( |
int |
comparatorconst void *, const void * | ) |
|
Definition at line 154 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:
- /usr/local/google/home/jbreiden/tesseract-ocr-read-only/ccutil/clst.h
- /usr/local/google/home/jbreiden/tesseract-ocr-read-only/ccutil/clst.cpp