mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 17:49:07 +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
|
generic THashmapIterator<TKey, TValue, T, TTable>=class
|
||||||
public
|
public
|
||||||
type PValue=^TValue;
|
type PValue=^TValue;
|
||||||
|
TIntIterator = specialize THashmapIterator<TKey, TValue, T, TTable>;
|
||||||
var
|
var
|
||||||
Fh,Fp:SizeUInt;
|
Fh,Fp:SizeUInt;
|
||||||
FData:TTable;
|
FData:TTable;
|
||||||
@ -55,6 +56,7 @@
|
|||||||
function GetValue:TValue;inline;
|
function GetValue:TValue;inline;
|
||||||
function GetMutable:PValue;inline;
|
function GetMutable:PValue;inline;
|
||||||
procedure SetValue(value:TValue);inline;
|
procedure SetValue(value:TValue);inline;
|
||||||
|
function GetEnumerator : TIntIterator; inline;
|
||||||
property Data:T read GetData;
|
property Data:T read GetData;
|
||||||
property Key:TKey read GetKey;
|
property Key:TKey read GetKey;
|
||||||
property Value:TValue read GetValue write SetValue;
|
property Value:TValue read GetValue write SetValue;
|
||||||
@ -376,4 +378,9 @@ begin
|
|||||||
((FData[Fh]).mutable[Fp])^.Value := value;
|
((FData[Fh]).mutable[Fp])^.Value := value;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function THashmapIterator.getenumerator: TIntIterator;
|
||||||
|
begin
|
||||||
|
result:=self;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -50,6 +50,7 @@ type
|
|||||||
function GetCurrent: T; inline;
|
function GetCurrent: T; inline;
|
||||||
public
|
public
|
||||||
constructor Create(AVector: TVector);
|
constructor Create(AVector: TVector);
|
||||||
|
function GetEnumerator: TVectorEnumerator; inline;
|
||||||
function MoveNext: Boolean; inline;
|
function MoveNext: Boolean; inline;
|
||||||
property Current: T read GetCurrent;
|
property Current: T read GetCurrent;
|
||||||
end;
|
end;
|
||||||
@ -83,6 +84,11 @@ begin
|
|||||||
FVector := AVector;
|
FVector := AVector;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TVector.TVectorEnumerator.GetEnumerator: TVectorEnumerator;
|
||||||
|
begin
|
||||||
|
result:=self;
|
||||||
|
end;
|
||||||
|
|
||||||
function TVector.TVectorEnumerator.GetCurrent: T;
|
function TVector.TVectorEnumerator.GetCurrent: T;
|
||||||
begin
|
begin
|
||||||
Result := FVector[FPosition];
|
Result := FVector[FPosition];
|
||||||
|
Loading…
Reference in New Issue
Block a user