[fpc-pascal] How reliable are Hashlists in Contnrs

2020-08-24 Thread Lars via fpc-pascal
I've noticed some problem with another hashlist that after adding about 
2000 items to it, it starts to have problems. There are duplicates added 
(possibly a collision?)


Is there a such thing as a perfect hashlist which never has a collision, 
or will they always have problems... In that case a regular but slower 
List might be of use for perfection.


If there is an error would it throw an exception?


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Difference between Associative array and Hashlist?

2020-08-24 Thread Lars via fpc-pascal
Since FPC has no associative array I was thinking that the closest is 
TStringList with name/value pairs.


Then there is a hashlist in contnrs.

Maybe an associative array means you don't have to implement it using 
hashes in order for it to work?


If there is a need for one I might write one as the TStringList is a bit 
slow, but do they already exist elsewhere before undertaking it...

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How reliable are Hashlists in Contnrs

2020-08-24 Thread Lars via fpc-pascal

On 2020-08-24 14:01, nore...@z505.com wrote:

I've noticed some problem with another hashlist that after adding
about 2000 items to it, it starts to have problems.


BTW, sorry to be more clear I meant I used another hashlist unit, not 
the contnrs one but another open source public domain one


This one:

https://github.com/z505/delphi-hashlist

And had problems with it.

I will try out contnrs one to compare soon!
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Procedural generics question

2020-08-24 Thread Lars via fpc-pascal
Inside a generic procedure (no objects used just a procedure) is there a 
way to check which type the code is being used for such as:


generic procedure Add();
begin
  if type = integer then...

  if type = string then...
  begin
// specialized code for that type only
  end
end;

I remember something like this in RTTI though but can't find it in your 
docs yet for generics.


The current way might be to code up separate procedures for each type, 
but that's kind of defeating the purpose of generics since that would 
simply be an overloaded regular function.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Procedural generics question

2020-09-03 Thread Lars via fpc-pascal

On 2020-08-26 05:44, Nico Neumann via fpc-pascal wrote:

The TypeInfo function checks the code during run-time thus the
generated code is 'bloated'. Better use the compiler intrinsic
GetTypeKind.

{$mode objfpc}

uses
   typinfo;

generic procedure Add;
begin
if GetTypeKind(T) = tkInteger then WriteLn('an integer');
if GetTypeKind(T) = tkString then WriteLn('a string');
end;



That's great but if the type is something like a TRec (custom record) or 
a class, it won't be possible to check the types AFAICT because those 
are special built in type kind values for common basic types?

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal