Moving Element from one list to a other
Moving Element from one list to a other
Would be nice to have a native way to move an element from one list to a other. Doing it by hand, is a little bit complicated.
sorry for my bad english
Re: Moving Element from one list to a other
? What's wrong with CopyStructure()?
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
Re: Moving Element from one list to a other
Pointers to the listelement are lost in this caseDK_PETER wrote:? What's wrong with CopyStructure()?
sorry for my bad english
Re: Moving Element from one list to a other
Hmmm..Okay..
How about this?
Wouldn't that work?
How about this?
Code: Select all
Declare CopyTheElement(*src, *dest)
Structure ELEMENT_DATA
id.i
num.i
var.s
EndStructure
Global NewList List1.ELEMENT_DATA()
Global NewList List2.ELEMENT_DATA()
Procedure CopyTheElement(*src, *dest)
CopyStructure(*src, *dest, ELEMENT_DATA)
EndProcedure
For x = 0 To 100
AddElement(List1())
List1()\id = Random(255,10)
List1()\num = Random(1000,100)
List1()\var = "This is a string " + Str(x)
Next x
SelectElement(List1(),55)
AddElement(List2())
CopyTheElement(@List1(), @List2())
Debug Str(List2()\id)
Debug List2()\var
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
Re: Moving Element from one list to a other
CopyStructure is to slow for big list elements.
MoveElement() change only the next- and previous element pointer, but only in one list.
PB 4.60 B1 - why MoveElement() isn't across lists?
We need some like TransferElement(SourceList(), DestinationList(), Location [, *RelativeElement])
MoveElement() change only the next- and previous element pointer, but only in one list.
PB 4.60 B1 - why MoveElement() isn't across lists?
We need some like TransferElement(SourceList(), DestinationList(), Location [, *RelativeElement])
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: Moving Element from one list to a other
You could section a larger list into two portions and keep track of where they start and stop. Then you only have to use MoveElement() to make the transition between the two 'logical' lists.
Sorting can still be done by specifying the start and end for the list 'portion' you were interested in and you could iterate through their elements by using While/Wend or Repeat/Until instead of a ForEach/Next.
Sorting can still be done by specifying the start and end for the list 'portion' you were interested in and you could iterate through their elements by using While/Wend or Repeat/Until instead of a ForEach/Next.
Re: Moving Element from one list to a other
There is a way, but you have to create a temporary list and then you have to do this:
I think Pb should do this by an easier native way.
Code: Select all
ChangeCurrentElement (List1(), *Element)
MoveElement (List1(), #PB_List_Last)
SplitList (List1(), ListTemp())
MergeLists (ListTemp(), List2)
sorry for my bad english
Re: Moving Element from one list to a other
That's a great idea.Josh wrote:There is a way, but you have to create a temporary list and then you have to do this:I think Pb should do this by an easier native way.Code: Select all
ChangeCurrentElement (List1(), *Element) MoveElement (List1(), #PB_List_Last) SplitList (List1(), ListTemp()) MergeLists (ListTemp(), List2)