Recent

Author Topic: IContainers  (Read 2532 times)

cdbc

  • Hero Member
  • *****
  • Posts: 1871
    • http://www.cdbc.dk
IContainers
« on: January 05, 2025, 01:28:56 pm »
Hi
Edit: Updated library today 29.01.2025, with added 'ILinkedList' and some small modifications...

Lately I was doing some work with an interesting framework for MQTT.
In playing with that, I stumbled upon the implementation of 'TQueue'...
Here's an excerpt from 'iqueues':
Quote
(* After seeing how the 'TQueue' is implemented in 'contnrs' unit, I thought;
   There has to be another way to do this, that doesn't involve moving data on
   every 'Enqueue' / 'Push'... So I took inspiration in Julian Bucknall's excellent
   book: "Tomes of Delphi, Algorithms and Data Structures" and implemented
   this unit with a base queue of pointers and a thread safe version of it.
   It's based on 'TFPList' to keep the code simple and snappy :o)
   It sports both classes and COM interfaces for usage, careful with 'intermixing'!
   January 2025 - Benny Christensen a.k.a. cdbc *)
It's my plan to continue adding interfaces and classes to this little library, as time permits, in the hope that it can be of use to somebody...
The library is hosted on my 'Gitlab' account HERE.
Please let me know what you think...
eta: Changed the title, 'cause now it's not so new any more...  :D
TIA
Regards Benny
« Last Edit: January 29, 2025, 03:26:27 pm by cdbc »
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

cdbc

  • Hero Member
  • *****
  • Posts: 1871
    • http://www.cdbc.dk
Re: New library 'IContainers' has been born...
« Reply #1 on: January 19, 2025, 06:00:22 pm »
Hi
So, today I've updated my Gitlab -> IContainers repo.
It has seen the addition of:
- INodeManager, a memory manager for linked lists et.al.
- IStack, together with TiStack implement a stack of pointers.
- ITSStack, a thread safe version of IStack.
These classes implement their functionality via linked lists. One of the potential problems with linked lists, is the possible 'heap-thrashing', due to many small(ish) allocations and disposals. Thus these sport an own node-pager / manager, to keep that from happening...
The library can be fetched from HERE.
In the hope it can be useful for somebody  8)
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

Thaddy

  • Hero Member
  • *****
  • Posts: 16580
  • Kallstadt seems a good place to evict Trump to.
Re: IContainers
« Reply #2 on: January 20, 2025, 08:04:32 am »
{$ifdef VER3_2_2} ?
Do you mean {$if fpc_fullversion >= 30202} or {$if fpc_fullversion <= 30202}?
It is almost never a good idea to use your way of distinguising between versions.

Looks nice, btw.
« Last Edit: January 20, 2025, 08:15:09 am by Thaddy »
But I am sure they don't want the Trumps back...

cdbc

  • Hero Member
  • *****
  • Posts: 1871
    • http://www.cdbc.dk
Re: IContainers
« Reply #3 on: January 20, 2025, 08:23:56 am »
Good morning Thaddy  :)
Thanks mate, I was hoping you would speak up, 'cause exactly your point, I was unsure of, so I took the first one that seemed to work  :D
I'm developing in 'main', but someone introduced 'RTLString' (I guess it has to do with upcoming unicode-stuff), it's all good and well, but I have to make it work, at least with the latest stable release, i.e.: 3.2.2.
<pseudo>
if compiler is less than main/trunk ~ 3.1.1 then define RTLString = ansistring;
</pseudo>
You got a divine suggestion?
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

cdbc

  • Hero Member
  • *****
  • Posts: 1871
    • http://www.cdbc.dk
Re: IContainers
« Reply #4 on: January 20, 2025, 08:36:34 am »
Ok I went with your second suggestion, it seems to do the trick  8)
Thanks again mate  ;)
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

cdbc

  • Hero Member
  • *****
  • Posts: 1871
    • http://www.cdbc.dk
Re: IContainers
« Reply #5 on: January 21, 2025, 06:23:44 pm »
Hi
Added 'IQueue' and some small modifications...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

Thaddy

  • Hero Member
  • *****
  • Posts: 16580
  • Kallstadt seems a good place to evict Trump to.
Re: IContainers
« Reply #6 on: January 21, 2025, 06:38:05 pm »
Hi
Added 'IQueue' and some small modifications...
Must be smart  :P 8-) How high?
But I am sure they don't want the Trumps back...

cdbc

  • Hero Member
  • *****
  • Posts: 1871
    • http://www.cdbc.dk
Re: IContainers
« Reply #7 on: January 21, 2025, 07:28:18 pm »
Hi
Hehehe... Well, in lieu of all this talk 'bout AI, I thought: Why not add some /real/ IQ  :D ;D
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

cdbc

  • Hero Member
  • *****
  • Posts: 1871
    • http://www.cdbc.dk
Re: IContainers
« Reply #8 on: January 29, 2025, 03:25:06 pm »
Hi
I've just updated the repo
with a new sibling, a work in progress, 'ILinkedList', which is a class / interface, that encapsulates a singly linked list, which again is optimized for speed and will play nice with the memorymanager \o/
...Though the array-based TFPList/TList are still beating it  :P
But if you need a linked list, it might just come in handy.
In the hope, it can be useful to somebody  :D
Regards Benny
« Last Edit: February 07, 2025, 08:29:33 pm by cdbc »
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

 

TinyPortal © 2005-2018