* self enumerators for hashmap and vector

git-svn-id: trunk@42909 -
This commit is contained in:
marco 2019-09-03 11:53:09 +00:00
parent fef4741eb8
commit 534d7b0943
2 changed files with 13 additions and 0 deletions

View File

@ -44,6 +44,7 @@
generic THashmapIterator<TKey, TValue, T, TTable>=class
public
type PValue=^TValue;
TIntIterator = specialize THashmapIterator<TKey, TValue, T, TTable>;
var
Fh,Fp:SizeUInt;
FData:TTable;
@ -55,6 +56,7 @@
function GetValue:TValue;inline;
function GetMutable:PValue;inline;
procedure SetValue(value:TValue);inline;
function GetEnumerator : TIntIterator; inline;
property Data:T read GetData;
property Key:TKey read GetKey;
property Value:TValue read GetValue write SetValue;
@ -376,4 +378,9 @@ begin
((FData[Fh]).mutable[Fp])^.Value := value;
end;
function THashmapIterator.getenumerator: TIntIterator;
begin
result:=self;
end;
end.

View File

@ -50,6 +50,7 @@ type
function GetCurrent: T; inline;
public
constructor Create(AVector: TVector);
function GetEnumerator: TVectorEnumerator; inline;
function MoveNext: Boolean; inline;
property Current: T read GetCurrent;
end;
@ -83,6 +84,11 @@ begin
FVector := AVector;
end;
function TVector.TVectorEnumerator.GetEnumerator: TVectorEnumerator;
begin
result:=self;
end;
function TVector.TVectorEnumerator.GetCurrent: T;
begin
Result := FVector[FPosition];