Hi,
I am toying around with generics and i got stuck when writing somewhat more
advanced generic code.
This code has already been once submitted by me as a bug(#0010247) report
because fpc 2.2.0 crashes when trying to compile this.
But this time I got futher with the latest svn(9488) compile. The error
message(see below) which i got is obvious but i have no idea what to do instead
of writing TBucket.PNode.
I hope somebody can enlighten me. Thank you in advance.
----------- 8< *snip, snip* -------------------------
{ TList }
generic TList<T> = class
[...]
end;
{ TLinkedList }
generic TLinkedList<T> = class
type
public
PNode = ^TNode;
TNode = record
Previous,
Next: PNode;
Element: T;
end;
var
[...]
end;
{ THashTable }
generic THashTable<T> = class
type
public
THashNode = record
Hash: LongWord;
Key: ShortString;
Element: T;
end;
TBucket = specialize TLinkedList<THashNode>;
TBucketList = specialize TList<TBucket>;
var
private
BucketList: TBucketList;
procedure InitBucketList(const TableSize: integer);
procedure ReHash(const TableSize: integer);
function GetElement(const Key: ShortString): T;
procedure SetElement(const Key: ShortString; const AElement: T);
function GetTableSize: integer;
procedure SetTableSize(const AValue: integer);
public
constructor Create;
destructor Destroy; override;
function HashOf(const Key: ShortString): DWord;
function BucketNodeOf(const Hash: DWord): TBucket.PNode;
----------------------------------------------------------^^^^^^^^^^^^^^
DataContainers.pp(104,66) Fatal: Syntax error, ";" expected but "." found
function Extract(const Hash: DWord): T;
function Append(const ANode: TBucket.PNode; const AHash: DWord):
property Element[Key: ShortString]: T read GetElement write
SetElement;
property TableSize: integer read GetTableSize write
SetTableSize;
end;
----------- 8< *snip, snip* -------------------------
bartek
_______________________________________________
fpc-pascal maillist - [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal