#include <elst.h>
Definition at line 182 of file elst.h.
ELIST_ITERATOR::ELIST_ITERATOR | ( | ) | [inline] |
ELIST_ITERATOR::ELIST_ITERATOR | ( | ELIST * | list_to_iterate | ) | [inline] |
CONSTRUCTOR; set iterator to specified list;.
Definition at line 313 of file elst.h.
References set_to_list().
00313 { 00314 set_to_list(list_to_iterate); 00315 }
void ELIST_ITERATOR::add_after_stay_put | ( | ELIST_LINK * | new_link | ) | [inline] |
Add a new element to the list after the current element but do not move the iterator to the new element.
Definition at line 366 of file elst.h.
References ABORT, current, ELIST::empty(), ex_current_was_last, FALSE, ELIST::last, list, next, ELIST_LINK::next, NULL, and prev.
00367 { 00368 #ifdef _DEBUG 00369 if (!this) 00370 NULL_OBJECT.error ("ELIST_ITERATOR::add_after_stay_put", ABORT, NULL); 00371 if (!list) 00372 NO_LIST.error ("ELIST_ITERATOR::add_after_stay_put", ABORT, NULL); 00373 if (!new_element) 00374 BAD_PARAMETER.error ("ELIST_ITERATOR::add_after_stay_put", ABORT, 00375 "new_element is NULL"); 00376 if (new_element->next) 00377 STILL_LINKED.error ("ELIST_ITERATOR::add_after_stay_put", ABORT, NULL); 00378 #endif 00379 00380 if (list->empty ()) { 00381 new_element->next = new_element; 00382 list->last = new_element; 00383 prev = next = new_element; 00384 ex_current_was_last = FALSE; 00385 current = NULL; 00386 } 00387 else { 00388 new_element->next = next; 00389 00390 if (current) { //not extracted 00391 current->next = new_element; 00392 if (prev == current) 00393 prev = new_element; 00394 if (current == list->last) 00395 list->last = new_element; 00396 } 00397 else { //current extracted 00398 prev->next = new_element; 00399 if (ex_current_was_last) { 00400 list->last = new_element; 00401 ex_current_was_last = FALSE; 00402 } 00403 } 00404 next = new_element; 00405 } 00406 }
void ELIST_ITERATOR::add_after_then_move | ( | ELIST_LINK * | new_link | ) | [inline] |
Add a new element to the list after the current element and move the iterator to the new element.
Definition at line 322 of file elst.h.
References ABORT, current, cycle_pt, ELIST::empty(), ex_current_was_cycle_pt, ex_current_was_last, ELIST::last, list, next, ELIST_LINK::next, NULL, and prev.
Referenced by ELIST::internal_deep_copy().
00323 { 00324 #ifdef _DEBUG 00325 if (!this) 00326 NULL_OBJECT.error ("ELIST_ITERATOR::add_after_then_move", ABORT, NULL); 00327 if (!list) 00328 NO_LIST.error ("ELIST_ITERATOR::add_after_then_move", ABORT, NULL); 00329 if (!new_element) 00330 BAD_PARAMETER.error ("ELIST_ITERATOR::add_after_then_move", ABORT, 00331 "new_element is NULL"); 00332 if (new_element->next) 00333 STILL_LINKED.error ("ELIST_ITERATOR::add_after_then_move", ABORT, NULL); 00334 #endif 00335 00336 if (list->empty ()) { 00337 new_element->next = new_element; 00338 list->last = new_element; 00339 prev = next = new_element; 00340 } 00341 else { 00342 new_element->next = next; 00343 00344 if (current) { //not extracted 00345 current->next = new_element; 00346 prev = current; 00347 if (current == list->last) 00348 list->last = new_element; 00349 } 00350 else { //current extracted 00351 prev->next = new_element; 00352 if (ex_current_was_last) 00353 list->last = new_element; 00354 if (ex_current_was_cycle_pt) 00355 cycle_pt = new_element; 00356 } 00357 } 00358 current = new_element; 00359 }
void ELIST_ITERATOR::add_before_stay_put | ( | ELIST_LINK * | new_link | ) | [inline] |
Add a new element to the list before the current element but dont move the iterator to the new element.
Definition at line 454 of file elst.h.
References ABORT, current, ELIST::empty(), ex_current_was_last, ELIST::last, list, next, ELIST_LINK::next, NULL, prev, and TRUE.
00455 { 00456 #ifdef _DEBUG 00457 if (!this) 00458 NULL_OBJECT.error ("ELIST_ITERATOR::add_before_stay_put", ABORT, NULL); 00459 if (!list) 00460 NO_LIST.error ("ELIST_ITERATOR::add_before_stay_put", ABORT, NULL); 00461 if (!new_element) 00462 BAD_PARAMETER.error ("ELIST_ITERATOR::add_before_stay_put", ABORT, 00463 "new_element is NULL"); 00464 if (new_element->next) 00465 STILL_LINKED.error ("ELIST_ITERATOR::add_before_stay_put", ABORT, NULL); 00466 #endif 00467 00468 if (list->empty ()) { 00469 new_element->next = new_element; 00470 list->last = new_element; 00471 prev = next = new_element; 00472 ex_current_was_last = TRUE; 00473 current = NULL; 00474 } 00475 else { 00476 prev->next = new_element; 00477 if (current) { //not extracted 00478 new_element->next = current; 00479 if (next == current) 00480 next = new_element; 00481 } 00482 else { //current extracted 00483 new_element->next = next; 00484 if (ex_current_was_last) 00485 list->last = new_element; 00486 } 00487 prev = new_element; 00488 } 00489 }
void ELIST_ITERATOR::add_before_then_move | ( | ELIST_LINK * | new_link | ) | [inline] |
Add a new element to the list before the current element and move the iterator to the new element.
Definition at line 413 of file elst.h.
References ABORT, current, cycle_pt, ELIST::empty(), ex_current_was_cycle_pt, ex_current_was_last, ELIST::last, list, next, ELIST_LINK::next, NULL, and prev.
00414 { 00415 #ifdef _DEBUG 00416 if (!this) 00417 NULL_OBJECT.error ("ELIST_ITERATOR::add_before_then_move", ABORT, NULL); 00418 if (!list) 00419 NO_LIST.error ("ELIST_ITERATOR::add_before_then_move", ABORT, NULL); 00420 if (!new_element) 00421 BAD_PARAMETER.error ("ELIST_ITERATOR::add_before_then_move", ABORT, 00422 "new_element is NULL"); 00423 if (new_element->next) 00424 STILL_LINKED.error ("ELIST_ITERATOR::add_before_then_move", ABORT, NULL); 00425 #endif 00426 00427 if (list->empty ()) { 00428 new_element->next = new_element; 00429 list->last = new_element; 00430 prev = next = new_element; 00431 } 00432 else { 00433 prev->next = new_element; 00434 if (current) { //not extracted 00435 new_element->next = current; 00436 next = current; 00437 } 00438 else { //current extracted 00439 new_element->next = next; 00440 if (ex_current_was_last) 00441 list->last = new_element; 00442 if (ex_current_was_cycle_pt) 00443 cycle_pt = new_element; 00444 } 00445 } 00446 current = new_element; 00447 }
void ELIST_ITERATOR::add_list_after | ( | ELIST * | list_to_add | ) | [inline] |
Insert another list to this list after the current element but dont move the iterator.
Definition at line 495 of file elst.h.
References ABORT, current, ELIST::empty(), ex_current_was_last, FALSE, ELIST::First(), ELIST::last, list, ELIST_LINK::next, next, NULL, prev, and TRUE.
00495 { 00496 #ifdef _DEBUG 00497 if (!this) 00498 NULL_OBJECT.error ("ELIST_ITERATOR::add_list_after", ABORT, NULL); 00499 if (!list) 00500 NO_LIST.error ("ELIST_ITERATOR::add_list_after", ABORT, NULL); 00501 if (!list_to_add) 00502 BAD_PARAMETER.error ("ELIST_ITERATOR::add_list_after", ABORT, 00503 "list_to_add is NULL"); 00504 #endif 00505 00506 if (!list_to_add->empty ()) { 00507 if (list->empty ()) { 00508 list->last = list_to_add->last; 00509 prev = list->last; 00510 next = list->First (); 00511 ex_current_was_last = TRUE; 00512 current = NULL; 00513 } 00514 else { 00515 if (current) { //not extracted 00516 current->next = list_to_add->First (); 00517 if (current == list->last) 00518 list->last = list_to_add->last; 00519 list_to_add->last->next = next; 00520 next = current->next; 00521 } 00522 else { //current extracted 00523 prev->next = list_to_add->First (); 00524 if (ex_current_was_last) { 00525 list->last = list_to_add->last; 00526 ex_current_was_last = FALSE; 00527 } 00528 list_to_add->last->next = next; 00529 next = prev->next; 00530 } 00531 } 00532 list_to_add->last = NULL; 00533 } 00534 }
void ELIST_ITERATOR::add_list_before | ( | ELIST * | list_to_add | ) | [inline] |
Insert another list to this list before the current element.
Move the iterator to the start of the inserted elements iterator.
Definition at line 542 of file elst.h.
References ABORT, current, cycle_pt, ELIST::empty(), ex_current_was_cycle_pt, ex_current_was_last, FALSE, ELIST::First(), ELIST::last, list, ELIST_LINK::next, next, NULL, and prev.
00542 { 00543 #ifdef _DEBUG 00544 if (!this) 00545 NULL_OBJECT.error ("ELIST_ITERATOR::add_list_before", ABORT, NULL); 00546 if (!list) 00547 NO_LIST.error ("ELIST_ITERATOR::add_list_before", ABORT, NULL); 00548 if (!list_to_add) 00549 BAD_PARAMETER.error ("ELIST_ITERATOR::add_list_before", ABORT, 00550 "list_to_add is NULL"); 00551 #endif 00552 00553 if (!list_to_add->empty ()) { 00554 if (list->empty ()) { 00555 list->last = list_to_add->last; 00556 prev = list->last; 00557 current = list->First (); 00558 next = current->next; 00559 ex_current_was_last = FALSE; 00560 } 00561 else { 00562 prev->next = list_to_add->First (); 00563 if (current) { //not extracted 00564 list_to_add->last->next = current; 00565 } 00566 else { //current extracted 00567 list_to_add->last->next = next; 00568 if (ex_current_was_last) 00569 list->last = list_to_add->last; 00570 if (ex_current_was_cycle_pt) 00571 cycle_pt = prev->next; 00572 } 00573 current = prev->next; 00574 next = current->next; 00575 } 00576 list_to_add->last = NULL; 00577 } 00578 }
void ELIST_ITERATOR::add_to_end | ( | ELIST_LINK * | new_element | ) | [inline] |
Add a new element to the end of the list without moving the iterator.
This is provided because a single linked list cannot move to the last as the iterator couldn't set its prev pointer. Adding to the end is essential for implementing queues.
Definition at line 763 of file elst.h.
References ABORT, ELIST::last, list, ELIST_LINK::next, and NULL.
Referenced by ELIST::internal_de_dump(), and ELIST::sort().
00764 { 00765 #ifdef _DEBUG 00766 if (!this) 00767 NULL_OBJECT.error ("ELIST_ITERATOR::add_to_end", ABORT, NULL); 00768 if (!list) 00769 NO_LIST.error ("ELIST_ITERATOR::add_to_end", ABORT, NULL); 00770 if (!new_element) 00771 BAD_PARAMETER.error ("ELIST_ITERATOR::add_to_end", ABORT, 00772 "new_element is NULL"); 00773 if (new_element->next) 00774 STILL_LINKED.error ("ELIST_ITERATOR::add_to_end", ABORT, NULL); 00775 #endif 00776 00777 if (this->at_last ()) { 00778 this->add_after_stay_put (new_element); 00779 } 00780 else { 00781 if (this->at_first ()) { 00782 this->add_before_stay_put (new_element); 00783 list->last = new_element; 00784 } 00785 else { //Iteratr is elsewhere 00786 new_element->next = list->last->next; 00787 list->last->next = new_element; 00788 list->last = new_element; 00789 } 00790 } 00791 }
BOOL8 ELIST_ITERATOR::at_first | ( | ) | [inline] |
Are we at the start of the list?
Definition at line 673 of file elst.h.
References ABORT, current, ELIST::empty(), ex_current_was_last, ELIST::First(), ELIST::last, list, NULL, and prev.
00673 { 00674 #ifdef _DEBUG 00675 if (!this) 00676 NULL_OBJECT.error ("ELIST_ITERATOR::at_first", ABORT, NULL); 00677 if (!list) 00678 NO_LIST.error ("ELIST_ITERATOR::at_first", ABORT, NULL); 00679 #endif 00680 00681 //we're at a deleted 00682 return ((list->empty ()) || (current == list->First ()) || ((current == NULL) && 00683 (prev == list->last) && //NON-last pt between 00684 !ex_current_was_last)); //first and last 00685 }
BOOL8 ELIST_ITERATOR::at_last | ( | ) | [inline] |
Are we at the end of the list?
Definition at line 691 of file elst.h.
References ABORT, current, ELIST::empty(), ex_current_was_last, ELIST::last, list, NULL, and prev.
Referenced by extract_sublist().
00691 { 00692 #ifdef _DEBUG 00693 if (!this) 00694 NULL_OBJECT.error ("ELIST_ITERATOR::at_last", ABORT, NULL); 00695 if (!list) 00696 NO_LIST.error ("ELIST_ITERATOR::at_last", ABORT, NULL); 00697 #endif 00698 00699 //we're at a deleted 00700 return ((list->empty ()) || (current == list->last) || ((current == NULL) && 00701 (prev == list->last) && //last point between 00702 ex_current_was_last)); //first and last 00703 }
BOOL8 ELIST_ITERATOR::current_extracted | ( | ) | [inline] |
BOOL8 ELIST_ITERATOR::cycled_list | ( | ) | [inline] |
Have we returned to the cycle_pt since it was set?
Definition at line 709 of file elst.h.
References ABORT, current, cycle_pt, ELIST::empty(), list, NULL, and started_cycling.
Referenced by extract_sublist(), ELIST::internal_deep_copy(), ELIST::internal_dump(), ELIST::length(), ELIST::prep_serialise(), and ELIST::sort().
00709 { 00710 #ifdef _DEBUG 00711 if (!this) 00712 NULL_OBJECT.error ("ELIST_ITERATOR::cycled_list", ABORT, NULL); 00713 if (!list) 00714 NO_LIST.error ("ELIST_ITERATOR::cycled_list", ABORT, NULL); 00715 #endif 00716 00717 return ((list->empty ()) || ((current == cycle_pt) && started_cycling)); 00718 00719 }
ELIST_LINK* ELIST_ITERATOR::data | ( | ) | [inline] |
Definition at line 231 of file elst.h.
Referenced by ELIST::internal_deep_copy(), and ELIST::internal_dump().
00231 { //get current data 00232 #ifdef _DEBUG 00233 if (!list) 00234 NO_LIST.error ("ELIST_ITERATOR::data", ABORT, NULL); 00235 if (!current) 00236 NULL_DATA.error ("ELIST_ITERATOR::data", ABORT, NULL); 00237 #endif 00238 return current; 00239 }
ELIST_LINK * ELIST_ITERATOR::data_relative | ( | INT8 | offset | ) |
Return the data pointer to the element "offset" elements from current.
"offset" must not be less than -1. This function can't be INLINEd because it contains a loop
Definition at line 338 of file elst.cpp.
References ABORT, current, ELIST::empty(), list, ELIST_LINK::next, NULL, and prev.
00339 { //offset from current 00340 ELIST_LINK *ptr; 00341 00342 #ifdef _DEBUG 00343 if (!this) 00344 NULL_OBJECT.error ("ELIST_ITERATOR::data_relative", ABORT, NULL); 00345 if (!list) 00346 NO_LIST.error ("ELIST_ITERATOR::data_relative", ABORT, NULL); 00347 if (list->empty ()) 00348 EMPTY_LIST.error ("ELIST_ITERATOR::data_relative", ABORT, NULL); 00349 if (offset < -1) 00350 BAD_PARAMETER.error ("ELIST_ITERATOR::data_relative", ABORT, 00351 "offset < -l"); 00352 #endif 00353 00354 if (offset == -1) 00355 ptr = prev; 00356 else 00357 for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next); 00358 00359 #ifdef _DEBUG 00360 if (!ptr) 00361 NULL_DATA.error ("ELIST_ITERATOR::data_relative", ABORT, NULL); 00362 #endif 00363 00364 return ptr; 00365 }
BOOL8 ELIST_ITERATOR::empty | ( | ) | [inline] |
void ELIST_ITERATOR::exchange | ( | ELIST_ITERATOR * | other_it | ) |
Exchange two elements in list.
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!)
Definition at line 401 of file elst.cpp.
References ABORT, current, cycle_pt, ELIST::empty(), ERRCODE::error(), ELIST::last, list, ELIST_LINK::next, next, NULL, and prev.
00402 { //other iterator 00403 const ERRCODE DONT_EXCHANGE_DELETED = 00404 "Can't exchange deleted elements of lists"; 00405 00406 ELIST_LINK *old_current; 00407 00408 #ifdef _DEBUG 00409 if (!this) 00410 NULL_OBJECT.error ("ELIST_ITERATOR::exchange", ABORT, NULL); 00411 if (!list) 00412 NO_LIST.error ("ELIST_ITERATOR::exchange", ABORT, NULL); 00413 if (!other_it) 00414 BAD_PARAMETER.error ("ELIST_ITERATOR::exchange", ABORT, "other_it NULL"); 00415 if (!(other_it->list)) 00416 NO_LIST.error ("ELIST_ITERATOR::exchange", ABORT, "other_it"); 00417 #endif 00418 00419 /* Do nothing if either list is empty or if both iterators 00420 reference the same link */ 00421 00422 if ((list->empty ()) || 00423 (other_it->list->empty ()) || (current == other_it->current)) 00424 return; 00425 00426 /* Error if either current element is deleted */ 00427 00428 if (!current || !other_it->current) 00429 DONT_EXCHANGE_DELETED.error ("ELIST_ITERATOR.exchange", ABORT, NULL); 00430 00431 /* Now handle the 4 cases: 00432 doubleton list; 00433 non-doubleton adjacent elements (other before this); 00434 non-doubleton adjacent elements (this before other); 00435 non-adjacent elements. */ 00436 00437 //adjacent links 00438 if ((next == other_it->current) || 00439 (other_it->next == current)) { 00440 //doubleton list 00441 if ((next == other_it->current) && 00442 (other_it->next == current)) { 00443 prev = next = current; 00444 other_it->prev = other_it->next = other_it->current; 00445 } 00446 else { //non-doubleton with 00447 //adjacent links 00448 //other before this 00449 if (other_it->next == current) { 00450 other_it->prev->next = current; 00451 other_it->current->next = next; 00452 current->next = other_it->current; 00453 other_it->next = other_it->current; 00454 prev = current; 00455 } 00456 else { //this before other 00457 prev->next = other_it->current; 00458 current->next = other_it->next; 00459 other_it->current->next = current; 00460 next = current; 00461 other_it->prev = other_it->current; 00462 } 00463 } 00464 } 00465 else { //no overlap 00466 prev->next = other_it->current; 00467 current->next = other_it->next; 00468 other_it->prev->next = current; 00469 other_it->current->next = next; 00470 } 00471 00472 /* update end of list pointer when necessary (remember that the 00473 2 iterators may iterate over different lists!) */ 00474 00475 if (list->last == current) 00476 list->last = other_it->current; 00477 if (other_it->list->last == other_it->current) 00478 other_it->list->last = current; 00479 00480 if (current == cycle_pt) 00481 cycle_pt = other_it->cycle_pt; 00482 if (other_it->current == other_it->cycle_pt) 00483 other_it->cycle_pt = cycle_pt; 00484 00485 /* The actual exchange - in all cases*/ 00486 00487 old_current = current; 00488 current = other_it->current; 00489 other_it->current = old_current; 00490 }
ELIST_LINK * ELIST_ITERATOR::extract | ( | ) | [inline] |
Do extraction by removing current from the list, returning it to the caller, but NOT updating the iterator.
Any calling loop can do this. The iterator's current points to NULL. If the extracted element is to be deleted, this is the callers responsibility.
Definition at line 588 of file elst.h.
References ABORT, current, cycle_pt, ex_current_was_cycle_pt, ex_current_was_last, FALSE, ELIST::last, list, ELIST_LINK::next, next, NULL, prev, ELIST::singleton(), and TRUE.
Referenced by ELIST::sort().
00588 { 00589 ELIST_LINK *extracted_link; 00590 00591 #ifdef _DEBUG 00592 if (!this) 00593 NULL_OBJECT.error ("ELIST_ITERATOR::extract", ABORT, NULL); 00594 if (!list) 00595 NO_LIST.error ("ELIST_ITERATOR::extract", ABORT, NULL); 00596 if (!current) //list empty or 00597 //element extracted 00598 NULL_CURRENT.error ("ELIST_ITERATOR::extract", 00599 ABORT, NULL); 00600 #endif 00601 00602 if (list->singleton ()) //special case where 00603 //we do need to 00604 prev = next = list->last = NULL; 00605 // change the iterator 00606 else { 00607 prev->next = next; //remove from list 00608 00609 if (current == list->last) { 00610 list->last = prev; 00611 ex_current_was_last = TRUE; 00612 } 00613 else 00614 ex_current_was_last = FALSE; 00615 00616 ex_current_was_cycle_pt = (current == cycle_pt) ? TRUE : FALSE; 00617 00618 } 00619 extracted_link = current; 00620 extracted_link->next = NULL; //for safety 00621 current = NULL; 00622 return extracted_link; 00623 }
ELIST_LINK * ELIST_ITERATOR::extract_sublist | ( | ELIST_ITERATOR * | other_it | ) | [private] |
This is a private member, used only by ELIST::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)
Definition at line 502 of file elst.cpp.
References ABORT, at_last(), current, cycle_pt, cycled_list(), ELIST::empty(), ERRCODE::error(), ex_current_was_cycle_pt, ex_current_was_last, FALSE, forward(), ELIST::last, list, mark_cycle_pt(), next, ELIST_LINK::next, NULL, prev, and TRUE.
Referenced by ELIST::assign_to_sublist().
00503 { //to other current 00504 #ifdef _DEBUG 00505 const ERRCODE BAD_EXTRACTION_PTS = 00506 "Can't extract sublist from points on different lists"; 00507 const ERRCODE DONT_EXTRACT_DELETED = 00508 "Can't extract a sublist marked by deleted points"; 00509 #endif 00510 const ERRCODE BAD_SUBLIST = "Can't find sublist end point in original list"; 00511 00512 ELIST_ITERATOR temp_it = *this; 00513 ELIST_LINK *end_of_new_list; 00514 00515 #ifdef _DEBUG 00516 if (!this) 00517 NULL_OBJECT.error ("ELIST_ITERATOR::extract_sublist", ABORT, NULL); 00518 if (!other_it) 00519 BAD_PARAMETER.error ("ELIST_ITERATOR::extract_sublist", ABORT, 00520 "other_it NULL"); 00521 if (!list) 00522 NO_LIST.error ("ELIST_ITERATOR::extract_sublist", ABORT, NULL); 00523 if (list != other_it->list) 00524 BAD_EXTRACTION_PTS.error ("ELIST_ITERATOR.extract_sublist", ABORT, NULL); 00525 if (list->empty ()) 00526 EMPTY_LIST.error ("ELIST_ITERATOR::extract_sublist", ABORT, NULL); 00527 00528 if (!current || !other_it->current) 00529 DONT_EXTRACT_DELETED.error ("ELIST_ITERATOR.extract_sublist", ABORT, 00530 NULL); 00531 #endif 00532 00533 ex_current_was_last = other_it->ex_current_was_last = FALSE; 00534 ex_current_was_cycle_pt = FALSE; 00535 other_it->ex_current_was_cycle_pt = FALSE; 00536 00537 temp_it.mark_cycle_pt (); 00538 do { //walk sublist 00539 if (temp_it.cycled_list ()) //cant find end pt 00540 BAD_SUBLIST.error ("ELIST_ITERATOR.extract_sublist", ABORT, NULL); 00541 00542 if (temp_it.at_last ()) { 00543 list->last = prev; 00544 ex_current_was_last = other_it->ex_current_was_last = TRUE; 00545 } 00546 00547 if (temp_it.current == cycle_pt) 00548 ex_current_was_cycle_pt = TRUE; 00549 00550 if (temp_it.current == other_it->cycle_pt) 00551 other_it->ex_current_was_cycle_pt = TRUE; 00552 00553 temp_it.forward (); 00554 } 00555 while (temp_it.prev != other_it->current); 00556 00557 //circularise sublist 00558 other_it->current->next = current; 00559 end_of_new_list = other_it->current; 00560 00561 //sublist = whole list 00562 if (prev == other_it->current) { 00563 list->last = NULL; 00564 prev = current = next = NULL; 00565 other_it->prev = other_it->current = other_it->next = NULL; 00566 } 00567 else { 00568 prev->next = other_it->next; 00569 current = other_it->current = NULL; 00570 next = other_it->next; 00571 other_it->prev = prev; 00572 } 00573 return end_of_new_list; 00574 }
ELIST_LINK * ELIST_ITERATOR::forward | ( | ) |
Move the iterator to the next element of the list.
Definition at line 298 of file elst.cpp.
References ABORT, current, cycle_pt, ELIST::empty(), ex_current_was_cycle_pt, list, ELIST_LINK::next, next, NULL, prev, started_cycling, and TRUE.
Referenced by extract_sublist(), ELIST::internal_deep_copy(), ELIST::internal_dump(), ELIST::length(), move_to_last(), ELIST::prep_serialise(), and ELIST::sort().
00298 { 00299 #ifdef _DEBUG 00300 if (!this) 00301 NULL_OBJECT.error ("ELIST_ITERATOR::forward", ABORT, NULL); 00302 if (!list) 00303 NO_LIST.error ("ELIST_ITERATOR::forward", ABORT, NULL); 00304 #endif 00305 if (list->empty ()) 00306 return NULL; 00307 00308 if (current) { //not removed so 00309 //set previous 00310 prev = current; 00311 started_cycling = TRUE; 00312 } 00313 else { 00314 if (ex_current_was_cycle_pt) 00315 cycle_pt = next; 00316 } 00317 current = next; 00318 next = current->next; 00319 00320 #ifdef _DEBUG 00321 if (!current) 00322 NULL_DATA.error ("ELIST_ITERATOR::forward", ABORT, NULL); 00323 if (!next) 00324 NULL_NEXT.error ("ELIST_ITERATOR::forward", ABORT, 00325 "This is: %i Current is: %i", 00326 (int) this, (int) current); 00327 #endif 00328 return current; 00329 }
INT32 ELIST_ITERATOR::length | ( | ) | [inline] |
Return the length of the list.
Definition at line 725 of file elst.h.
References ABORT, ELIST::length(), list, and NULL.
00725 { 00726 #ifdef _DEBUG 00727 if (!this) 00728 NULL_OBJECT.error ("ELIST_ITERATOR::length", ABORT, NULL); 00729 if (!list) 00730 NO_LIST.error ("ELIST_ITERATOR::length", ABORT, NULL); 00731 #endif 00732 00733 return list->length (); 00734 }
void ELIST_ITERATOR::mark_cycle_pt | ( | ) | [inline] |
Remember the current location so that we can tell whether we've returned to this point later.
If the current point is deleted either now, or in the future, the cycle point will be set to the next item which is set to current. This could be by a forward, add_after_then_move or add_after_then_move.
Definition at line 654 of file elst.h.
References ABORT, current, cycle_pt, ex_current_was_cycle_pt, FALSE, list, NULL, started_cycling, and TRUE.
Referenced by extract_sublist(), ELIST::internal_deep_copy(), ELIST::internal_dump(), ELIST::length(), ELIST::prep_serialise(), and ELIST::sort().
00654 { 00655 #ifdef _DEBUG 00656 if (!this) 00657 NULL_OBJECT.error ("ELIST_ITERATOR::mark_cycle_pt", ABORT, NULL); 00658 if (!list) 00659 NO_LIST.error ("ELIST_ITERATOR::mark_cycle_pt", ABORT, NULL); 00660 #endif 00661 00662 if (current) 00663 cycle_pt = current; 00664 else 00665 ex_current_was_cycle_pt = TRUE; 00666 started_cycling = FALSE; 00667 }
ELIST_LINK * ELIST_ITERATOR::move_to_first | ( | ) | [inline] |
Move current so that it is set to the start of the list.
Return data just in case anyone wants it.
Definition at line 631 of file elst.h.
References ABORT, current, ELIST::First(), ELIST::last, list, ELIST_LINK::next, next, NULL, and prev.
Referenced by sort().
00631 { 00632 #ifdef _DEBUG 00633 if (!this) 00634 NULL_OBJECT.error ("ELIST_ITERATOR::move_to_first", ABORT, NULL); 00635 if (!list) 00636 NO_LIST.error ("ELIST_ITERATOR::move_to_first", ABORT, NULL); 00637 #endif 00638 00639 current = list->First (); 00640 prev = list->last; 00641 next = current ? current->next : NULL; 00642 return current; 00643 }
ELIST_LINK * ELIST_ITERATOR::move_to_last | ( | ) |
Move current so that it is set to the end of the list.
Return data just in case anyone wants it. This function can't be INLINEd because it contains a loop
Definition at line 374 of file elst.cpp.
References ABORT, current, forward(), ELIST::last, list, and NULL.
00374 { 00375 #ifdef _DEBUG 00376 if (!this) 00377 NULL_OBJECT.error ("ELIST_ITERATOR::move_to_last", ABORT, NULL); 00378 if (!list) 00379 NO_LIST.error ("ELIST_ITERATOR::move_to_last", ABORT, NULL); 00380 #endif 00381 00382 while (current != list->last) 00383 forward(); 00384 00385 return current; 00386 }
void ELIST_ITERATOR::set_to_list | ( | ELIST * | list_to_iterate | ) | [inline] |
Re initialise iterator to point to start of list_to_iterate over.
Definition at line 289 of file elst.h.
References ABORT, current, cycle_pt, ex_current_was_cycle_pt, ex_current_was_last, FALSE, ELIST::First(), ELIST::last, list, ELIST_LINK::next, next, NULL, prev, and started_cycling.
Referenced by ELIST_ITERATOR(), and ELIST::internal_de_dump().
00290 { 00291 #ifdef _DEBUG 00292 if (!this) 00293 NULL_OBJECT.error ("ELIST_ITERATOR::set_to_list", ABORT, NULL); 00294 if (!list_to_iterate) 00295 BAD_PARAMETER.error ("ELIST_ITERATOR::set_to_list", ABORT, 00296 "list_to_iterate is NULL"); 00297 #endif 00298 00299 list = list_to_iterate; 00300 prev = list->last; 00301 current = list->First (); 00302 next = current ? current->next : NULL; 00303 cycle_pt = NULL; //await explicit set 00304 started_cycling = FALSE; 00305 ex_current_was_last = FALSE; 00306 ex_current_was_cycle_pt = FALSE; 00307 }
void ELIST_ITERATOR::sort | ( | int | comparator(const void *, const void *) | ) | [inline] |
Sort the elements of the list, then reposition at the start.
Definition at line 741 of file elst.h.
References ABORT, list, move_to_first(), NULL, and ELIST::sort().
00743 { 00744 #ifdef _DEBUG 00745 if (!this) 00746 NULL_OBJECT.error ("ELIST_ITERATOR::sort", ABORT, NULL); 00747 if (!list) 00748 NO_LIST.error ("ELIST_ITERATOR::sort", ABORT, NULL); 00749 #endif 00750 00751 list->sort (comparator); 00752 move_to_first(); 00753 }
void ELIST::assign_to_sublist | ( | ELIST_ITERATOR * | , | |
ELIST_ITERATOR * | ||||
) | [friend] |
ELIST_LINK* ELIST_ITERATOR::current [private] |
Definition at line 188 of file elst.h.
Referenced by add_after_stay_put(), add_after_then_move(), add_before_stay_put(), add_before_then_move(), add_list_after(), add_list_before(), at_first(), at_last(), cycled_list(), data_relative(), exchange(), extract(), extract_sublist(), forward(), mark_cycle_pt(), move_to_first(), move_to_last(), and set_to_list().
ELIST_LINK* ELIST_ITERATOR::cycle_pt [private] |
Definition at line 194 of file elst.h.
Referenced by add_after_then_move(), add_before_then_move(), add_list_before(), cycled_list(), exchange(), extract(), extract_sublist(), forward(), mark_cycle_pt(), and set_to_list().
BOOL8 ELIST_ITERATOR::ex_current_was_cycle_pt [private] |
Definition at line 192 of file elst.h.
Referenced by add_after_then_move(), add_before_then_move(), add_list_before(), extract(), extract_sublist(), forward(), mark_cycle_pt(), and set_to_list().
BOOL8 ELIST_ITERATOR::ex_current_was_last [private] |
Definition at line 190 of file elst.h.
Referenced by add_after_stay_put(), add_after_then_move(), add_before_stay_put(), add_before_then_move(), add_list_after(), add_list_before(), at_first(), at_last(), extract(), extract_sublist(), and set_to_list().
ELIST* ELIST_ITERATOR::list [private] |
Definition at line 186 of file elst.h.
Referenced by add_after_stay_put(), add_after_then_move(), add_before_stay_put(), add_before_then_move(), add_list_after(), add_list_before(), add_to_end(), at_first(), at_last(), cycled_list(), data_relative(), exchange(), extract(), extract_sublist(), forward(), length(), mark_cycle_pt(), move_to_first(), move_to_last(), set_to_list(), and sort().
ELIST_LINK* ELIST_ITERATOR::next [private] |
Definition at line 189 of file elst.h.
Referenced by add_after_stay_put(), add_after_then_move(), add_before_stay_put(), add_before_then_move(), add_list_after(), add_list_before(), exchange(), extract(), extract_sublist(), forward(), move_to_first(), and set_to_list().
ELIST_LINK* ELIST_ITERATOR::prev [private] |
Definition at line 187 of file elst.h.
Referenced by add_after_stay_put(), add_after_then_move(), add_before_stay_put(), add_before_then_move(), add_list_after(), add_list_before(), at_first(), at_last(), data_relative(), exchange(), extract(), extract_sublist(), forward(), move_to_first(), and set_to_list().
BOOL8 ELIST_ITERATOR::started_cycling [private] |
Definition at line 196 of file elst.h.
Referenced by cycled_list(), forward(), mark_cycle_pt(), and set_to_list().