| 405 | **********************************************************************/ |
| 406 | |
| 407 | ELIST2_LINK *ELIST2_ITERATOR::extract_sublist( //from this current |
| 408 | ELIST2_ITERATOR *other_it) { //to other current |
| 409 | #ifndef NDEBUG |
| 410 | const ERRCODE BAD_EXTRACTION_PTS = |
| 411 | "Can't extract sublist from points on different lists"; |
| 412 | const ERRCODE DONT_EXTRACT_DELETED = |
| 413 | "Can't extract a sublist marked by deleted points"; |
| 414 | #endif |
| 415 | const ERRCODE BAD_SUBLIST = "Can't find sublist end point in original list"; |
| 416 | |
| 417 | ELIST2_ITERATOR temp_it = *this; |
| 418 | ELIST2_LINK *end_of_new_list; |
| 419 | |
| 420 | #ifndef NDEBUG |
| 421 | if (!other_it) |
| 422 | BAD_PARAMETER.error ("ELIST2_ITERATOR::extract_sublist", ABORT, |
| 423 | "other_it NULL"); |
| 424 | if (!list) |
| 425 | NO_LIST.error ("ELIST2_ITERATOR::extract_sublist", ABORT, NULL); |
| 426 | if (list != other_it->list) |
| 427 | BAD_EXTRACTION_PTS.error ("ELIST2_ITERATOR.extract_sublist", ABORT, NULL); |
| 428 | if (list->empty ()) |
| 429 | EMPTY_LIST.error ("ELIST2_ITERATOR::extract_sublist", ABORT, NULL); |
| 430 | |
| 431 | if (!current || !other_it->current) |
| 432 | DONT_EXTRACT_DELETED.error ("ELIST2_ITERATOR.extract_sublist", ABORT, |
| 433 | NULL); |
| 434 | #endif |
| 435 | |
| 436 | ex_current_was_last = other_it->ex_current_was_last = FALSE; |
| 437 | ex_current_was_cycle_pt = FALSE; |
| 438 | other_it->ex_current_was_cycle_pt = FALSE; |
| 439 | |
| 440 | temp_it.mark_cycle_pt (); |
| 441 | do { //walk sublist |
| 442 | if (temp_it.cycled_list()) // can't find end pt |
| 443 | BAD_SUBLIST.error ("ELIST2_ITERATOR.extract_sublist", ABORT, NULL); |
| 444 | |
| 445 | if (temp_it.at_last ()) { |
| 446 | list->last = prev; |
| 447 | ex_current_was_last = other_it->ex_current_was_last = TRUE; |
| 448 | } |
| 449 | |
| 450 | if (temp_it.current == cycle_pt) |
| 451 | ex_current_was_cycle_pt = TRUE; |
| 452 | |
| 453 | if (temp_it.current == other_it->cycle_pt) |
| 454 | other_it->ex_current_was_cycle_pt = TRUE; |
| 455 | |
| 456 | temp_it.forward (); |
| 457 | } |
| 458 | //do INCLUSIVE list |
| 459 | while (temp_it.prev != other_it->current); |
| 460 | |
| 461 | //circularise sublist |
| 462 | other_it->current->next = current; |
| 463 | //circularise sublist |
| 464 | current->prev = other_it->current; |
no test coverage detected