I have a list containing user-defined types of values. I wish to make a copy of it and make changes to it without changing the original list.
Here is a trival sample of my problem:
Sub Globals
Type AType(A As Int,B As Int)
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim I As Short
Dim Lst1,Lst2 As List
Dim Typ As AType
Lst1.Initialize
Lst2.Initialize
Typ.Initialize
Typ.A=1: Typ.B=2 'add to Lst1
Lst1.Add(Typ)
For I=0 To Lst1.Size-1 'copy to Lst2 (Lst2=Lst1 just makes an alias)
Lst2.Add(Lst1.get(I))
Next
Dim Type As AType
Typ.Initialize
Typ=Lst2.Get(0)
Typ.B=3 'this changes Lst1 too!
End Sub
My extraordinarily simple question:
How can I create a new list as an independent copy as another?
Here is a trival sample of my problem:
Sub Globals
Type AType(A As Int,B As Int)
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim I As Short
Dim Lst1,Lst2 As List
Dim Typ As AType
Lst1.Initialize
Lst2.Initialize
Typ.Initialize
Typ.A=1: Typ.B=2 'add to Lst1
Lst1.Add(Typ)
For I=0 To Lst1.Size-1 'copy to Lst2 (Lst2=Lst1 just makes an alias)
Lst2.Add(Lst1.get(I))
Next
Dim Type As AType
Typ.Initialize
Typ=Lst2.Get(0)
Typ.B=3 'this changes Lst1 too!
End Sub
My extraordinarily simple question:
How can I create a new list as an independent copy as another?