mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-09 02:48:14 +02:00
* self enumerators for hashmap and vector
git-svn-id: trunk@42909 -
This commit is contained in:
parent
fef4741eb8
commit
534d7b0943
@ -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.
|
||||
|
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user