[Implemented] Native ability to concatenate and split lists.
Posted: Fri Aug 13, 2010 7:32 pm
For reference see this thread topic.
The concatenation of 2 lists should ideally only involve changing 2 sets of pointers and the lists respective header data (i.e. size, and first/last element ptrs).
Without a native implementation it is necessary to loop through each list element and make a copy of it (via assignment) and then removing the original elements (via delete or ClearList()). The more in a list the longer the process. One of linked-list's advantages is that it allows the links to be modified easily. It would be useful to allow this kind of rearranging of elements between linked-lists.
Suggested command formats:
ConcatenateList(sourceList(), destList()) ;move elements from current element in sourceList() to destList() starting after current element
MoveListElements(sourceList(), destList(), numElements) ;move upto numElements from current element in sourceList to destList starting after current element.
@Edit: see KJ67 suggestions below for splitting lists.
The concatenation of 2 lists should ideally only involve changing 2 sets of pointers and the lists respective header data (i.e. size, and first/last element ptrs).
Without a native implementation it is necessary to loop through each list element and make a copy of it (via assignment) and then removing the original elements (via delete or ClearList()). The more in a list the longer the process. One of linked-list's advantages is that it allows the links to be modified easily. It would be useful to allow this kind of rearranging of elements between linked-lists.
Suggested command formats:
ConcatenateList(sourceList(), destList()) ;move elements from current element in sourceList() to destList() starting after current element
MoveListElements(sourceList(), destList(), numElements) ;move upto numElements from current element in sourceList to destList starting after current element.
@Edit: see KJ67 suggestions below for splitting lists.