@@ -88,7 +88,7 @@ TEnumerator = record
8888 { $REGION 'Property Accessors'}
8989 function GetCapacity : Integer; inline;
9090 function GetCount : Integer;
91- function GetIsEmpty : Boolean ;
91+ function GetCountFast : Integer ;
9292 function GetItem (const key: TKey): TValue;
9393 function GetKeys : IReadOnlyCollection<TKey>;
9494 function GetValues : IReadOnlyCollection<TValue>;
@@ -177,8 +177,8 @@ TInverse = class(TCollectionBase<TValueKeyPair>,
177177 { $REGION 'Property Accessors'}
178178 function GetCapacity : Integer;
179179 function GetCount : Integer;
180+ function GetCountFast : Integer;
180181 function GetInverse : IBidiDictionary<TKey, TValue>;
181- function GetIsEmpty : Boolean;
182182 function GetItem (const value : TValue): TKey;
183183 function GetKeys : IReadOnlyCollection<TValue>;
184184 function GetKeyType : PTypeInfo;
@@ -269,7 +269,7 @@ TKeyCollection = class(TEnumerableBase<TKey>,
269269 fSource: TBidiDictionary<TKey, TValue>;
270270 { $REGION 'Property Accessors'}
271271 function GetCount : Integer;
272- function GetIsEmpty : Boolean ;
272+ function GetCountFast : Integer ;
273273 { $ENDREGION}
274274 public
275275 constructor Create(const source: TBidiDictionary<TKey, TValue>);
@@ -293,7 +293,7 @@ TValueCollection = class(TEnumerableBase<TValue>,
293293 fSource: TBidiDictionary<TKey, TValue>;
294294 { $REGION 'Property Accessors'}
295295 function GetCount : Integer;
296- function GetIsEmpty : Boolean ;
296+ function GetCountFast : Integer ;
297297 { $ENDREGION}
298298 public
299299 constructor Create(const source: TBidiDictionary<TKey, TValue>);
@@ -329,8 +329,8 @@ TValueCollection = class(TEnumerableBase<TValue>,
329329 { $REGION 'Property Accessors'}
330330 function GetCapacity : Integer; inline;
331331 function GetCount : Integer;
332+ function GetCountFast : Integer;
332333 function GetInverse : IBidiDictionary<TValue, TKey>;
333- function GetIsEmpty : Boolean;
334334 function GetItem (const key: TKey): TValue;
335335 function GetKeys : IReadOnlyCollection<TKey>;
336336 function GetValues : IReadOnlyCollection<TValue>;
@@ -444,7 +444,7 @@ TKeyCollection = class(TEnumerableBase<TKey>,
444444 fSource: TSortedDictionary<TKey, TValue>;
445445 { $REGION 'Property Accessors'}
446446 function GetCount : Integer;
447- function GetIsEmpty : Boolean ;
447+ function GetCountFast : Integer ;
448448 { $ENDREGION}
449449 public
450450 constructor Create(const source: TSortedDictionary<TKey, TValue>);
@@ -467,7 +467,7 @@ TValueCollection = class(TEnumerableBase<TValue>,
467467 fSource: TSortedDictionary<TKey, TValue>;
468468 { $REGION 'Property Accessors'}
469469 function GetCount : Integer;
470- function GetIsEmpty : Boolean ;
470+ function GetCountFast : Integer ;
471471 { $ENDREGION}
472472 public
473473 constructor Create(const source: TSortedDictionary<TKey, TValue>);
@@ -494,7 +494,7 @@ TValueCollection = class(TEnumerableBase<TValue>,
494494 { $REGION 'Property Accessors'}
495495 function GetCapacity : Integer;
496496 function GetCount : Integer;
497- function GetIsEmpty : Boolean ;
497+ function GetCountFast : Integer ;
498498 function GetItem (const key: TKey): TValue;
499499 function GetKeys : IReadOnlyCollection<TKey>;
500500 function GetValues : IReadOnlyCollection<TValue>;
@@ -768,9 +768,9 @@ function TDictionary<TKey, TValue>.GetCount: Integer;
768768 Result := fHashTable.Count;
769769end ;
770770
771- function TDictionary <TKey, TValue>.GetIsEmpty: Boolean ;
771+ function TDictionary <TKey, TValue>.GetCountFast: Integer ;
772772begin
773- Result := fHashTable.Count = 0 ;
773+ Result := fHashTable.Count;
774774end ;
775775
776776procedure TDictionary <TKey, TValue>.Add(const key: TKey; const value : TValue);
@@ -1588,6 +1588,11 @@ function TBidiDictionary<TKey, TValue>.GetCount: Integer;
15881588 Result := fCount;
15891589end ;
15901590
1591+ function TBidiDictionary <TKey, TValue>.GetCountFast: Integer;
1592+ begin
1593+ Result := fCount;
1594+ end ;
1595+
15911596procedure TBidiDictionary <TKey, TValue>.AddOrSetKey(const value : TValue; const key: TKey);
15921597var
15931598 keyHashCode, keyBucketIndex, valueHashCode, valueBucketIndex, keyItemIndex, valueItemIndex: Integer;
@@ -1797,11 +1802,6 @@ function TBidiDictionary<TKey, TValue>.GetInverse: IBidiDictionary<TValue, TKey>
17971802 Result := fInverse;
17981803end ;
17991804
1800- function TBidiDictionary <TKey, TValue>.GetIsEmpty: Boolean;
1801- begin
1802- Result := fCount = 0 ;
1803- end ;
1804-
18051805function TBidiDictionary <TKey, TValue>.GetKeys: IReadOnlyCollection<TKey>;
18061806begin
18071807 Result := fKeys;
@@ -1973,6 +1973,11 @@ function TBidiDictionary<TKey, TValue>.TInverse.GetCount: Integer;
19731973 Result := fSource.fCount;
19741974end ;
19751975
1976+ function TBidiDictionary <TKey, TValue>.TInverse.GetCountFast: Integer;
1977+ begin
1978+ Result := fSource.fCount;
1979+ end ;
1980+
19761981function TBidiDictionary <TKey, TValue>.TInverse.GetEnumerator: IEnumerator<TValueKeyPair>;
19771982begin
19781983 Result := TInverseEnumerator.Create(fSource);
@@ -1983,13 +1988,7 @@ function TBidiDictionary<TKey, TValue>.TInverse.GetInverse: IBidiDictionary<TKey
19831988 Result := fSource;
19841989end ;
19851990
1986- function TBidiDictionary <TKey, TValue>.TInverse.GetIsEmpty: Boolean;
1987- begin
1988- Result := fSource.fCount = 0 ;
1989- end ;
1990-
1991- function TBidiDictionary <TKey, TValue>.TInverse.GetItem(
1992- const value : TValue): TKey;
1991+ function TBidiDictionary <TKey, TValue>.TInverse.GetItem(const value : TValue): TKey;
19931992var
19941993 valueBucketIndex, valueItemIndex: Integer;
19951994begin
@@ -2266,14 +2265,14 @@ function TBidiDictionary<TKey, TValue>.TKeyCollection.GetCount: Integer;
22662265 Result := fSource.fCount;
22672266end ;
22682267
2269- function TBidiDictionary <TKey, TValue>.TKeyCollection.GetEnumerator: IEnumerator<TKey> ;
2268+ function TBidiDictionary <TKey, TValue>.TKeyCollection.GetCountFast: Integer ;
22702269begin
2271- Result := TEnumerator.Create( fSource) ;
2270+ Result := fSource.fCount ;
22722271end ;
22732272
2274- function TBidiDictionary <TKey, TValue>.TKeyCollection.GetIsEmpty: Boolean ;
2273+ function TBidiDictionary <TKey, TValue>.TKeyCollection.GetEnumerator: IEnumerator<TKey> ;
22752274begin
2276- Result := fSource.fCount = 0 ;
2275+ Result := TEnumerator.Create(fSource) ;
22772276end ;
22782277
22792278function TBidiDictionary <TKey, TValue>.TKeyCollection.ToArray: TArray<TKey>;
@@ -2332,14 +2331,14 @@ function TBidiDictionary<TKey, TValue>.TValueCollection.GetCount: Integer;
23322331 Result := fSource.fCount;
23332332end ;
23342333
2335- function TBidiDictionary <TKey, TValue>.TValueCollection.GetEnumerator: IEnumerator<TValue> ;
2334+ function TBidiDictionary <TKey, TValue>.TValueCollection.GetCountFast: Integer ;
23362335begin
2337- Result := TEnumerator.Create( fSource) ;
2336+ Result := fSource.fCount ;
23382337end ;
23392338
2340- function TBidiDictionary <TKey, TValue>.TValueCollection.GetIsEmpty: Boolean ;
2339+ function TBidiDictionary <TKey, TValue>.TValueCollection.GetEnumerator: IEnumerator<TValue> ;
23412340begin
2342- Result := fSource.fCount = 0 ;
2341+ Result := TEnumerator.Create(fSource) ;
23432342end ;
23442343
23452344function TBidiDictionary <TKey, TValue>.TValueCollection.ToArray: TArray<TValue>;
@@ -2565,14 +2564,14 @@ function TSortedDictionary<TKey, TValue>.GetCount: Integer;
25652564 Result := fTree.Count;
25662565end ;
25672566
2568- function TSortedDictionary <TKey, TValue>.GetEnumerator: IEnumerator<TKeyValuePair> ;
2567+ function TSortedDictionary <TKey, TValue>.GetCountFast: Integer ;
25692568begin
2570- Result := TEnumerator.Create(Self) ;
2569+ Result := fTree.Count ;
25712570end ;
25722571
2573- function TSortedDictionary <TKey, TValue>.GetIsEmpty: Boolean ;
2572+ function TSortedDictionary <TKey, TValue>.GetEnumerator: IEnumerator<TKeyValuePair> ;
25742573begin
2575- Result := fTree.Count = 0 ;
2574+ Result := TEnumerator.Create(Self) ;
25762575end ;
25772576
25782577function TSortedDictionary <TKey, TValue>.GetItem(const key: TKey): TValue;
@@ -2825,14 +2824,14 @@ function TSortedDictionary<TKey, TValue>.TKeyCollection.GetCount: Integer;
28252824 Result := fSource.fTree.Count;
28262825end ;
28272826
2828- function TSortedDictionary <TKey, TValue>.TKeyCollection.GetEnumerator: IEnumerator<TKey> ;
2827+ function TSortedDictionary <TKey, TValue>.TKeyCollection.GetCountFast: Integer ;
28292828begin
2830- Result := TEnumerator.Create( fSource) ;
2829+ Result := fSource.fTree.Count ;
28312830end ;
28322831
2833- function TSortedDictionary <TKey, TValue>.TKeyCollection.GetIsEmpty: Boolean ;
2832+ function TSortedDictionary <TKey, TValue>.TKeyCollection.GetEnumerator: IEnumerator<TKey> ;
28342833begin
2835- Result := fSource.fTree.Count = 0 ;
2834+ Result := TEnumerator.Create(fSource) ;
28362835end ;
28372836
28382837function TSortedDictionary <TKey, TValue>.TKeyCollection.ToArray: TArray<TKey>;
@@ -2883,14 +2882,14 @@ function TSortedDictionary<TKey, TValue>.TValueCollection.GetCount: Integer;
28832882 Result := fSource.fTree.Count;
28842883end ;
28852884
2886- function TSortedDictionary <TKey, TValue>.TValueCollection.GetEnumerator: IEnumerator<TValue> ;
2885+ function TSortedDictionary <TKey, TValue>.TValueCollection.GetCountFast: Integer ;
28872886begin
2888- Result := TEnumerator.Create( fSource) ;
2887+ Result := fSource.fTree.Count ;
28892888end ;
28902889
2891- function TSortedDictionary <TKey, TValue>.TValueCollection.GetIsEmpty: Boolean ;
2890+ function TSortedDictionary <TKey, TValue>.TValueCollection.GetEnumerator: IEnumerator<TValue> ;
28922891begin
2893- Result := fSource.fTree.Count = 0 ;
2892+ Result := TEnumerator.Create(fSource) ;
28942893end ;
28952894
28962895function TSortedDictionary <TKey, TValue>.TValueCollection.ToArray: TArray<TValue>;
0 commit comments