tesseract  5.0.0-alpha-619-ge9db
oldlist.cpp File Reference
#include "oldlist.h"
#include <cstdio>
#include <cstring>
#include "errcode.h"

Go to the source code of this file.

Functions

int count (LIST var_list)
 
LIST delete_d (LIST list, void *key, int_compare is_equal)
 
LIST destroy (LIST list)
 
void destroy_nodes (LIST list, void_dest destructor)
 
LIST last (LIST var_list)
 
LIST pop (LIST list)
 
LIST push (LIST list, void *element)
 
LIST push_last (LIST list, void *item)
 
LIST search (LIST list, void *key, int_compare is_equal)
 

Function Documentation

◆ count()

int count ( LIST  var_list)

Definition at line 79 of file oldlist.cpp.

81  {
82  int temp = 0;
83 
84  iterate(var_list) temp += 1;

◆ delete_d()

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

Definition at line 93 of file oldlist.cpp.

96  {
97  LIST result = NIL_LIST;
98  LIST last_one = NIL_LIST;
99 
100  if (is_equal == nullptr) is_equal = is_same;
101 
102  while (list != NIL_LIST) {
103  if (!(*is_equal)(first_node(list), key)) {
104  if (last_one == NIL_LIST) {
105  last_one = list;
106  list = list_rest(list);
107  result = last_one;
108  set_rest(last_one, NIL_LIST);
109  } else {
110  set_rest(last_one, list);
111  last_one = list;
112  list = list_rest(list);
113  set_rest(last_one, NIL_LIST);
114  }
115  } else {
116  list = pop(list);
117  }

◆ destroy()

LIST destroy ( LIST  list)

Definition at line 123 of file oldlist.cpp.

127  {
128  LIST next;
129 
130  while (list != NIL_LIST) {
131  next = list_rest(list);
132  delete list;

◆ destroy_nodes()

void destroy_nodes ( LIST  list,
void_dest  destructor 
)

Definition at line 138 of file oldlist.cpp.

143  {
144  ASSERT_HOST(destructor != nullptr);
145 

◆ last()

LIST last ( LIST  var_list)

Definition at line 151 of file oldlist.cpp.

157  {

◆ pop()

LIST pop ( LIST  list)

Definition at line 161 of file oldlist.cpp.

168  {

◆ push()

LIST push ( LIST  list,
void *  element 
)

Definition at line 172 of file oldlist.cpp.

180  {

◆ push_last()

LIST push_last ( LIST  list,
void *  item 
)

Definition at line 185 of file oldlist.cpp.

194  {

◆ search()

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

Definition at line 202 of file oldlist.cpp.

212  {
first_node
#define first_node(l)
Definition: oldlist.h:84
ASSERT_HOST
#define ASSERT_HOST(x)
Definition: errcode.h:87
list_rec
Definition: oldlist.h:73
list_rest
#define list_rest(l)
Definition: oldlist.h:83
NIL_LIST
#define NIL_LIST
Definition: oldlist.h:68
is_equal
#define is_equal(p1, p2)
Definition: outlines.h:97
iterate
#define iterate(l)
Definition: oldlist.h:92
pop
LIST pop(LIST list)
Definition: oldlist.cpp:161
set_rest
#define set_rest(l, cell)
Definition: oldlist.h:101