[fpc-pascal] rtl-generics: TIStringComparer.Ordinal -> Access violation

Maciej Izak hnb.code at gmail.com
Wed Aug 17 17:20:25 CEST 2016


2016-08-17 16:05 GMT+02:00 silvioprog <silvioprog at gmail.com>:

> I need to find the values using case-insensitive keys (I'm using it in a
> class registry of my app), so unfortunately this bug doesn't let me to use
> TDictionary on FPC yet. :-(


There is simple workaround:

=== begin code ===

function EqualityComparison(constref ALeft, ARight: string): Boolean;
begin
  Result := LowerCase(ALeft) = LowerCase(ARight);
end;

procedure ExtendedHasher(constref AValue: string; AHashList: PUInt32);
begin
  TDefaultHashFactory.GetHashList(Pointer(AValue), Length(AValue) *
SizeOf(Char), AHashList);
end;

var
  list: TDictionary<string, string>;
begin
  list := TDictionary<string,
string>.Create(TEqualityComparer<string>.Construct(EqualityComparison,
ExtendedHasher));

=== end code ===


-- 
Best regards,
Maciej Izak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160817/5627eec3/attachment.html>


More information about the fpc-pascal mailing list