"Fossies" - the Fresh Open Source Software Archive

Member "tesseract-ocr/doc/html/class_e_l_i_s_t.html" (26 Oct 2012, 36481 Bytes) of package /linux/misc/old/tesseract-ocr-3.02.02-doc-html.tar.gz:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the tesseract-ocr-3.02.02-doc-html.tar.gz project site itself.

Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ELIST Class Reference

#include <elst.h>

List of all members.

Public Member Functions

 ELIST ()
void internal_clear (void(*zapper)(ELIST_LINK *))
bool empty () const
bool singleton () const
void shallow_copy (ELIST *from_list)
void internal_deep_copy (ELIST_LINK *(*copier)(ELIST_LINK *), const ELIST *list)
void assign_to_sublist (ELIST_ITERATOR *start_it, ELIST_ITERATOR *end_it)
inT32 length () const
void sort (int comparator(const void *, const void *))
ELIST_LINKadd_sorted_and_find (int comparator(const void *, const void *), bool unique, ELIST_LINK *new_link)
bool add_sorted (int comparator(const void *, const void *), bool unique, ELIST_LINK *new_link)

Friends

class ELIST_ITERATOR

Detailed Description

Definition at line 114 of file elst.h.


Constructor & Destructor Documentation

ELIST::ELIST ( )
inline

Definition at line 125 of file elst.h.

{ //constructor
}

Member Function Documentation

bool ELIST::add_sorted ( int   comparatorconst void *, const void *,
bool  unique,
ELIST_LINK new_link 
)
inline

Definition at line 175 of file elst.h.

{
return (add_sorted_and_find(comparator, unique, new_link) == new_link);
}
ELIST_LINK * ELIST::add_sorted_and_find ( int   comparatorconst void *, const void *,
bool  unique,
ELIST_LINK new_link 
)

Definition at line 173 of file elst.cpp.

{
// Check for adding at the end.
if (last == NULL || comparator(&last, &new_link) < 0) {
if (last == NULL) {
new_link->next = new_link;
} else {
new_link->next = last->next;
last->next = new_link;
}
last = new_link;
} else {
// Need to use an iterator.
ELIST_ITERATOR it(this);
for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
ELIST_LINK* link = it.data();
int compare = comparator(&link, &new_link);
if (compare > 0) {
break;
} else if (unique && compare == 0) {
return link;
}
}
if (it.cycled_list())
it.add_to_end(new_link);
else
it.add_before_then_move(new_link);
}
return new_link;
}
void ELIST::assign_to_sublist ( ELIST_ITERATOR start_it,
ELIST_ITERATOR end_it 
)

Definition at line 78 of file elst.cpp.

{ //from list end
const ERRCODE LIST_NOT_EMPTY =
"Destination list must be empty before extracting a sublist";
#ifndef NDEBUG
if (!this)
NULL_OBJECT.error ("ELIST::assign_to_sublist", ABORT, NULL);
#endif
if (!empty ())
LIST_NOT_EMPTY.error ("ELIST.assign_to_sublist", ABORT, NULL);
last = start_it->extract_sublist (end_it);
}
bool ELIST::empty ( ) const
inline

Definition at line 133 of file elst.h.

{ //is list empty?
return !last;
}
void ELIST::internal_clear ( void(*)(ELIST_LINK *)  zapper)

Definition at line 42 of file elst.cpp.

{
//ptr to zapper functn
ELIST_LINK *ptr;
ELIST_LINK *next;
#ifndef NDEBUG
if (!this)
NULL_OBJECT.error ("ELIST::internal_clear", ABORT, NULL);
#endif
if (!empty ()) {
ptr = last->next; //set to first
last->next = NULL; //break circle
last = NULL; //set list empty
while (ptr) {
next = ptr->next;
zapper(ptr);
ptr = next;
}
}
}
void ELIST::internal_deep_copy ( ELIST_LINK *(*)(ELIST_LINK *)  copier,
const ELIST list 
)
inT32 ELIST::length ( ) const

Definition at line 102 of file elst.cpp.

{ // count elements
ELIST_ITERATOR it(const_cast<ELIST*>(this));
inT32 count = 0;
#ifndef NDEBUG
if (!this)
NULL_OBJECT.error ("ELIST::length", ABORT, NULL);
#endif
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
count++;
return count;
}
void ELIST::shallow_copy ( ELIST from_list)
inline

Definition at line 141 of file elst.h.

{ //beware destructors!!
last = from_list->last;
}
bool ELIST::singleton ( ) const
inline

Definition at line 137 of file elst.h.

{
return last ? (last == last->next) : false;
}
void ELIST::sort ( int   comparatorconst void *, const void *)

Definition at line 126 of file elst.cpp.

{
ELIST_ITERATOR it(this);
ELIST_LINK **base; //ptr array to sort
ELIST_LINK **current;
inT32 i;
#ifndef NDEBUG
if (!this)
NULL_OBJECT.error ("ELIST::sort", ABORT, NULL);
#endif
/* Allocate an array of pointers, one per list element */
count = length ();
base = (ELIST_LINK **) malloc (count * sizeof (ELIST_LINK *));
/* Extract all elements, putting the pointers in the array */
current = base;
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
*current = it.extract ();
current++;
}
/* Sort the pointer array */
qsort ((char *) base, count, sizeof (*base), comparator);
/* Rebuild the list from the sorted pointers */
current = base;
for (i = 0; i < count; i++) {
it.add_to_end (*current);
current++;
}
free(base);
}

Friends And Related Function Documentation

friend class ELIST_ITERATOR
friend

Definition at line 116 of file elst.h.


The documentation for this class was generated from the following files: