[fpc-pascal] Pre-allocated TFPGList or similar

Ryan Joseph genericptr at gmail.com
Sat Nov 23 23:42:17 CET 2019


I need a pre-grown list which I can put (not insert!) items into at indexes without getting "List index out of bounds" errors. For example I want to start with a list that has 10 empty indexes:

list := TList.Create(10); // 10 empty slots!

list[5] := someItem;

Is this possible using any list type in the RTL? Actually I'd rather just disable all the out of bounds errors because  I need some performant which isn't making more checks than need be. I want to use a heap-based list because the it may need to grow later.

Thanks guys.

Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list