⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 elst2.cpp

📁 一OCR的相关资料。.希望对研究OCR的朋友有所帮助.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
  if (current) {                 //not removed so                                 //set previous    prev = current;    started_cycling = TRUE;  }  else {    if (ex_current_was_cycle_pt)      cycle_pt = next;  }  current = next;  next = current->next;  #ifdef _DEBUG  if (!current)    NULL_DATA.error ("ELIST2_ITERATOR::forward", ABORT, NULL);  if (!next)    NULL_NEXT.error ("ELIST2_ITERATOR::forward", ABORT,      "This is: %i  Current is: %i",      (int) this, (int) current);  #endif  return current;}/*********************************************************************** *							ELIST2_ITERATOR::backward * *  Move the iterator to the previous element of the list. *  REMEMBER: ALL LISTS ARE CIRCULAR. **********************************************************************/ELIST2_LINK *ELIST2_ITERATOR::backward() {  #ifdef _DEBUG  if (!this)    NULL_OBJECT.error ("ELIST2_ITERATOR::backward", ABORT, NULL);  if (!list)    NO_LIST.error ("ELIST2_ITERATOR::backward", ABORT, NULL);  #endif  if (list->empty ())    return NULL;  if (current) {                 //not removed so                                 //set previous    next = current;    started_cycling = TRUE;  }  else {    if (ex_current_was_cycle_pt)      cycle_pt = prev;  }  current = prev;  prev = current->prev;  #ifdef _DEBUG  if (!current)    NULL_DATA.error ("ELIST2_ITERATOR::backward", ABORT, NULL);  if (!prev)    NULL_PREV.error ("ELIST2_ITERATOR::backward", ABORT,      "This is: %i  Current is: %i",      (int) this, (int) current);  #endif  return current;}/*********************************************************************** *							ELIST2_ITERATOR::data_relative * *  Return the data pointer to the element "offset" elements from current. *  (This function can't be INLINEd because it contains a loop) **********************************************************************/ELIST2_LINK *ELIST2_ITERATOR::data_relative(                //get data + or - ..                                            INT8 offset) {  //offset from current  ELIST2_LINK *ptr;  #ifdef _DEBUG  if (!this)    NULL_OBJECT.error ("ELIST2_ITERATOR::data_relative", ABORT, NULL);  if (!list)    NO_LIST.error ("ELIST2_ITERATOR::data_relative", ABORT, NULL);  if (list->empty ())    EMPTY_LIST.error ("ELIST2_ITERATOR::data_relative", ABORT, NULL);  #endif  if (offset < 0)    for (ptr = current ? current : next; offset++ < 0; ptr = ptr->prev);  else    for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);  #ifdef _DEBUG  if (!ptr)    NULL_DATA.error ("ELIST2_ITERATOR::data_relative", ABORT, NULL);  #endif  return ptr;}/*********************************************************************** *							ELIST2_ITERATOR::exchange() * *  Given another iterator, whose current element is a different element on *  the same list list OR an element of another list, exchange the two current *  elements.  On return, each iterator points to the element which was the *  other iterators current on entry. *  (This function hasn't been in-lined because its a bit big!) **********************************************************************/void ELIST2_ITERATOR::exchange(                              //positions of 2 links                               ELIST2_ITERATOR *other_it) {  //other iterator  const ERRCODE DONT_EXCHANGE_DELETED =    "Can't exchange deleted elements of lists";  ELIST2_LINK *old_current;  #ifdef _DEBUG  if (!this)    NULL_OBJECT.error ("ELIST2_ITERATOR::exchange", ABORT, NULL);  if (!list)    NO_LIST.error ("ELIST2_ITERATOR::exchange", ABORT, NULL);  if (!other_it)    BAD_PARAMETER.error ("ELIST2_ITERATOR::exchange", ABORT, "other_it NULL");  if (!(other_it->list))    NO_LIST.error ("ELIST2_ITERATOR::exchange", ABORT, "other_it");  #endif  /* Do nothing if either list is empty or if both iterators reference the same  link */  if ((list->empty ()) ||    (other_it->list->empty ()) || (current == other_it->current))    return;  /* Error if either current element is deleted */  if (!current || !other_it->current)    DONT_EXCHANGE_DELETED.error ("ELIST2_ITERATOR.exchange", ABORT, NULL);  /* Now handle the 4 cases: doubleton list; non-doubleton adjacent elements  (other before this); non-doubleton adjacent elements (this before other);  non-adjacent elements. */                                 //adjacent links  if ((next == other_it->current) ||  (other_it->next == current)) {                                 //doubleton list    if ((next == other_it->current) &&    (other_it->next == current)) {      prev = next = current;      other_it->prev = other_it->next = other_it->current;    }    else {                       //non-doubleton with                                 //adjacent links                                 //other before this      if (other_it->next == current) {        other_it->prev->next = current;        other_it->current->next = next;        other_it->current->prev = current;        current->next = other_it->current;        current->prev = other_it->prev;        next->prev = other_it->current;        other_it->next = other_it->current;        prev = current;      }      else {                     //this before other        prev->next = other_it->current;        current->next = other_it->next;        current->prev = other_it->current;        other_it->current->next = current;        other_it->current->prev = prev;        other_it->next->prev = current;        next = current;        other_it->prev = other_it->current;      }    }  }  else {                         //no overlap    prev->next = other_it->current;    current->next = other_it->next;    current->prev = other_it->prev;    next->prev = other_it->current;    other_it->prev->next = current;    other_it->current->next = next;    other_it->current->prev = prev;    other_it->next->prev = current;  }  /* update end of list pointer when necessary (remember that the 2 iterators    may iterate over different lists!) */  if (list->last == current)    list->last = other_it->current;  if (other_it->list->last == other_it->current)    other_it->list->last = current;  if (current == cycle_pt)    cycle_pt = other_it->cycle_pt;  if (other_it->current == other_it->cycle_pt)    other_it->cycle_pt = cycle_pt;  /* The actual exchange - in all cases*/  old_current = current;  current = other_it->current;  other_it->current = old_current;}/*********************************************************************** *							ELIST2_ITERATOR::extract_sublist() * *  This is a private member, used only by ELIST2::assign_to_sublist. *  Given another iterator for the same list, extract the links from THIS to *  OTHER inclusive, link them into a new circular list, and return a *  pointer to the last element. *  (Can't inline this function because it contains a loop) **********************************************************************/ELIST2_LINK *ELIST2_ITERATOR::extract_sublist(                              //from this current                                              ELIST2_ITERATOR *other_it) {  //to other current  #ifdef _DEBUG  const ERRCODE BAD_EXTRACTION_PTS =    "Can't extract sublist from points on different lists";  const ERRCODE DONT_EXTRACT_DELETED =    "Can't extract a sublist marked by deleted points";  #endif  const ERRCODE BAD_SUBLIST = "Can't find sublist end point in original list";  ELIST2_ITERATOR temp_it = *this;  ELIST2_LINK *end_of_new_list;  #ifdef _DEBUG  if (!this)    NULL_OBJECT.error ("ELIST2_ITERATOR::extract_sublist", ABORT, NULL);  if (!other_it)    BAD_PARAMETER.error ("ELIST2_ITERATOR::extract_sublist", ABORT,      "other_it NULL");  if (!list)    NO_LIST.error ("ELIST2_ITERATOR::extract_sublist", ABORT, NULL);  if (list != other_it->list)    BAD_EXTRACTION_PTS.error ("ELIST2_ITERATOR.extract_sublist", ABORT, NULL);  if (list->empty ())    EMPTY_LIST.error ("ELIST2_ITERATOR::extract_sublist", ABORT, NULL);  if (!current || !other_it->current)    DONT_EXTRACT_DELETED.error ("ELIST2_ITERATOR.extract_sublist", ABORT,      NULL);  #endif  ex_current_was_last = other_it->ex_current_was_last = FALSE;  ex_current_was_cycle_pt = FALSE;  other_it->ex_current_was_cycle_pt = FALSE;  temp_it.mark_cycle_pt ();  do {                           //walk sublist    if (temp_it.cycled_list ())  //cant find end pt      BAD_SUBLIST.error ("ELIST2_ITERATOR.extract_sublist", ABORT, NULL);    if (temp_it.at_last ()) {      list->last = prev;      ex_current_was_last = other_it->ex_current_was_last = TRUE;    }    if (temp_it.current == cycle_pt)      ex_current_was_cycle_pt = TRUE;    if (temp_it.current == other_it->cycle_pt)      other_it->ex_current_was_cycle_pt = TRUE;    temp_it.forward ();  }                                 //do INCLUSIVE list  while (temp_it.prev != other_it->current);                                 //circularise sublist  other_it->current->next = current;                                 //circularise sublist  current->prev = other_it->current;  end_of_new_list = other_it->current;                                 //sublist = whole list  if (prev == other_it->current) {    list->last = NULL;    prev = current = next = NULL;    other_it->prev = other_it->current = other_it->next = NULL;  }  else {    prev->next = other_it->next;    other_it->next->prev = prev;    current = other_it->current = NULL;    next = other_it->next;    other_it->prev = prev;  }  return end_of_new_list;}

⌨️ 快捷键说明

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