I'd like to be able to quickly concatenate linked lists (of the same type, of course).
I know I can do something like this:
Code: Select all
;-- Step 1: create two lists
NewList a()
For i = 1 To 3
AddElement(a())
a() = i
Next
NewList b()
For i = 4 To 10
AddElement(b())
b() = i
Next
;-- Step 2: "move" all elements from list b() to list a()
FirstElement(b())
While ListSize(b()) > 0
AddElement(a())
a() = b()
DeleteElement(b(), 1)
Wend
;-- Step 3: show new lists
ForEach a()
Debug a()
Next
Debug "-----"
ForEach b() ; b() is empty now
Debug b()
Next
Debug "-----"
Is there a way to do the same thing faster? Maybe something like this (pseudocode):
Code: Select all
pointer of last element in a(), that points to next element = address of first element in b()
delete any internal information about b()