Recent

Author Topic: LGenerics: yet another generics collection  (Read 37354 times)

avk

  • Hero Member
  • *****
  • Posts: 752
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: 14169
  • Probably until I exterminate Putin.
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
Specialize a type, not a var.

Akira1364

  • Hero Member
  • *****
  • Posts: 561
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: 1106
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: 561
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: 3237
  • 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.3.0 (rev main-2_3-2863...) FPC 3.3.1 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: 561
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

  • Hero Member
  • *****
  • Posts: 752
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

  • Administrator
  • Hero Member
  • *
  • Posts: 11352
  • 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

  • Hero Member
  • *****
  • Posts: 752
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

  • Hero Member
  • *****
  • Posts: 752
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: 14169
  • Probably until I exterminate Putin.
Re: Yet another generics collection
« Reply #26 on: February 23, 2019, 11:29:09 am »
I like the thread pool features. Will test.
Specialize a type, not a var.

avk

  • Hero Member
  • *****
  • Posts: 752
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

  • Hero Member
  • *****
  • Posts: 752
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

  • Guest
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 »

 

TinyPortal © 2005-2018