Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Macros | Typedefs | Functions
oldlist.h File Reference
`#include "cutil.h"`
`#include "tesscallback.h"`

Go to the source code of this file.

## Classes
struct | list_rec

## Macros
#define | NIL_LIST (LIST) 0
#define | list_rest(l) ((l) ? (l)->next : NIL_LIST)
#define | first_node(l) ((l) ? (l)->node : NIL_LIST)
#define | copy_first(l1, l2) (l2=push(l2, first_node(l1)))
#define | iterate(l) for (; (l) != NIL_LIST; (l) = list_rest (l))
#define | iterate_list(x, l) for ((x)=(l); (x)!=0; (x)=list_rest(x))
#define | JOIN_ON(list1, list2) ((list1) = join ((list1), (list2)))
#define | pop_off(list) ((list) = pop (list))
#define | push_on(list, thing) ((list) = push (list, (LIST) (thing)))
#define | second_node(l) first_node (list_rest (l))
#define | set_rest(l, cell) ((l)->next = (cell))
#define | third(l) first_node (list_rest (list_rest (l)))

## Typedefs
typedef list_rec * | LIST

## Functions
int | count (LIST var_list)
LIST | delete_d (LIST list, void *key, int_compare is_equal)
LIST | delete_d (LIST list, void *key, TessResultCallback2< int, void *, void * > *is_equal)
LIST | destroy (LIST list)
void | destroy_nodes (LIST list, void_dest destructor)
void | insert (LIST list, void *node)
int | is_same_node (void *item1, void *item2)
int | is_same (void *item1, void *item2)
LIST | join (LIST list1, LIST list2)
LIST | last (LIST var_list)
void * | nth_cell (LIST var_list, int item_num)
LIST | pop (LIST list)
LIST | push (LIST list, void *element)
LIST | push_last (LIST list, void *item)
LIST | reverse (LIST list)
LIST | reverse_d (LIST list)
LIST | s_adjoin (LIST var_list, void *variable, int_compare compare)
LIST | search (LIST list, void *key, int_compare is_equal)
LIST | search (LIST list, void *key, TessResultCallback2< int, void *, void * > *)

## Macro Definition Documentation

#define copy_first | ( |  | l1,
|  |  | l2
| ) |  | (l2=push(l2, first_node(l1)))

Definition at line 149 of file oldlist.h.

#define first_node | ( |  | l | ) | ((l) ? (l)->node : NIL_LIST)

Definition at line 139 of file oldlist.h.

#define iterate | ( |  | l | ) | for (; (l) != NIL_LIST; (l) = list_rest (l))

Definition at line 159 of file oldlist.h.

#define iterate_list | ( |  | x,
|  |  | l
| ) |  | for ((x)=(l); (x)!=0; (x)=list_rest(x))

Definition at line 170 of file oldlist.h.

#define JOIN_ON | ( |  | list1,
|  |  | list2
| ) |  | ((list1) = join ((list1), (list2)))

Definition at line 180 of file oldlist.h.

#define list_rest | ( |  | l | ) | ((l) ? (l)->next : NIL_LIST)

Definition at line 138 of file oldlist.h.

#define NIL_LIST (LIST) 0

Definition at line 126 of file oldlist.h.

#define pop_off | ( |  | list | ) | ((list) = pop (list))

Definition at line 190 of file oldlist.h.

#define push_on | ( |  | list,
|  |  | thing
| ) |  | ((list) = push (list, (LIST) (thing)))

Definition at line 200 of file oldlist.h.

#define second_node | ( |  | l | ) | first_node (list_rest (l))

Definition at line 211 of file oldlist.h.

#define set_rest | ( |  | l,
|  |  | cell
| ) |  | ((l)->next = (cell))

Definition at line 222 of file oldlist.h.

#define third | ( |  | l | ) | first_node (list_rest (list_rest (l)))

Definition at line 233 of file oldlist.h.

## Typedef Documentation

typedef list_rec* LIST

Definition at line 132 of file oldlist.h.

## Function Documentation

int count | ( | LIST | var_list | ) |

Definition at line 108 of file oldlist.cpp.

{
int temp = 0;
iterate (var_list) temp += 1;
return (temp);
}

LIST delete_d | ( | LIST | list,
|  | void * | key,
|  | int_compare | is_equal
| ) |  |

Definition at line 125 of file oldlist.cpp.

{
LIST result = NIL_LIST;
LIST last_one = NIL_LIST;
if (is_equal == NULL)
is_equal = is_same;
while (list != NIL_LIST) {
if (!(*is_equal) (first_node (list), key)) {
if (last_one == NIL_LIST) {
last_one = list;
list = list_rest (list);
result = last_one;
set_rest(last_one, NIL_LIST);
}
else {
set_rest(last_one, list);
last_one = list;
list = list_rest (list);
set_rest(last_one, NIL_LIST);
}
}
else {
list = pop (list);
}
}
return (result);
}

