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.
[Implemented] Native ability to concatenate and split lists.
[Implemented] Native ability to concatenate and split lists.
Last edited by Demivec on Sat Aug 14, 2010 1:45 pm, edited 3 times in total.
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Native ability to concatenate lists.
Demivec,
thank you for writing this feature request. I probably wouldn't have been able to express the situation that clearly in English.
Regards, Little John
thank you for writing this feature request. I probably wouldn't have been able to express the situation that clearly in English.
Regards, Little John
Re: Native ability to concatenate lists.
The ability to cut, divide and maybe also copy a part of a linked list would be much faster using looping copy/delete.
Code: Select all
; Pseudo code...
NewList A()=[0,1,2,3,4,5,6,7,8,9,10]
NewList B()=CutList( A(), 4)
Would give;
A()=[0,1,2,3]
B()=[4,5,6,7,8,9,10]
; ___________________________________________
; This would allow code as
SortContactListbyMaleFemale(MyList())
NewList Females()=CutList(MyList(), indexoffirstgirl)
; MyList() would now be ‘Male()’ part
ForEach MyList()
ForEach Female()
Check_if_dating(MyList(), Female())
Next
Next
The best preparation for tomorrow is doing your best today.