|
@@ -412,10 +412,15 @@ type
|
|
|
THTNode = THTDataNode;
|
|
|
|
|
|
TDataIteratorMethod = Procedure(Item: Pointer; const Key: string; var Continue: Boolean) of object;
|
|
|
+ TDataIteratorCallBack = Procedure(Item: Pointer; const Key: string; var Continue: Boolean);
|
|
|
+
|
|
|
// For compatibility
|
|
|
TIteratorMethod = TDataIteratorMethod;
|
|
|
|
|
|
TFPDataHashTable = Class(TFPCustomHashTable)
|
|
|
+ Private
|
|
|
+ FIteratorCallBack: TDataIteratorCallBack;
|
|
|
+ Procedure CallbackIterator(Item: Pointer; const Key: string; var Continue: Boolean);
|
|
|
Protected
|
|
|
Function CreateNewNode(const aKey : String) : THTCustomNode; override;
|
|
|
Procedure AddNode(ANode : THTCustomNode); override;
|
|
@@ -424,6 +429,7 @@ type
|
|
|
Function ForEachCall(aMethod: TDataIteratorMethod): THTDataNode; virtual;
|
|
|
Public
|
|
|
Function Iterate(aMethod: TDataIteratorMethod): Pointer; virtual;
|
|
|
+ Function Iterate(aMethod: TDataIteratorCallBack): Pointer; virtual;
|
|
|
Procedure Add(const aKey: string; AItem: pointer); virtual;
|
|
|
property Items[const index: string]: Pointer read GetData write SetData; default;
|
|
|
end;
|
|
@@ -435,9 +441,14 @@ type
|
|
|
public
|
|
|
property Data: String read FData write FData;
|
|
|
end;
|
|
|
+
|
|
|
TStringIteratorMethod = Procedure(Item: String; const Key: string; var Continue: Boolean) of object;
|
|
|
+ TStringIteratorCallback = Procedure(Item: String; const Key: string; var Continue: Boolean);
|
|
|
|
|
|
TFPStringHashTable = Class(TFPCustomHashTable)
|
|
|
+ Private
|
|
|
+ FIteratorCallBack: TStringIteratorCallback;
|
|
|
+ Procedure CallbackIterator(Item: String; const Key: string; var Continue: Boolean);
|
|
|
Protected
|
|
|
Function CreateNewNode(const aKey : String) : THTCustomNode; override;
|
|
|
Procedure AddNode(ANode : THTCustomNode); override;
|
|
@@ -446,6 +457,7 @@ type
|
|
|
Function ForEachCall(aMethod: TStringIteratorMethod): THTStringNode; virtual;
|
|
|
Public
|
|
|
Function Iterate(aMethod: TStringIteratorMethod): String; virtual;
|
|
|
+ Function Iterate(aMethod: TStringIteratorCallback): String; virtual;
|
|
|
Procedure Add(const aKey,aItem: string); virtual;
|
|
|
property Items[const index: string]: String read GetData write SetData; default;
|
|
|
end;
|
|
@@ -464,11 +476,15 @@ type
|
|
|
public
|
|
|
destructor Destroy; override;
|
|
|
end;
|
|
|
+
|
|
|
TObjectIteratorMethod = Procedure(Item: TObject; const Key: string; var Continue: Boolean) of object;
|
|
|
+ TObjectIteratorCallback = Procedure(Item: TObject; const Key: string; var Continue: Boolean);
|
|
|
|
|
|
TFPObjectHashTable = Class(TFPCustomHashTable)
|
|
|
Private
|
|
|
FOwnsObjects : Boolean;
|
|
|
+ FIteratorCallBack: TObjectIteratorCallback;
|
|
|
+ procedure CallbackIterator(Item: TObject; const Key: string; var Continue: Boolean);
|
|
|
Protected
|
|
|
Function CreateNewNode(const aKey : String) : THTCustomNode; override;
|
|
|
Procedure AddNode(ANode : THTCustomNode); override;
|
|
@@ -479,6 +495,7 @@ type
|
|
|
constructor Create(AOwnsObjects : Boolean = True);
|
|
|
constructor CreateWith(AHashTableSize: Longword; aHashFunc: THashFunction; AOwnsObjects : Boolean = True);
|
|
|
Function Iterate(aMethod: TObjectIteratorMethod): TObject; virtual;
|
|
|
+ Function Iterate(aMethod: TObjectIteratorCallback): TObject; virtual;
|
|
|
Procedure Add(const aKey: string; AItem : TObject); virtual;
|
|
|
property Items[const index: string]: TObject read GetData write SetData; default;
|
|
|
Property OwnsObjects : Boolean Read FOwnsObjects;
|
|
@@ -2242,6 +2259,17 @@ begin
|
|
|
Result:=nil;
|
|
|
end;
|
|
|
|
|
|
+Procedure TFPDataHashTable.CallbackIterator(Item: Pointer; const Key: string; var Continue: Boolean);
|
|
|
+begin
|
|
|
+ FIteratorCallBack(Item, Key, Continue);
|
|
|
+end;
|
|
|
+
|
|
|
+Function TFPDataHashTable.Iterate(aMethod: TDataIteratorCallBack): Pointer;
|
|
|
+begin
|
|
|
+ FIteratorCallBack := aMethod;
|
|
|
+ Result := Iterate(@CallbackIterator);
|
|
|
+end;
|
|
|
+
|
|
|
Function TFPDataHashTable.ForEachCall(aMethod: TDataIteratorMethod): THTDataNode;
|
|
|
var
|
|
|
i, j: Longword;
|
|
@@ -2321,6 +2349,17 @@ begin
|
|
|
Result:='';
|
|
|
end;
|
|
|
|
|
|
+Procedure TFPStringHashTable.CallbackIterator(Item: String; const Key: string; var Continue: Boolean);
|
|
|
+begin
|
|
|
+ FIteratorCallBack(Item, Key, Continue);
|
|
|
+end;
|
|
|
+
|
|
|
+Function TFPStringHashTable.Iterate(aMethod: TStringIteratorCallback): String;
|
|
|
+begin
|
|
|
+ FIteratorCallBack := aMethod;
|
|
|
+ Result := Iterate(@CallbackIterator);
|
|
|
+end;
|
|
|
+
|
|
|
Function TFPStringHashTable.ForEachCall(aMethod: TStringIteratorMethod): THTStringNode;
|
|
|
var
|
|
|
i, j: Longword;
|
|
@@ -2398,6 +2437,17 @@ begin
|
|
|
Result:=nil;
|
|
|
end;
|
|
|
|
|
|
+Procedure TFPObjectHashTable.CallbackIterator(Item: TObject; const Key: string; var Continue: Boolean);
|
|
|
+begin
|
|
|
+ FIteratorCallBack(Item, Key, Continue);
|
|
|
+end;
|
|
|
+
|
|
|
+Function TFPObjectHashTable.Iterate(aMethod: TObjectIteratorCallback): TObject;
|
|
|
+begin
|
|
|
+ FIteratorCallBack := aMethod;
|
|
|
+ Result := Iterate(@CallbackIterator);
|
|
|
+end;
|
|
|
+
|
|
|
Function TFPObjectHashTable.ForEachCall(aMethod: TObjectIteratorMethod): THTObjectNode;
|
|
|
var
|
|
|
i, j: Longword;
|