@@ -237,18 +237,15 @@ TInverse = class(TCollectionBase<TValueKeyPair>,
237237 end ;
238238
239239 TEnumerator = class (TRefCountedObject,
240- IEnumerator<TKeyValuePair>, IEnumerator<TKey>, IEnumerator<TValue>,
241- IEnumerator<TValueKeyPair>)
240+ IEnumerator<TKeyValuePair>, IEnumerator<TKey>, IEnumerator<TValue>)
242241 private
243242 { $IFDEF AUTOREFCOUNT} [Unsafe]{ $ENDIF}
244243 fSource: TBidiDictionary<TKey, TValue>;
245244 fItemIndex: Integer;
246245 fVersion: Integer;
247246 function GetCurrent : TKeyValuePair;
248- function GetCurrentInverse : TValueKeyPair;
249247 function GetCurrentKey : TKey;
250248 function GetCurrentValue : TValue;
251- function IEnumerator <TValueKeyPair>.GetCurrent = GetCurrentInverse;
252249 function IEnumerator <TKey>.GetCurrent = GetCurrentKey;
253250 function IEnumerator <TValue>.GetCurrent = GetCurrentValue;
254251 public
@@ -257,6 +254,11 @@ TEnumerator = class(TRefCountedObject,
257254 function MoveNext : Boolean;
258255 end ;
259256
257+ TInverseEnumerator = class (TEnumerator, IEnumerator<TValueKeyPair>)
258+ private
259+ function GetCurrent : TValueKeyPair;
260+ end ;
261+
260262 TKeyCollection = class (TEnumerableBase<TKey>,
261263 IEnumerable<TKey>, IReadOnlyCollection<TKey>)
262264 private
@@ -1946,7 +1948,7 @@ function TBidiDictionary<TKey, TValue>.TInverse.GetCount: Integer;
19461948
19471949function TBidiDictionary <TKey, TValue>.TInverse.GetEnumerator: IEnumerator<TValueKeyPair>;
19481950begin
1949- Result := TEnumerator .Create(fSource);
1951+ Result := TInverseEnumerator .Create(fSource);
19501952end ;
19511953
19521954function TBidiDictionary <TKey, TValue>.TInverse.GetInverse: IBidiDictionary<TKey, TValue>;
@@ -2170,12 +2172,6 @@ function TBidiDictionary<TKey, TValue>.TEnumerator.GetCurrent: TKeyValuePair;
21702172 Result.Value := fSource.fItems[fItemIndex].Value ;
21712173end ;
21722174
2173- function TBidiDictionary <TKey, TValue>.TEnumerator.GetCurrentInverse: TValueKeyPair;
2174- begin
2175- Result.Key := fSource.fItems[fItemIndex].Value ;
2176- Result.Value := fSource.fItems[fItemIndex].Key;
2177- end ;
2178-
21792175function TBidiDictionary <TKey, TValue>.TEnumerator.GetCurrentKey: TKey;
21802176begin
21812177 Result := fSource.fItems[fItemIndex].Key;
@@ -2194,6 +2190,17 @@ function TBidiDictionary<TKey, TValue>.TEnumerator.MoveNext: Boolean;
21942190{ $ENDREGION}
21952191
21962192
2193+ { $REGION 'TBidiDictionary<TKey, TValue>.TInverseEnumerator' }
2194+
2195+ function TBidiDictionary <TKey, TValue>.TInverseEnumerator.GetCurrent: TValueKeyPair;
2196+ begin
2197+ Result.Key := fSource.fItems[fItemIndex].Value ;
2198+ Result.Value := fSource.fItems[fItemIndex].Key;
2199+ end ;
2200+
2201+ { $ENDREGION}
2202+
2203+
21972204{ $REGION 'TBidiDictionary<TKey, TValue>.TKeyCollection'}
21982205
21992206constructor TBidiDictionary<TKey, TValue>.TKeyCollection.Create(
0 commit comments