nikif
asked on
Moving a list into another
Good morning,
could anyone help me in this?
In Delphi-6 I have a piece of code which declares
var MyList, TempList: TList;
MyList has some items. TempList has the same items in a different order. Both lists refer to pointers of the same type.
How can I move TempList to the var MyList? I do not wish to execute re-ordering directly in MyList since it might no be definitive.
When I assign
MyList := TempList;
all looks fine, although freeing lists produces following error
"Access violation at address [addr]. Read of address [addr]"
Thank you for the attention
Nikiforos
could anyone help me in this?
In Delphi-6 I have a piece of code which declares
var MyList, TempList: TList;
MyList has some items. TempList has the same items in a different order. Both lists refer to pointers of the same type.
How can I move TempList to the var MyList? I do not wish to execute re-ordering directly in MyList since it might no be definitive.
When I assign
MyList := TempList;
all looks fine, although freeing lists produces following error
"Access violation at address [addr]. Read of address [addr]"
Thank you for the attention
Nikiforos
ASKER
Dear MerijnB thank you for your attention,
Unfortunately what you proposed does not work as I expected.
Let's say MyList contains items A-B-C-D-E-F-G
TempList contains items A-F-E-D-C-B-G
Your proposition copies all pointers to MyList, so in line 18 MyList comes with items A-B-C-D-E-F-G-A-F-E-D-C-B- G
My aim is MyList with items A-F-E-D-C-B-G
Thank you
Nikiforos
Unfortunately what you proposed does not work as I expected.
Let's say MyList contains items A-B-C-D-E-F-G
TempList contains items A-F-E-D-C-B-G
Your proposition copies all pointers to MyList, so in line 18 MyList comes with items A-B-C-D-E-F-G-A-F-E-D-C-B-
My aim is MyList with items A-F-E-D-C-B-G
Thank you
Nikiforos
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That's perfect
Thank you
Nikif
Thank you
Nikif
ASKER
That's perfect
Thank you
Nikiforos
Thank you
Nikiforos
When you do MyList := TempList, both vars point to the same list, if you that list, both variables become invalid.
try something like:
Open in new window