Page 1 of 1

[Implemented] Native ability to concatenate and split lists.

Posted: Fri Aug 13, 2010 7:32 pm
by Demivec
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.

Re: Native ability to concatenate lists.

Posted: Fri Aug 13, 2010 11:18 pm
by Little John
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

Re: Native ability to concatenate lists.

Posted: Sat Aug 14, 2010 1:32 pm
by KJ67
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