<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">James Richters via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>> schrieb am Di., 8. Sep. 2020, 20:07:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div class="m_7088456680926493946WordSection1"><p class="MsoNormal"><span>What’s the difference between <span class="m_7088456680926493946SpellE">TList</span> and <span class="m_7088456680926493946SpellE">TFPGList</span>?<span> </span>Which one is better for this example? </span></p></div></div></blockquote></div></div><div dir="auto">The main difference is that TFPGList ist a generic, thus when you specialize it with your record you'll have a typesafe object where you don't need to manually work with pointers while for TList you either need to work with pointers or declare a descendant with typesafe setters/getters like you had done in the other mail. </div><div dir="auto">You could also take a look at the generic TList in Generics.Collections which does not require an = operator like TFPGList does. </div><div dir="auto"><br></div><div dir="auto">Please note that if you work with TFPGList or the Generics.Collection.TList then you need to modify an entry using a local variable if your entries are records:</div><div dir="auto"><br></div><div dir="auto">entry := mylist[i];</div><div dir="auto">entry.field := entry.field * 2;</div><div dir="auto">mylist[i] := entry;</div><div dir="auto"><br></div><div dir="auto">This is because the getter for the Items property will provide a /copy/ of the entry. </div><div dir="auto"><br></div><div dir="auto">With Classes.TList you'd use a pointer however and thus you can modify it in place. </div><div dir="auto"><br></div><div dir="auto">Regards,</div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>