Numeric equivalent of TStringList? lazarus / 31-LCL ---------------------------------------------------------------------- MarkMLl · 2022-02-26 20:29 Simple question: is there such a thing, preferably allowing 64-bit keys? MarkMLl ---------------------------------------------------------------------- dsiders · 2022-02-26 23:43 Quote from: MarkMLl on February 26, 2022, 09:29:45 pmSimple question: is there such a thing, preferably allowing 64-bit keys? MarkMLl These might be of interest: https://dsiders.gitlab.io/lazdocsnext/lazutils/integerlist/index- 4.html ---------------------------------------------------------------------- br4d · 2022-02-27 04:47 Just an Idea: how about create a new class inheriting the TStringList. Implements addAsInteger and retrieveAsInteger which simply converting the number into String and vice versa... ---------------------------------------------------------------------- Thaddy · 2022-02-27 06:54 Tdictionary from rtl-generics or indeed similar, based on fcl: https://dsiders.gitlab.io/lazdocsnext/lazutils/integerlist/tin t64list.html I prefer the first, btw. You can also simply use TList from classes. ---------------------------------------------------------------------- MarkMLl · 2022-02-27 08:23 Quote from: br4d on February 27, 2022, 05:47:52 amhow about create a new class inheriting the TStringList. Implements addAsInteger and retrieveAsInteger which simply converting the number into String and vice versa... That had occurred to me, but the list is likely to contain from 1K to many times that number of timestamped events from a logic analyser, arriving out-of-sequence (since timing and state are dumped separately), which will need sorting before being processed sequentially. I suppose that a way to do it would be to put the timestamp in numeric form in the object associated with each row, leaving the string portion effectively as a cached conversion. MarkMLl ---------------------------------------------------------------------- MarkMLl · 2022-02-27 08:31 Quote from: Thaddy on February 27, 2022, 07:54:54 amTdictionary from rtl-generics or indeed similar, based on fcl: https://dsiders.gitlab.io/lazdocsnext/lazutils/integerli st/tint64list.html I prefer the first, btw. You can also simply use TList from classes. Thanks, those look like interesting possibilities. I'd been thinking about something TList-based but for some strange reason assumed that it would, by analogy to a TStringList, sort on the pointer rather than the content. MarkMLl ---------------------------------------------------------------------- Thaddy · 2022-02-27 08:37 For high volumes I suggest the generics.collections version. After all, when a string representation is needed, there are always the helper functions from sysutils, like TInt64Helper.ToString, TInt64Helper.ToHexTring and family. Storing as string is too much overhead if the data is just a 64 bit value anyway. You will be able to achieve much higher speeds in collecting the data when the data is in its native format... ---------------------------------------------------------------------- jcmontherock · 2022-02-27 09:03 You can use dynamic array: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...type  TIntArray = Array of Integer;... ---------------------------------------------------------------------- MarkMLl · 2022-02-27 09:47 Quote from: Thaddy on February 27, 2022, 09:37:58 amFor high volumes I suggest the generics.collections version. After all, when a string representation is needed, there are always the helper functions from sysutils, like TInt64Helper.ToString, TInt64Helper.ToHexTring and family. Storing as string is too much overhead if the data is just a 64 bit value anyway. You will be able to achieve much higher speeds in collecting the data when the data is in its native format... It would probably be a good excuse for me to look at generics, but I'm still a bit wary of them for anything which will eventually be put on Github etc.: while having a modern facility like that might be a good advert for FPC, insisting that the user upgrades to the latest version with no (lower-performance etc.) fallback if he's still on an older version isn't. MarkMLl ---------------------------------------------------------------------- MarkMLl · 2022-02-27 09:48 Quote from: jcmontherock on February 27, 2022, 10:03:02 amYou can use dynamic array: You're obviously using a somewhat relaxed interpretation of "equivalent". MarkMLl ---------------------------------------------------------------------- PascalDragon · 2022-02-27 10:31 Quote from: MarkMLl on February 27, 2022, 10:47:49 amQuote from: Thaddy on February 27, 2022, 09:37:58 amFor high volumes I suggest the generics.collections version. After all, when a string representation is needed, there are always the helper functions from sysutils, like TInt64Helper.ToString, TInt64Helper.ToHexTring and family. Storing as string is too much overhead if the data is just a 64 bit value anyway. You will be able to achieve much higher speeds in collecting the data when the data is in its native format... It would probably be a good excuse for me to look at generics, but I'm still a bit wary of them for anything which will eventually be put on Github etc.: while having a modern facility like that might be a good advert for FPC, insisting that the user upgrades to the latest version with no (lower-performance etc.) fallback if he's still on an older version isn't. Then you can alternatively use TFPGMap<> or TFPGMapObject<> from unit fgl, they are much older (2.2, 2.4 or so). ---------------------------------------------------------------------- MarkMLl · 2022-02-27 10:45 Quote from: PascalDragon on February 27, 2022, 11:31:56 amThen you can alternatively use TFPGMap<> or TFPGMapObject<> from unit fgl, they are much older (2.2, 2.4 or so). Thanks for that, I'll investigate. In practice I think the absolute cutoff point is 2.2.4 since that was the point at which FPC_FULLVERSION was introduced, i.e. before that there might not even be a sensible error message telling the user what language facility is missing. I can't remember the practical result of that: it's around there that the LCL lost (maintained) GTK1 support. Realistically 2.6.4 is also significant since that's when  case  gained the ability to handle strings, and a lot of target development and fixes went into 2.7.1... would I be safe assuming that late 2.7.1 equates to 3.0.0? In practice I normally assume 3.2.0 because of support for CURRENTROUTINE, but try not to insist on it. MarkMLl ---------------------------------------------------------------------- PascalDragon · 2022-02-27 10:55 Quote from: MarkMLl on February 27, 2022, 11:45:59 amRealistically 2.6.4 is also significant since that's when  case  gained the ability to handle strings, and a lot of target development and fixes went into 2.7.1... would I be safe assuming that late 2.7.1 equates to 3.0.0? The development versions are considered moving targets, thus yes, you can equal it to 3.0.0 (essentially the last supported 2.7.1 is the revision right before the branch ) ---------------------------------------------------------------------- MarkMLl · 2022-02-27 10:57 Quote from: PascalDragon on February 27, 2022, 11:55:26 amThe development versions are considered moving targets, thus yes, you can equal it to 3.0.0 (essentially the last supported 2.7.1 is the revision right before the branch ) Thanks, I thought that was the case. I think I might in the past have referred somewhere to "late 2.7.1" as being a desirable version, but unless stuff was actually pulled out of it before release (which I don't believe to be the case) I suppose that's basically silly. MarkMLl ---------------------------------------------------------------------- PascalDragon · 2022-02-27 11:03 I generally wouldn't adivce to use development versions that are no longer considered to be in development. It can be a big hazzle otherwise to find out what might be wrong in case of a problem. ---------------------------------------------------------------------- Thaddy · 2022-02-27 11:28 Quote from: MarkMLl on February 27, 2022, 10:47:49 amIt would probably be a good excuse for me to look at generics, but I'm still a bit wary of them for anything which will eventually be put on Github etc.: while having a modern facility like that might be a good advert for FPC, insisting that the user upgrades to the latest version with no (lower-performance etc.) fallback if he's still on an older version isn't. MarkMLl Well, the packages are included in the rtl as fcl and rtl-generics, so that is maintained as long as there is Freepascal or the algorithms passed their sell by date. Quite often seen the latter in 40 years in the business.. Although the theory is still sound. Generics usually (if not mostly or at all) have no speed penalty, so don't be afraid of them: they are resolved at parse time, not even at compile time. But feel free to do it the OOP way and derive from classes.Tlist. Easy.. It also depends on the operations that you want: if there are not many, you can indeed use just an array (not recommended for convenience, though) ---------------------------------------------------------------------- MarkMLl · 2022-02-27 11:54 Quote from: Thaddy on February 27, 2022, 12:28:30 pmWell, the packages are included in the rtl as fcl and rtl-generics, so that is maintained as long as there is Freepascal or the algorithms passed their sell by date. Quite often seen the latter in 40 years in the business.. Although the theory is still sound. rtl-generics appears at FPC 3.2.0. That means that e.g. anybody on Debian "Stable" should have it, but anybody on "Oldstable" won't... and I'd definitely call it a poor advert if I insisted that somebody upgraded before he had any change at all of compiling something. Now, my preference is to compile FPC myself, so even the older systems here are candidates for having at least 3.0.4 (I've got a 32-bit laptop which I use for various things, Debian no longer ships the video driver which effectively pins its version). But considering that system, and considering a production (well-firewalled) system for which at one point I had to use an older compiler (because of ASound requirements, now fixed)... no, I'm really not happy demanding 3.2.0. MarkMLl ---------------------------------------------------------------------- Thaddy · 2022-02-27 12:38 Quote from: MarkMLl on February 27, 2022, 12:54:21 pmrtl-generics appears at FPC 3.2.0. That means that e.g. anybody on Debian "Stable" should have it, but anybody on "Oldstable" won't... and I'd definitely call it a poor Now, my preference is to compile FPC myself, so even the older systems here are candidates for having at least 3.0.4 (I've got a 32-bit laptop which I use for various things, Debian no longer ships the video driver which effectively pins its version). But considering that system, and considering a production (well-firewalled) system for which at one point I had to use an older compiler (because of ASound requirements, now fixed)... no, I'm really not happy demanding 3.2.0. MarkMLl Well, I am still happy with D7  And 2006 and XE 10.1 but those were expensive except the latter.. Freepascal is free software and is well maintained. Some commercial options not quite so. With free software you can also update for free, but you are right that in the case of the commercial versions I still need D7. (because the development version of the compiler is and should be frozen in commercial settings) But anything I can do in D7 (or higher) I do with FreePascal now. It is not only a matter of taste, but about two other things: 1. Is it stable 2. Does it fit my requirements I don't have to work, but these two were always important to me. Btw: I also compile the compiler myself, both current and trunk. And that goes for more than just FreePascal...