MCPcopy Create free account
hub / github.com/creatale/node-dv / extract_sublist

Method extract_sublist

deps/tesseract/ccutil/elst.cpp:387–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

385 **********************************************************************/
386
387ELIST_LINK *ELIST_ITERATOR::extract_sublist( //from this current
388 ELIST_ITERATOR *other_it) { //to other current
389 #ifndef NDEBUG
390 const ERRCODE BAD_EXTRACTION_PTS =
391 "Can't extract sublist from points on different lists";
392 const ERRCODE DONT_EXTRACT_DELETED =
393 "Can't extract a sublist marked by deleted points";
394 #endif
395 const ERRCODE BAD_SUBLIST = "Can't find sublist end point in original list";
396
397 ELIST_ITERATOR temp_it = *this;
398 ELIST_LINK *end_of_new_list;
399
400 #ifndef NDEBUG
401 if (!other_it)
402 BAD_PARAMETER.error ("ELIST_ITERATOR::extract_sublist", ABORT,
403 "other_it NULL");
404 if (!list)
405 NO_LIST.error ("ELIST_ITERATOR::extract_sublist", ABORT, NULL);
406 if (list != other_it->list)
407 BAD_EXTRACTION_PTS.error ("ELIST_ITERATOR.extract_sublist", ABORT, NULL);
408 if (list->empty ())
409 EMPTY_LIST.error ("ELIST_ITERATOR::extract_sublist", ABORT, NULL);
410
411 if (!current || !other_it->current)
412 DONT_EXTRACT_DELETED.error ("ELIST_ITERATOR.extract_sublist", ABORT,
413 NULL);
414 #endif
415
416 ex_current_was_last = other_it->ex_current_was_last = FALSE;
417 ex_current_was_cycle_pt = FALSE;
418 other_it->ex_current_was_cycle_pt = FALSE;
419
420 temp_it.mark_cycle_pt ();
421 do { //walk sublist
422 if (temp_it.cycled_list()) // can't find end pt
423 BAD_SUBLIST.error ("ELIST_ITERATOR.extract_sublist", ABORT, NULL);
424
425 if (temp_it.at_last ()) {
426 list->last = prev;
427 ex_current_was_last = other_it->ex_current_was_last = TRUE;
428 }
429
430 if (temp_it.current == cycle_pt)
431 ex_current_was_cycle_pt = TRUE;
432
433 if (temp_it.current == other_it->cycle_pt)
434 other_it->ex_current_was_cycle_pt = TRUE;
435
436 temp_it.forward ();
437 }
438 while (temp_it.prev != other_it->current);
439
440 //circularise sublist
441 other_it->current->next = current;
442 end_of_new_list = other_it->current;
443
444 //sublist = whole list

Callers 1

assign_to_sublistMethod · 0.45

Calls 6

errorMethod · 0.45
emptyMethod · 0.45
mark_cycle_ptMethod · 0.45
cycled_listMethod · 0.45
at_lastMethod · 0.45
forwardMethod · 0.45

Tested by

no test coverage detected