elst.h

来自「一个google的OCR源码」· C头文件 代码 · 共 1,147 行 · 第 1/4 页

H
1,147
字号
                    ELIST_LINK *new_link);  //dont move    void exchange(                            //positions of 2 links                  ELIST_ITERATOR *other_it);  //other iterator    inT32 length();  //# elements in list    void sort (                  //sort elements      int comparator (           //comparison routine      const void *, const void *));};/*********************************************************************** *                          ELIST_ITERATOR::set_to_list * *  (Re-)initialise the iterator to point to the start of the list_to_iterate *  over. **********************************************************************/inline void ELIST_ITERATOR::set_to_list(  //change list                                        ELIST *list_to_iterate) {  #ifdef _DEBUG  if (!this)    NULL_OBJECT.error ("ELIST_ITERATOR::set_to_list", ABORT, NULL);  if (!list_to_iterate)    BAD_PARAMETER.error ("ELIST_ITERATOR::set_to_list", ABORT,      "list_to_iterate is NULL");  #endif  list = list_to_iterate;  prev = list->last;  current = list->First ();  next = current ? current->next : NULL;  cycle_pt = NULL;               //await explicit set  started_cycling = FALSE;  ex_current_was_last = FALSE;  ex_current_was_cycle_pt = FALSE;}/*********************************************************************** *                          ELIST_ITERATOR::ELIST_ITERATOR * *  CONSTRUCTOR - set iterator to specified list; **********************************************************************/inline ELIST_ITERATOR::ELIST_ITERATOR(ELIST *list_to_iterate) {  set_to_list(list_to_iterate);}/*********************************************************************** *                          ELIST_ITERATOR::add_after_then_move * *  Add a new element to the list after the current element and move the *  iterator to the new element. **********************************************************************/inline void ELIST_ITERATOR::add_after_then_move(  // element to add                                                ELIST_LINK *new_element) {  #ifdef _DEBUG  if (!this)    NULL_OBJECT.error ("ELIST_ITERATOR::add_after_then_move", ABORT, NULL);  if (!list)    NO_LIST.error ("ELIST_ITERATOR::add_after_then_move", ABORT, NULL);  if (!new_element)    BAD_PARAMETER.error ("ELIST_ITERATOR::add_after_then_move", ABORT,      "new_element is NULL");  if (new_element->next)    STILL_LINKED.error ("ELIST_ITERATOR::add_after_then_move", ABORT, NULL);  #endif  if (list->empty ()) {    new_element->next = new_element;    list->last = new_element;    prev = next = new_element;  }  else {    new_element->next = next;    if (current) {               //not extracted      current->next = new_element;      prev = current;      if (current == list->last)        list->last = new_element;    }    else {                       //current extracted      prev->next = new_element;      if (ex_current_was_last)        list->last = new_element;      if (ex_current_was_cycle_pt)        cycle_pt = new_element;    }  }  current = new_element;}/*********************************************************************** *                          ELIST_ITERATOR::add_after_stay_put * *  Add a new element to the list after the current element but do not move *  the iterator to the new element. **********************************************************************/inline void ELIST_ITERATOR::add_after_stay_put(  // element to add                                               ELIST_LINK *new_element) {  #ifdef _DEBUG  if (!this)    NULL_OBJECT.error ("ELIST_ITERATOR::add_after_stay_put", ABORT, NULL);  if (!list)    NO_LIST.error ("ELIST_ITERATOR::add_after_stay_put", ABORT, NULL);  if (!new_element)    BAD_PARAMETER.error ("ELIST_ITERATOR::add_after_stay_put", ABORT,      "new_element is NULL");  if (new_element->next)    STILL_LINKED.error ("ELIST_ITERATOR::add_after_stay_put", ABORT, NULL);  #endif  if (list->empty ()) {    new_element->next = new_element;    list->last = new_element;    prev = next = new_element;    ex_current_was_last = FALSE;    current = NULL;  }  else {    new_element->next = next;    if (current) {               //not extracted      current->next = new_element;      if (prev == current)        prev = new_element;      if (current == list->last)        list->last = new_element;    }    else {                       //current extracted      prev->next = new_element;      if (ex_current_was_last) {        list->last = new_element;        ex_current_was_last = FALSE;      }    }    next = new_element;  }}/*********************************************************************** *                          ELIST_ITERATOR::add_before_then_move * *  Add a new element to the list before the current element and move the *  iterator to the new element. **********************************************************************/inline void ELIST_ITERATOR::add_before_then_move(  // element to add                                                 ELIST_LINK *new_element) {  #ifdef _DEBUG  if (!this)    NULL_OBJECT.error ("ELIST_ITERATOR::add_before_then_move", ABORT, NULL);  if (!list)    NO_LIST.error ("ELIST_ITERATOR::add_before_then_move", ABORT, NULL);  if (!new_element)    BAD_PARAMETER.error ("ELIST_ITERATOR::add_before_then_move", ABORT,      "new_element is NULL");  if (new_element->next)    STILL_LINKED.error ("ELIST_ITERATOR::add_before_then_move", ABORT, NULL);  #endif  if (list->empty ()) {    new_element->next = new_element;    list->last = new_element;    prev = next = new_element;  }  else {    prev->next = new_element;    if (current) {               //not extracted      new_element->next = current;      next = current;    }    else {                       //current extracted      new_element->next = next;      if (ex_current_was_last)        list->last = new_element;      if (ex_current_was_cycle_pt)        cycle_pt = new_element;    }  }  current = new_element;}/*********************************************************************** *                          ELIST_ITERATOR::add_before_stay_put * *  Add a new element to the list before the current element but dont move the *  iterator to the new element. **********************************************************************/inline void ELIST_ITERATOR::add_before_stay_put(  // element to add                                                ELIST_LINK *new_element) {  #ifdef _DEBUG  if (!this)    NULL_OBJECT.error ("ELIST_ITERATOR::add_before_stay_put", ABORT, NULL);  if (!list)    NO_LIST.error ("ELIST_ITERATOR::add_before_stay_put", ABORT, NULL);  if (!new_element)    BAD_PARAMETER.error ("ELIST_ITERATOR::add_before_stay_put", ABORT,      "new_element is NULL");  if (new_element->next)    STILL_LINKED.error ("ELIST_ITERATOR::add_before_stay_put", ABORT, NULL);  #endif  if (list->empty ()) {    new_element->next = new_element;    list->last = new_element;    prev = next = new_element;    ex_current_was_last = TRUE;    current = NULL;  }  else {    prev->next = new_element;    if (current) {               //not extracted      new_element->next = current;      if (next == current)        next = new_element;    }    else {                       //current extracted      new_element->next = next;      if (ex_current_was_last)        list->last = new_element;    }    prev = new_element;  }}/*********************************************************************** *                          ELIST_ITERATOR::add_list_after * *  Insert another list to this list after the current element but dont move the *  iterator. **********************************************************************/inline void ELIST_ITERATOR::add_list_after(ELIST *list_to_add) {  #ifdef _DEBUG  if (!this)    NULL_OBJECT.error ("ELIST_ITERATOR::add_list_after", ABORT, NULL);  if (!list)    NO_LIST.error ("ELIST_ITERATOR::add_list_after", ABORT, NULL);  if (!list_to_add)    BAD_PARAMETER.error ("ELIST_ITERATOR::add_list_after", ABORT,      "list_to_add is NULL");  #endif  if (!list_to_add->empty ()) {    if (list->empty ()) {      list->last = list_to_add->last;      prev = list->last;      next = list->First ();      ex_current_was_last = TRUE;      current = NULL;    }    else {      if (current) {             //not extracted        current->next = list_to_add->First ();        if (current == list->last)          list->last = list_to_add->last;        list_to_add->last->next = next;        next = current->next;      }      else {                     //current extracted        prev->next = list_to_add->First ();        if (ex_current_was_last) {          list->last = list_to_add->last;          ex_current_was_last = FALSE;        }        list_to_add->last->next = next;        next = prev->next;      }    }    list_to_add->last = NULL;  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?