mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-12 19:49:31 +02:00
59 lines
1.5 KiB
ObjectPascal
59 lines
1.5 KiB
ObjectPascal
unit tw22540;
|
|
|
|
interface
|
|
|
|
{$ifdef FPC}
|
|
{$Mode Delphi}
|
|
{$endif}
|
|
{$pointermath on} // Be more objfpc like in overindexing and removing of ^.
|
|
{$inline on}
|
|
|
|
type
|
|
{$ifndef FPC} Ptrint=integer; {$endif}
|
|
TLightMap<tkey,tvalue> = class
|
|
Type
|
|
PKey = ^TKey;
|
|
PValue= ^TValue;
|
|
TKeyCompareFunc = function(const Key1, Key2: TKey): Integer; // returns Integer both in FPC and Delphi
|
|
TFinalizeKeyFunc = Procedure(var Key1:TKey) of object;
|
|
private
|
|
keycomparefunc:TKeyCompareFunc;
|
|
finalizekeyfunc:TFinalizeKeyFunc; // finalize keys. NIL if unused.
|
|
public
|
|
constructor Create; virtual;
|
|
end;
|
|
|
|
TLightStringMap<tvalue> = class(TLightMap<string,tvalue>)
|
|
constructor create; override;
|
|
procedure finalizestring(var s:string);
|
|
end;
|
|
|
|
TLightStringMapInteger = class(TLightStringMap<Integer>);
|
|
|
|
implementation
|
|
|
|
Uses Sysutils;
|
|
|
|
{ TLightMap<tkey, tvalue> }
|
|
|
|
constructor TLightMap<tkey, tvalue>.Create;
|
|
begin
|
|
end;
|
|
|
|
{ TLightStringMap<tvalue> }
|
|
|
|
constructor TLightStringMap<tvalue>.create;
|
|
begin
|
|
inherited;
|
|
keycomparefunc:=comparestr;
|
|
finalizekeyfunc:=finalizestring;
|
|
end;
|
|
|
|
procedure TLightStringMap<tvalue>.finalizestring(var s: string);
|
|
begin
|
|
finalize (s);
|
|
end;
|
|
|
|
|
|
end.
|