Recent

Author Topic: Yet another generics collection  (Read 11460 times)

avk

  • Sr. Member
  • ****
  • Posts: 271
    • my self-education project
Re: Yet another generics collection
« Reply #15 on: February 04, 2019, 02:24:40 pm »
@Thaddy, thank you, I have to think about it.
The fact is that FPC generates a lot of unnecessary hints among which you can not see the important.

Thaddy

  • Hero Member
  • *****
  • Posts: 10213
Re: Yet another generics collection
« Reply #16 on: February 04, 2019, 05:14:21 pm »
I wrote a wiki article on how to handle that properly. http://wiki.freepascal.org/Turn_warnings_and_hints_on_or_off
Maybe that helps
I am more like donkey than shrek

Akira1364

  • Hero Member
  • *****
  • Posts: 540
Re: Yet another generics collection
« Reply #17 on: February 04, 2019, 09:04:26 pm »
Cool library! Whole lot of "something wasn't inlined" hints though. Just in case you aren't aware, that is almost always caused by a function being marked inline but being called by another function with an implementation that comes later in the file than it. It just won't ever work in that case.

valdir.marcos

  • Hero Member
  • *****
  • Posts: 989
Re: Yet another generics collection
« Reply #18 on: February 05, 2019, 02:11:34 am »
Collection of generic algorithms and data structures entirely written in/for FPC and Lazarus. Started as a self-education project, it now seems quite comfortable and fast. In order to use it (FPC 3.1.1 and higher and Lazarus 1.9.0 and higher):

Also the types in Generics.Collections support records without any operator overload.
One advantage of the FGL ones: they are small, so they're more suitable for embedded projects where memory size might be an issue.
And for those that are interested: here we have a performance comparison of various FPC containers (no, not by me).
Just curious.

If there are already official Generics implementations for Objfpc syntax since version 2.2. and Delphi compatible syntax since version 2.6.0.
http://wiki.freepascal.org/Generics

Why are there still so many alternative implementations for Generics?

Shouldn't all this effort be redirected to evolve official Generics implementation?
« Last Edit: February 05, 2019, 02:14:36 am by valdir.marcos »

Akira1364

  • Hero Member
  • *****
  • Posts: 540
Re: Yet another generics collection
« Reply #19 on: February 05, 2019, 03:40:00 am »
Shouldn't all this effort be redirected to evolve official Generics implementation?

I think a more important thing to look at first would be to start actively encouraging people to use generics overall in new code, and stop pointing them at things like Contnrs as though they're still "the best you'll get." They're not. Typecasting void pointers back and forth is dumb when it can be avoided.

There's a reason nobody uses non-generic TList or anything from Contnrs when working with new Delphi versions. I don't get why FPC is so different in this regard when it has all the same functionality (better functionality in some ways) available.
« Last Edit: February 05, 2019, 03:13:53 pm by Akira1364 »

Blaazen

  • Hero Member
  • *****
  • Posts: 2818
  • POKE 54296,15
    • Eye-Candy Controls
Re: Yet another generics collection
« Reply #20 on: February 05, 2019, 02:48:30 pm »
@ Akira1364

Something similar asked Graeme on ML a few years ago. For example, I still use TCollection and TCollectionItem for visual components because they work well and have built-in design-time editors. Otherwise I use FGL (at most TFPGObjectList)  for reasons you pointed.
One of reasons may be that CodeTools still does not fully support generics, i.e. when you hit Ctrl+Space you don't get proper choice.
Lazarus 2.1.0 r61214:62238 FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Akira1364

  • Hero Member
  • *****
  • Posts: 540
Re: Yet another generics collection
« Reply #21 on: February 05, 2019, 03:10:34 pm »
For example, I still use TCollection and TCollectionItem for visual components because they work well and have built-in design-time editors.

One of reasons may be that CodeTools still does not fully support generics, i.e. when you hit Ctrl+Space you don't get proper choice.

TCollection and TCollectionItem are a bit different I'd say due to the specific "persistent" RTTI-based functionality they provide. There's definitely good reasons to use those, since no relevant generic equivalent currently exists.

For the CodeTools stuff, it's true that the support for generics still isn't perfect. I don't think I'd ever write my code specifically to workaround IDE issues, though.
« Last Edit: February 05, 2019, 03:14:33 pm by Akira1364 »

avk

  • Sr. Member
  • ****
  • Posts: 271
    • my self-education project
Re: Yet another generics collection
« Reply #22 on: February 06, 2019, 12:01:06 pm »
Whole lot of "something wasn't inlined" hints though.
I cleaned the inlines a bit, so the compiler noise about this should be smaller.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8496
  • FPC developer.
Re: Yet another generics collection
« Reply #23 on: February 06, 2019, 05:25:02 pm »
Why are there still so many alternative implementations for Generics?

The Delphi compatible generics library is not yet delivered in a release.

avk

  • Sr. Member
  • ****
  • Posts: 271
    • my self-education project
Re: Yet another generics collection
« Reply #24 on: February 07, 2019, 08:29:55 am »
The Delphi compatible generics library is not yet delivered in a release.
Just in case, LGenerics is incompatible with Delphi.

avk

  • Sr. Member
  • ****
  • Posts: 271
    • my self-education project
Re: Yet another generics collection
« Reply #25 on: February 23, 2019, 11:13:33 am »
recent changes in LGenerics:
 - added implementation of concurrent fine-grained hashmap(first attempt)
 - added some thread pool implementations
 - improved implementation of futures

Thaddy

  • Hero Member
  • *****
  • Posts: 10213
Re: Yet another generics collection
« Reply #26 on: February 23, 2019, 11:29:09 am »
I like the thread pool features. Will test.
I am more like donkey than shrek

avk

  • Sr. Member
  • ****
  • Posts: 271
    • my self-education project
Re: Yet another generics collection
« Reply #27 on: February 24, 2019, 08:36:51 am »
... Will test.
Thank you, it would be highly interesting to know if it works on the arm device.
« Last Edit: February 24, 2019, 09:07:31 am by avk »

avk

  • Sr. Member
  • ****
  • Posts: 271
    • my self-education project
Re: Yet another generics collection
« Reply #28 on: December 22, 2019, 05:23:25 am »
Hi everyone,
a separate branch "stable_0_52"(I hope) has been created for the current version of the LGenerics package and it seems to be compatible with fpc 3.2.

It has been added since the last announcement
new primitives:
 - some variants of "smart pointers"
 - dynarray with COW semantics
 - 128-bit integers
 - general rooted tree
 - red-black tree
 - some variants of the treap
 - static segment tree
 - helpers for getting an extended IEnumerable interface
   for any entity that provides an enumerator

algorithms on graphs:
 - minimum vertex cover
 - chordality testing
 - dominators in flowgraps
 - FMR planarity testing algorithm

Merry Christmas and happy coding! 

julkas

  • Hero Member
  • *****
  • Posts: 606
  • KISS principle / Lazarus 2.0.6 / FPC 3.0.4
Re: Yet another generics collection
« Reply #29 on: December 22, 2019, 11:35:00 am »
@avk Great +5.
1. Plans for random algorithms on graph (Karger, ...) ?
2. Delphi compatibility?
Add docs.

Thanks.
« Last Edit: December 22, 2019, 02:08:00 pm by julkas »
procedure mulu64(a, b: QWORD; out clo, chi: QWORD); assembler;
asm
  mov rax, a
  mov rdx, b
  mul rdx
  mov [clo], rax
  mov [chi], rdx
end;

 

TinyPortal © 2005-2018