LIST delete_d | ( | LIST | list,
|  | void * | key,
|  | TessResultCallback2< int, void *, void * > * | is_equal
| ) |  |

Definition at line 154 of file oldlist.cpp.

{
LIST result = NIL_LIST;
LIST last_one = NIL_LIST;
while (list != NIL_LIST) {
if (!(*is_equal).Run (first_node (list), key)) {
if (last_one == NIL_LIST) {
last_one = list;
list = list_rest (list);
result = last_one;
set_rest(last_one, NIL_LIST);
}
else {
set_rest(last_one, list);
last_one = list;
list = list_rest (list);
set_rest(last_one, NIL_LIST);
}
}
else {
list = pop (list);
}
}
return (result);
}

LIST destroy | ( | LIST | list | ) |

Definition at line 187 of file oldlist.cpp.

{
LIST next;
while (list != NIL_LIST) {
next = list_rest (list);
free_cell(list);
list = next;
}
return (NIL_LIST);
}

void destroy_nodes | ( | LIST | list,
|  | void_dest | destructor
| ) |  |

Definition at line 204 of file oldlist.cpp.

{
if (destructor == NULL)
destructor = memfree;
while (list != NIL_LIST) {
(*destructor) (first_node (list));
list = pop (list);
}
}

void insert | ( | LIST | list,
|  | void * | node
| ) |  |

Definition at line 221 of file oldlist.cpp.

{
LIST element;
if (list != NIL_LIST) {
element = push (NIL_LIST, node);
set_rest (element, list_rest (list));
set_rest(list, element);
node = first_node (list);
list->node = first_node (list_rest (list));
list->next->node = (LIST) node;
}
}

int is_same | ( | void * | item1,
|  | void * | item2
| ) |  |

Definition at line 252 of file oldlist.cpp.

{
return (!strcmp ((char *) item1, (char *) item2));
}

int is_same_node | ( | void * | item1,
|  | void * | item2
| ) |  |

Definition at line 241 of file oldlist.cpp.

{
return (item1 == item2);
}

LIST join | ( | LIST | list1,
|  | LIST | list2
| ) |  |

Definition at line 264 of file oldlist.cpp.

{
if (list1 == NIL_LIST)
return (list2);
set_rest (last (list1), list2);
return (list1);
}

LIST last | ( | LIST | var_list | ) |

Definition at line 277 of file oldlist.cpp.

{
while (list_rest (var_list) != NIL_LIST)
var_list = list_rest (var_list);
return (var_list);
}

void* nth_cell | ( | LIST | var_list,
|  | int | item_num
| ) |  |

Definition at line 289 of file oldlist.cpp.

{
int x = 0;
iterate(var_list) {
if (x++ == item_num)
return (var_list);
}
return (var_list);
}

LIST pop | ( | LIST | list | ) |

Definition at line 305 of file oldlist.cpp.

{
LIST temp;
temp = list_rest (list);
if (list != NIL_LIST) {
free_cell(list);
}
return (temp);
}

LIST push | ( | LIST | list,
|  | void * | element
| ) |  |

Definition at line 323 of file oldlist.cpp.

{
LIST t;
t = new_cell ();
t->node = (LIST) element;
set_rest(t, list);
return (t);
}

LIST push_last | ( | LIST | list,
|  | void * | item
| ) |  |

Definition at line 338 of file oldlist.cpp.

{
LIST t;
if (list != NIL_LIST) {
t = last (list);
t->next = push (NIL_LIST, item);
return (list);
}
else
return (push (NIL_LIST, item));
}

LIST reverse | ( | LIST | list | ) |

Definition at line 357 of file oldlist.cpp.

{
LIST newlist = NIL_LIST;
iterate (list) copy_first (list, newlist);
return (newlist);
}

LIST reverse_d | ( | LIST | list | ) |

Definition at line 371 of file oldlist.cpp.

{
LIST result = reverse (list);
destroy(list);
return (result);
}

LIST s_adjoin | ( | LIST | var_list,
|  | void * | variable,
|  | int_compare | compare
| ) |  |

Definition at line 384 of file oldlist.cpp.

{
LIST l;
int result;
if (compare == NULL)
compare = (int_compare) strcmp;
l = var_list;
iterate(l) {
result = (*compare) (variable, first_node (l));
if (result == 0)
return (var_list);
else if (result < 0) {
insert(l, variable);
return (var_list);
}
}
return (push_last (var_list, variable));
}

LIST search | ( | LIST | list,
|  | void * | key,
|  | int_compare | is_equal
| ) |  |

Definition at line 413 of file oldlist.cpp.

{
if (is_equal == NULL)
is_equal = is_same;
iterate (list) if ((*is_equal) (first_node (list), key))
return (list);
return (NIL_LIST);
}

LIST search | ( | LIST | list,
|  | void * | key,
|  | TessResultCallback2< int, void *, void * > * |
| ) |  |

Definition at line 422 of file oldlist.cpp.

{
iterate (list) if ((*is_equal).Run(first_node (list), key))
return (list);
return (NIL_LIST);
}