Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2020-05

Concat TCollection?

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ryan Joseph

I have many TCollection's that I need to concat together into one larger collection for streaming. Since it's just a list I thought I could add the elements together but it appears TCollection requires that it allocate each item.

Is there a way to do this without relocating each item of the collection? There could be 10000+ items so it's important that I reuse the existing collections.

Regards,
Ryan Joseph

Michael Van Canneyt
to Ryan Joseph
Ryan Joseph wrote
I have many TCollection's that I need to concat together into one larger collection for streaming. Since it's just a list I thought I could add the elements together but it appears TCollection requires that it allocate each item. Is there a way to do this without relocating each item of the collection? There could be 10000+ items so it's important that I reuse the existing collections.

Just set the Collection property of the items to the concatenated collection instance.

Note that this effectively moves the items.

Michael.

Ryan Joseph
to Michael Van Canneyt
Show quoted text 5 lines
On May 3, 2020, at 4:04 PM, Michael Van Canneyt wrote: Just set the Collection property of the items to the concatenated collection instance. Note that this effectively moves the items.

That means I'll need to set it back later right? The original lists are being kept alive because they may need to be streamed also.

Regards,
Ryan Joseph

Michael Van Canneyt
to Ryan Joseph
Ryan Joseph wrote 9 lines
> On May 3, 2020, at 4:04 PM, Michael Van Canneyt wrote: > > Just set the Collection property of the items to the concatenated collection instance. > > Note that this effectively moves the items. That means I'll need to set it back later right? The original lists are being kept alive because they may need to be streamed also.

If you want to reuse the original collections: Yes. A collection item belongs only to 1 collection.

Michael.