瀏覽代碼

* change constref parameters to const for Delphi compatibility as well as better code generation

(cherry picked from commit 693491048bf2c6f9122a0d8b044ad0e55382354d)
Sven/Sarah Barth 2 年之前
父節點
當前提交
b037b005ae

+ 133 - 133
packages/rtl-generics/src/generics.collections.pas

@@ -80,19 +80,19 @@ type
     class procedure Sort(var AValues: array of T;
       const AComparer: IComparer<T>; AIndex, ACount: SizeInt); overload;
 
-    class function BinarySearch(constref AValues: array of T; constref AItem: T;
+    class function BinarySearch(const AValues: array of T; const AItem: T;
       out ASearchResult: TBinarySearchResult; const AComparer: IComparer<T>;
       AIndex, ACount: SizeInt): Boolean; virtual; abstract; overload;
-    class function BinarySearch(constref AValues: array of T; constref AItem: T;
+    class function BinarySearch(const AValues: array of T; const AItem: T;
       out AFoundIndex: SizeInt; const AComparer: IComparer<T>;
       AIndex, ACount: SizeInt): Boolean; virtual; abstract; overload;
-    class function BinarySearch(constref AValues: array of T; constref AItem: T;
+    class function BinarySearch(const AValues: array of T; const AItem: T;
       out AFoundIndex: SizeInt; const AComparer: IComparer<T>): Boolean; overload;
-    class function BinarySearch(constref AValues: array of T; constref AItem: T;
+    class function BinarySearch(const AValues: array of T; const AItem: T;
       out AFoundIndex: SizeInt): Boolean; overload;
-    class function BinarySearch(constref AValues: array of T; constref AItem: T;
+    class function BinarySearch(const AValues: array of T; const AItem: T;
       out ASearchResult: TBinarySearchResult; const AComparer: IComparer<T>): Boolean; overload;
-    class function BinarySearch(constref AValues: array of T; constref AItem: T;
+    class function BinarySearch(const AValues: array of T; const AItem: T;
       out ASearchResult: TBinarySearchResult): Boolean; overload;
   end {$ifdef EXTRA_WARNINGS}experimental{$endif}; // will be renamed to TCustomArray (bug #24254)
 
@@ -107,16 +107,16 @@ type
   protected
     class procedure QuickSort(var AValues: array of T; ALeft, ARight: SizeInt; const AComparer: IComparer<T>); override;
   public
-    class function BinarySearch(constref AValues: array of T; constref AItem: T;
+    class function BinarySearch(const AValues: array of T; const AItem: T;
       out ASearchResult: TBinarySearchResult; const AComparer: IComparer<T>;
       AIndex, ACount: SizeInt): Boolean; override; overload;
-    class function BinarySearch(constref AValues: array of T; constref AItem: T;
+    class function BinarySearch(const AValues: array of T; const AItem: T;
       out AFoundIndex: SizeInt; const AComparer: IComparer<T>;
       AIndex, ACount: SizeInt): Boolean; override; overload;
   end {$ifdef EXTRA_WARNINGS}experimental{$endif}; // will be renamed to TArray (bug #24254)
 
   TCollectionNotification = (cnAdded, cnRemoved, cnExtracted);
-  TCollectionNotifyEvent<T> = procedure(ASender: TObject; constref AItem: T; AAction: TCollectionNotification)
+  TCollectionNotifyEvent<T> = procedure(ASender: TObject; const AItem: T; AAction: TCollectionNotification)
     of object;
 
   { TEnumerator }
@@ -187,7 +187,7 @@ type
 
     function PrepareAddingItem: SizeInt; virtual;
     function PrepareAddingRange(ACount: SizeInt): SizeInt; virtual;
-    procedure Notify(constref AValue: T; ACollectionNotification: TCollectionNotification); virtual;
+    procedure Notify(const AValue: T; ACollectionNotification: TCollectionNotification); virtual;
     function DoRemove(AIndex: SizeInt; ACollectionNotification: TCollectionNotification): T; virtual;
     procedure SetCapacity(AValue: SizeInt); virtual; abstract;
     function GetCount: SizeInt; virtual;
@@ -247,7 +247,7 @@ type
     procedure SetCapacity(AValue: SizeInt); override;
     procedure SetCount(AValue: SizeInt);
     procedure InitializeList; virtual;
-    procedure InternalInsert(AIndex: SizeInt; constref AValue: T);
+    procedure InternalInsert(AIndex: SizeInt; const AValue: T);
   private
     function GetItem(AIndex: SizeInt): T;
     procedure SetItem(AIndex: SizeInt; const AValue: T);
@@ -260,27 +260,27 @@ type
     {$ENDIF}
     destructor Destroy; override;
 
-    function Add(constref AValue: T): SizeInt; virtual;
-    procedure AddRange(constref AValues: array of T); virtual; overload;
+    function Add(const AValue: T): SizeInt; virtual;
+    procedure AddRange(const AValues: array of T); virtual; overload;
     procedure AddRange(const AEnumerable: IEnumerable<T>); overload;
     procedure AddRange(AEnumerable: TEnumerable<T>); overload;
     {$IFDEF ENABLE_METHODS_WITH_TEnumerableWithPointers}
     procedure AddRange(AEnumerable: TEnumerableWithPointers<T>); overload;
     {$ENDIF}
 
-    procedure Insert(AIndex: SizeInt; constref AValue: T); virtual;
-    procedure InsertRange(AIndex: SizeInt; constref AValues: array of T); virtual; overload;
+    procedure Insert(AIndex: SizeInt; const AValue: T); virtual;
+    procedure InsertRange(AIndex: SizeInt; const AValues: array of T); virtual; overload;
     procedure InsertRange(AIndex: SizeInt; const AEnumerable: IEnumerable<T>); overload;
     procedure InsertRange(AIndex: SizeInt; const AEnumerable: TEnumerable<T>); overload;
     {$IFDEF ENABLE_METHODS_WITH_TEnumerableWithPointers}
     procedure InsertRange(AIndex: SizeInt; const AEnumerable: TEnumerableWithPointers<T>); overload;
     {$ENDIF}
 
-    function Remove(constref AValue: T): SizeInt;
+    function Remove(const AValue: T): SizeInt;
     procedure Delete(AIndex: SizeInt); inline;
     procedure DeleteRange(AIndex, ACount: SizeInt);
     function ExtractIndex(const AIndex: SizeInt): T; overload;
-    function Extract(constref AValue: T): T; overload;
+    function Extract(const AValue: T): T; overload;
 
     procedure Exchange(AIndex1, AIndex2: SizeInt); virtual;
     procedure Move(AIndex, ANewIndex: SizeInt); virtual;
@@ -290,9 +290,9 @@ type
 
     procedure Clear;
 
-    function Contains(constref AValue: T): Boolean; inline;
-    function IndexOf(constref AValue: T): SizeInt; virtual;
-    function LastIndexOf(constref AValue: T): SizeInt; virtual;
+    function Contains(const AValue: T): Boolean; inline;
+    function IndexOf(const AValue: T): SizeInt; virtual;
+    function LastIndexOf(const AValue: T): SizeInt; virtual;
 
     procedure Reverse;
 
@@ -300,8 +300,8 @@ type
 
     procedure Sort; overload;
     procedure Sort(const AComparer: IComparer<T>); overload;
-    function BinarySearch(constref AItem: T; out AIndex: SizeInt): Boolean; overload;
-    function BinarySearch(constref AItem: T; out AIndex: SizeInt; const AComparer: IComparer<T>): Boolean; overload;
+    function BinarySearch(const AItem: T; out AIndex: SizeInt): Boolean; overload;
+    function BinarySearch(const AItem: T; out AIndex: SizeInt; const AComparer: IComparer<T>): Boolean; overload;
 
     property Count: SizeInt read FLength write SetCount;
     property Items[Index: SizeInt]: T read GetItem write SetItem; default;
@@ -320,12 +320,12 @@ type
   protected
     procedure InitializeList; override;
   public
-    function Add(constref AValue: T): SizeInt; override; overload;
-    procedure AddRange(constref AValues: array of T); override; overload;
-    procedure Insert(AIndex: SizeInt; constref AValue: T); override;
+    function Add(const AValue: T): SizeInt; override; overload;
+    procedure AddRange(const AValues: array of T); override; overload;
+    procedure Insert(AIndex: SizeInt; const AValue: T); override;
     procedure Exchange(AIndex1, AIndex2: SizeInt); override;
     procedure Move(AIndex, ANewIndex: SizeInt); override;
-    procedure InsertRange(AIndex: SizeInt; constref AValues: array of T); override; overload;
+    procedure InsertRange(AIndex: SizeInt; const AValues: array of T); override; overload;
     property Duplicates: TDuplicates read FDuplicates write FDuplicates;
     property Sorted: Boolean read GetSorted write SetSorted;
     property SortStyle: TCollectionSortStyle read FSortStyle write SetSortStyle;
@@ -342,8 +342,8 @@ type
     constructor Create;
     destructor Destroy; override;
 
-    procedure Add(constref AValue: T);
-    procedure Remove(constref AValue: T);
+    procedure Add(const AValue: T);
+    procedure Remove(const AValue: T);
     procedure Clear;
 
     function LockList: TList<T>;
@@ -392,7 +392,7 @@ type
     constructor Create(ACollection: TEnumerableWithPointers<T>); overload;
     {$ENDIF}
     destructor Destroy; override;
-    procedure Enqueue(constref AValue: T);
+    procedure Enqueue(const AValue: T);
     function Dequeue: T;
     function Extract: T;
     function Peek: T;
@@ -421,7 +421,7 @@ type
     {$ENDIF}
     destructor Destroy; override;
     procedure Clear;
-    procedure Push(constref AValue: T);
+    procedure Push(const AValue: T);
     function Pop: T; inline;
     function Peek: T;
     function Extract: T; inline;
@@ -432,7 +432,7 @@ type
   private
     FObjectsOwner: Boolean;
   protected
-    procedure Notify(constref AValue: T; ACollectionNotification: TCollectionNotification); override;
+    procedure Notify(const AValue: T; ACollectionNotification: TCollectionNotification); override;
   public
     constructor Create(AOwnsObjects: Boolean = True); overload;
     constructor Create(const AComparer: IComparer<T>; AOwnsObjects: Boolean = True); overload;
@@ -447,7 +447,7 @@ type
   private
     FObjectsOwner: Boolean;
   protected
-    procedure Notify(constref AValue: T; ACollectionNotification: TCollectionNotification); override;
+    procedure Notify(const AValue: T; ACollectionNotification: TCollectionNotification); override;
   public
     constructor Create(AOwnsObjects: Boolean = True); overload;
     constructor Create(ACollection: TEnumerable<T>; AOwnsObjects: Boolean = True); overload;
@@ -462,7 +462,7 @@ type
   private
     FObjectsOwner: Boolean;
   protected
-    procedure Notify(constref AValue: T; ACollectionNotification: TCollectionNotification); override;
+    procedure Notify(const AValue: T; ACollectionNotification: TCollectionNotification); override;
   public
     constructor Create(AOwnsObjects: Boolean = True); overload;
     constructor Create(ACollection: TEnumerable<T>; AOwnsObjects: Boolean = True); overload;
@@ -510,13 +510,13 @@ type
     {$ENDIF}
     function GetEnumerator: TCustomSetEnumerator; reintroduce; virtual; abstract;
 
-    function Add(constref AValue: T): Boolean; virtual; abstract;
-    function Remove(constref AValue: T): Boolean; virtual; abstract;
-    function Extract(constref AValue: T): T; virtual; abstract;
+    function Add(const AValue: T): Boolean; virtual; abstract;
+    function Remove(const AValue: T): Boolean; virtual; abstract;
+    function Extract(const AValue: T): T; virtual; abstract;
 
     procedure Clear; virtual; abstract;
-    function Contains(constref AValue: T): Boolean; virtual; abstract;
-    function AddRange(constref AValues: array of T): Boolean; overload;
+    function Contains(const AValue: T): Boolean; virtual; abstract;
+    function AddRange(const AValues: array of T): Boolean; overload;
     function AddRange(const AEnumerable: IEnumerable<T>): Boolean; overload;
     function AddRange(AEnumerable: TEnumerable<T>): Boolean; overload;
     {$IFDEF ENABLE_METHODS_WITH_TEnumerableWithPointers}
@@ -538,7 +538,7 @@ type
 
   THashSet<T> = class(TCustomSet<T>)
   private
-    procedure InternalDictionaryNotify(ASender: TObject; constref AItem: T; AAction: TCollectionNotification);
+    procedure InternalDictionaryNotify(ASender: TObject; const AItem: T; AAction: TCollectionNotification);
   protected
     FInternalDictionary: TOpenAddressingLP<T, TEmptyRecord>;
   public type
@@ -571,12 +571,12 @@ type
     destructor Destroy; override;
     function GetEnumerator: TCustomSetEnumerator; override;
 
-    function Add(constref AValue: T): Boolean; override;
-    function Remove(constref AValue: T): Boolean; override;
-    function Extract(constref AValue: T): T; override;
+    function Add(const AValue: T): Boolean; override;
+    function Remove(const AValue: T): Boolean; override;
+    function Extract(const AValue: T): T; override;
 
     procedure Clear; override;
-    function Contains(constref AValue: T): Boolean; override;
+    function Contains(const AValue: T): Boolean; override;
 
     procedure TrimExcess; override;
   end;
@@ -674,7 +674,7 @@ type
     function DoRemove(ANode: PNode; ACollectionNotification: TCollectionNotification; ADispose: boolean): TValue;
     procedure DisposeAllNodes(ANode: PNode); overload;
 
-    function Compare(constref ALeft, ARight: TKey): Integer; inline;
+    function Compare(const ALeft, ARight: TKey): Integer; inline;
     function FindPredecessor(ANode: PNode): PNode;
     function FindInsertNode(ANode: PNode; out AInsertNode: PNode): Integer;
 
@@ -683,10 +683,10 @@ type
     procedure RotateRightLeft(ANode: PNode); virtual;
     procedure RotateLeftRight(ANode: PNode); virtual;
 
-    procedure KeyNotify(constref AKey: TKey; ACollectionNotification: TCollectionNotification); inline;
-    procedure ValueNotify(constref AValue: TValue; ACollectionNotification: TCollectionNotification); inline;
+    procedure KeyNotify(const AKey: TKey; ACollectionNotification: TCollectionNotification); inline;
+    procedure ValueNotify(const AValue: TValue; ACollectionNotification: TCollectionNotification); inline;
     procedure NodeNotify(ANode: PNode; ACollectionNotification: TCollectionNotification; ADispose: boolean); inline;
-    procedure SetValue(var AValue: TValue; constref ANewValue: TValue);
+    procedure SetValue(var AValue: TValue; const ANewValue: TValue);
     function GetItem(const AKey: TKey): TValue;
     procedure SetItem(const AKey: TKey; const AValue: TValue);
 
@@ -753,12 +753,12 @@ type
 
     destructor Destroy; override;
     function AddNode(ANode: PNode): boolean; overload; inline;
-    function Add(constref APair: TTreePair): PNode; overload; inline;
-    function Add(constref AKey: TKey; constref AValue: TValue): PNode; overload; inline;
-    function Remove(constref AKey: TKey; ADisposeNode: boolean = true): boolean;
-    function ExtractPair(constref AKey: TKey; ADisposeNode: boolean = true): TTreePair; overload;
-    function ExtractPair(constref ANode: PNode; ADispose: boolean = true): TTreePair; overload;
-    function Extract(constref AKey: TKey; ADisposeNode: boolean): PNode;
+    function Add(const APair: TTreePair): PNode; overload; inline;
+    function Add(const AKey: TKey; const AValue: TValue): PNode; overload; inline;
+    function Remove(const AKey: TKey; ADisposeNode: boolean = true): boolean;
+    function ExtractPair(const AKey: TKey; ADisposeNode: boolean = true): TTreePair; overload;
+    function ExtractPair(const ANode: PNode; ADispose: boolean = true): TTreePair; overload;
+    function Extract(const AKey: TKey; ADisposeNode: boolean): PNode;
     function ExtractNode(ANode: PNode; ADispose: boolean): PNode;
     procedure Delete(ANode: PNode; ADispose: boolean = true); inline;
 
@@ -773,9 +773,9 @@ type
     property Count: SizeInt read FCount;
 
     property Root: PNode read FRoot;
-    function Find(constref AKey: TKey): PNode;
-    function ContainsKey(constref AKey: TKey; out ANode: PNode): boolean; overload; inline;
-    function ContainsKey(constref AKey: TKey): boolean; overload; inline;
+    function Find(const AKey: TKey): PNode;
+    function ContainsKey(const AKey: TKey; out ANode: PNode): boolean; overload; inline;
+    function ContainsKey(const AKey: TKey): boolean; overload; inline;
 
     procedure ConsistencyCheck; virtual;
     procedure WriteTreeNode(AStream: TStream; ANode: PNode);
@@ -825,7 +825,7 @@ type
   public type
     TItemEnumerator = TKeyEnumerator;
   public
-    function Add(constref AValue: T): PNode; reintroduce; inline;
+    function Add(const AValue: T): PNode; reintroduce; inline;
     function AddNode(ANode: PNode): boolean; reintroduce; inline;
 
     property OnNotify: TCollectionNotifyEvent<T> read FOnKeyNotify write FOnKeyNotify;
@@ -838,7 +838,7 @@ type
   public type
     TItemEnumerator = TKeyEnumerator;
   public
-    function Add(constref AValue: T): PNode; reintroduce; inline;
+    function Add(const AValue: T): PNode; reintroduce; inline;
     function AddNode(ANode: PNode): boolean; reintroduce; inline;
 
     property OnNotify: TCollectionNotifyEvent<T> read FOnKeyNotify write FOnKeyNotify;
@@ -846,7 +846,7 @@ type
 
   TSortedSet<T> = class(TCustomSet<T>)
   private
-    procedure InternalAVLTreeNotify(ASender: TObject; constref AItem: T; AAction: TCollectionNotification);
+    procedure InternalAVLTreeNotify(ASender: TObject; const AItem: T; AAction: TCollectionNotification);
   protected
     FInternalTree: TAVLTree<T>;
   public type
@@ -879,18 +879,18 @@ type
     destructor Destroy; override;
     function GetEnumerator: TCustomSetEnumerator; override;
 
-    function Add(constref AValue: T): Boolean; override;
-    function Remove(constref AValue: T): Boolean; override;
-    function Extract(constref AValue: T): T; override;
+    function Add(const AValue: T): Boolean; override;
+    function Remove(const AValue: T): Boolean; override;
+    function Extract(const AValue: T): T; override;
     procedure Clear; override;
-    function Contains(constref AValue: T): Boolean; override;
+    function Contains(const AValue: T): Boolean; override;
 
     procedure TrimExcess; override;
   end;
 
   TSortedHashSet<T> = class(TCustomSet<T>)
   private
-    procedure InternalDictionaryNotify(ASender: TObject; constref AItem: PT; AAction: TCollectionNotification);
+    procedure InternalDictionaryNotify(ASender: TObject; const AItem: PT; AAction: TCollectionNotification);
   protected
     FInternalDictionary: TOpenAddressingLP<PT, TEmptyRecord>;
     FInternalTree: TAVLTree<T>;
@@ -905,8 +905,8 @@ type
     private
       FComparer: IComparer<T>;
       FEqualityComparer: IEqualityComparer<T>;
-      function Equals(constref ALeft, ARight: PT): Boolean;
-      function GetHashCode(constref AValue: PT): UInt32;
+      function Equals(const ALeft, ARight: PT): Boolean;
+      function GetHashCode(const AValue: PT): UInt32;
     public
       constructor Create(const AComparer: IComparer<T>); overload;
       constructor Create(const AEqualityComparer: IEqualityComparer<T>); overload;
@@ -939,11 +939,11 @@ type
     destructor Destroy; override;
     function GetEnumerator: TCustomSetEnumerator; override;
 
-    function Add(constref AValue: T): Boolean; override;
-    function Remove(constref AValue: T): Boolean; override;
-    function Extract(constref AValue: T): T; override;
+    function Add(const AValue: T): Boolean; override;
+    function Remove(const AValue: T): Boolean; override;
+    function Extract(const AValue: T): T; override;
     procedure Clear; override;
-    function Contains(constref AValue: T): Boolean; override;
+    function Contains(const AValue: T): Boolean; override;
 
     procedure TrimExcess; override;
   end;
@@ -965,25 +965,25 @@ end;
 
 { TCustomArrayHelper<T> }
 
-class function TCustomArrayHelper<T>.BinarySearch(constref AValues: array of T; constref AItem: T;
+class function TCustomArrayHelper<T>.BinarySearch(const AValues: array of T; const AItem: T;
   out AFoundIndex: SizeInt; const AComparer: IComparer<T>): Boolean;
 begin
   Result := BinarySearch(AValues, AItem, AFoundIndex, AComparer, Low(AValues), Length(AValues));
 end;
 
-class function TCustomArrayHelper<T>.BinarySearch(constref AValues: array of T; constref AItem: T;
+class function TCustomArrayHelper<T>.BinarySearch(const AValues: array of T; const AItem: T;
   out AFoundIndex: SizeInt): Boolean;
 begin
   Result := BinarySearch(AValues, AItem, AFoundIndex, TComparerBugHack.Default, Low(AValues), Length(AValues));
 end;
 
-class function TCustomArrayHelper<T>.BinarySearch(constref AValues: array of T; constref AItem: T;
+class function TCustomArrayHelper<T>.BinarySearch(const AValues: array of T; const AItem: T;
   out ASearchResult: TBinarySearchResult; const AComparer: IComparer<T>): Boolean;
 begin
   Result := BinarySearch(AValues, AItem, ASearchResult, AComparer, Low(AValues), Length(AValues));
 end;
 
-class function TCustomArrayHelper<T>.BinarySearch(constref AValues: array of T; constref AItem: T;
+class function TCustomArrayHelper<T>.BinarySearch(const AValues: array of T; const AItem: T;
   out ASearchResult: TBinarySearchResult): Boolean;
 begin
   Result := BinarySearch(AValues, AItem, ASearchResult, TComparerBugHack.Default, Low(AValues), Length(AValues));
@@ -1129,7 +1129,7 @@ begin
   QSort(PT(AValues) + ALeft, ARight - ALeft + 1, ARight - ALeft + 1, AComparer);
 end;
 
-class function TArrayHelper<T>.BinarySearch(constref AValues: array of T; constref AItem: T;
+class function TArrayHelper<T>.BinarySearch(const AValues: array of T; const AItem: T;
   out ASearchResult: TBinarySearchResult; const AComparer: IComparer<T>;
   AIndex, ACount: SizeInt): Boolean;
 var
@@ -1199,7 +1199,7 @@ begin
   end;
 end;
 
-class function TArrayHelper<T>.BinarySearch(constref AValues: array of T; constref AItem: T;
+class function TArrayHelper<T>.BinarySearch(const AValues: array of T; const AItem: T;
   out AFoundIndex: SizeInt; const AComparer: IComparer<T>;
   AIndex, ACount: SizeInt): Boolean;
 var
@@ -1382,7 +1382,7 @@ begin
   Result := FLength;
 end;
 
-procedure TCustomList<T>.Notify(constref AValue: T; ACollectionNotification: TCollectionNotification);
+procedure TCustomList<T>.Notify(const AValue: T; ACollectionNotification: TCollectionNotification);
 begin
   if Assigned(FOnNotify) then
     FOnNotify(Self, AValue, ACollectionNotification);
@@ -1554,14 +1554,14 @@ begin
   Result := GetEnumerator;
 end;
 
-function TList<T>.Add(constref AValue: T): SizeInt;
+function TList<T>.Add(const AValue: T): SizeInt;
 begin
   Result := PrepareAddingItem;
   FItems[Result] := AValue;
   Notify(AValue, cnAdded);
 end;
 
-procedure TList<T>.AddRange(constref AValues: array of T);
+procedure TList<T>.AddRange(const AValues: array of T);
 begin
   InsertRange(Count, AValues);
 end;
@@ -1592,7 +1592,7 @@ begin
 end;
 {$ENDIF}
 
-procedure TList<T>.InternalInsert(AIndex: SizeInt; constref AValue: T);
+procedure TList<T>.InternalInsert(AIndex: SizeInt; const AValue: T);
 begin
   if AIndex <> PrepareAddingItem then
   begin
@@ -1604,7 +1604,7 @@ begin
   Notify(AValue, cnAdded);
 end;
 
-procedure TList<T>.Insert(AIndex: SizeInt; constref AValue: T);
+procedure TList<T>.Insert(AIndex: SizeInt; const AValue: T);
 begin
   if (AIndex < 0) or (AIndex > Count) then
     raise EArgumentOutOfRangeException.CreateRes(@SArgumentOutOfRange);
@@ -1612,7 +1612,7 @@ begin
   InternalInsert(AIndex, AValue);
 end;
 
-procedure TList<T>.InsertRange(AIndex: SizeInt; constref AValues: array of T);
+procedure TList<T>.InsertRange(AIndex: SizeInt; const AValues: array of T);
 var
   i: SizeInt;
   LLength: SizeInt;
@@ -1690,7 +1690,7 @@ begin
 end;
 {$ENDIF}
 
-function TList<T>.Remove(constref AValue: T): SizeInt;
+function TList<T>.Remove(const AValue: T): SizeInt;
 begin
   Result := IndexOf(AValue);
   if Result >= 0 then
@@ -1739,7 +1739,7 @@ begin
   Result := DoRemove(AIndex, cnExtracted);
 end;
 
-function TList<T>.Extract(constref AValue: T): T;
+function TList<T>.Extract(const AValue: T): T;
 var
   LIndex: SizeInt;
 begin
@@ -1802,12 +1802,12 @@ begin
   SetCapacity(Count);
 end;
 
-function TList<T>.Contains(constref AValue: T): Boolean;
+function TList<T>.Contains(const AValue: T): Boolean;
 begin
   Result := IndexOf(AValue) >= 0;
 end;
 
-function TList<T>.IndexOf(constref AValue: T): SizeInt;
+function TList<T>.IndexOf(const AValue: T): SizeInt;
 var
   i: SizeInt;
 begin
@@ -1817,7 +1817,7 @@ begin
   Result := -1;
 end;
 
-function TList<T>.LastIndexOf(constref AValue: T): SizeInt;
+function TList<T>.LastIndexOf(const AValue: T): SizeInt;
 var
   i: SizeInt;
 begin
@@ -1854,12 +1854,12 @@ begin
   TArrayHelperBugHack.Sort(FItems, AComparer, 0, Count);
 end;
 
-function TList<T>.BinarySearch(constref AItem: T; out AIndex: SizeInt): Boolean;
+function TList<T>.BinarySearch(const AItem: T; out AIndex: SizeInt): Boolean;
 begin
   Result := TArrayHelperBugHack.BinarySearch(FItems, AItem, AIndex, FComparer, 0, Count);
 end;
 
-function TList<T>.BinarySearch(constref AItem: T; out AIndex: SizeInt; const AComparer: IComparer<T>): Boolean;
+function TList<T>.BinarySearch(const AItem: T; out AIndex: SizeInt; const AComparer: IComparer<T>): Boolean;
 begin
   Result := TArrayHelperBugHack.BinarySearch(FItems, AItem, AIndex, AComparer, 0, Count);
 end;
@@ -1871,7 +1871,7 @@ begin
   FSortStyle := cssAuto;
 end;
 
-function TSortedList<T>.Add(constref AValue: T): SizeInt;
+function TSortedList<T>.Add(const AValue: T): SizeInt;
 var
   LSearchResult: TBinarySearchResult;
 begin
@@ -1897,7 +1897,7 @@ begin
   InternalInsert(Result, AValue);
 end;
 
-procedure TSortedList<T>.Insert(AIndex: SizeInt; constref AValue: T);
+procedure TSortedList<T>.Insert(AIndex: SizeInt; const AValue: T);
 begin
   if FSortStyle = cssAuto then
     raise EListError.Create(SSortedListError)
@@ -1921,7 +1921,7 @@ begin
     inherited;
 end;
 
-procedure TSortedList<T>.AddRange(constref AValues: array of T);
+procedure TSortedList<T>.AddRange(const AValues: array of T);
 var
   i: T;
 begin
@@ -1929,7 +1929,7 @@ begin
     Add(i);
 end;
 
-procedure TSortedList<T>.InsertRange(AIndex: SizeInt; constref AValues: array of T);
+procedure TSortedList<T>.InsertRange(AIndex: SizeInt; const AValues: array of T);
 var
   LValue: T;
   i:  SizeInt;
@@ -2020,7 +2020,7 @@ begin
   end;
 end;
 
-procedure TThreadList<T>.Add(constref AValue: T);
+procedure TThreadList<T>.Add(const AValue: T);
 begin
   LockList;
   try
@@ -2033,7 +2033,7 @@ begin
   end;
 end;
 
-procedure TThreadList<T>.Remove(constref AValue: T);
+procedure TThreadList<T>.Remove(const AValue: T);
 begin
   LockList;
   try
@@ -2213,7 +2213,7 @@ begin
   Clear;
 end;
 
-procedure TQueue<T>.Enqueue(constref AValue: T);
+procedure TQueue<T>.Enqueue(const AValue: T);
 var
   LIndex: SizeInt;
 begin
@@ -2313,7 +2313,7 @@ begin
   SetLength(FItems, AValue);
 end;
 
-procedure TStack<T>.Push(constref AValue: T);
+procedure TStack<T>.Push(const AValue: T);
 var
   LIndex: SizeInt;
 begin
@@ -2347,7 +2347,7 @@ end;
 
 { TObjectList<T> }
 
-procedure TObjectList<T>.Notify(constref AValue: T; ACollectionNotification: TCollectionNotification);
+procedure TObjectList<T>.Notify(const AValue: T; ACollectionNotification: TCollectionNotification);
 begin
   inherited Notify(AValue, ACollectionNotification);
 
@@ -2387,7 +2387,7 @@ end;
 
 { TObjectQueue<T> }
 
-procedure TObjectQueue<T>.Notify(constref AValue: T; ACollectionNotification: TCollectionNotification);
+procedure TObjectQueue<T>.Notify(const AValue: T; ACollectionNotification: TCollectionNotification);
 begin
   inherited Notify(AValue, ACollectionNotification);
   if FObjectsOwner and (ACollectionNotification = cnRemoved) then
@@ -2424,7 +2424,7 @@ end;
 
 { TObjectStack<T> }
 
-procedure TObjectStack<T>.Notify(constref AValue: T; ACollectionNotification: TCollectionNotification);
+procedure TObjectStack<T>.Notify(const AValue: T; ACollectionNotification: TCollectionNotification);
 begin
   inherited Notify(AValue, ACollectionNotification);
   if FObjectsOwner and (ACollectionNotification = cnRemoved) then
@@ -2505,7 +2505,7 @@ begin
 end;
 {$ENDIF}
 
-function TCustomSet<T>.AddRange(constref AValues: array of T): Boolean;
+function TCustomSet<T>.AddRange(const AValues: array of T): Boolean;
 var
   i: T;
 begin
@@ -2626,7 +2626,7 @@ end;
 
 { THashSet<T> }
 
-procedure THashSet<T>.InternalDictionaryNotify(ASender: TObject; constref AItem: T; AAction: TCollectionNotification);
+procedure THashSet<T>.InternalDictionaryNotify(ASender: TObject; const AItem: T; AAction: TCollectionNotification);
 begin
   FOnNotify(Self, AItem, AAction);
 end;
@@ -2685,14 +2685,14 @@ begin
   FInternalDictionary.Free;
 end;
 
-function THashSet<T>.Add(constref AValue: T): Boolean;
+function THashSet<T>.Add(const AValue: T): Boolean;
 begin
   Result := not FInternalDictionary.ContainsKey(AValue);
   if Result then
     FInternalDictionary.Add(AValue, EmptyRecord);
 end;
 
-function THashSet<T>.Remove(constref AValue: T): Boolean;
+function THashSet<T>.Remove(const AValue: T): Boolean;
 var
   LIndex: SizeInt;
 begin
@@ -2702,7 +2702,7 @@ begin
     FInternalDictionary.DoRemove(LIndex, cnRemoved);
 end;
 
-function THashSet<T>.Extract(constref AValue: T): T;
+function THashSet<T>.Extract(const AValue: T): T;
 var
   LIndex: SizeInt;
 begin
@@ -2719,7 +2719,7 @@ begin
   FInternalDictionary.Clear;
 end;
 
-function THashSet<T>.Contains(constref AValue: T): Boolean;
+function THashSet<T>.Contains(const AValue: T): Boolean;
 begin
   Result := FInternalDictionary.ContainsKey(AValue);
 end;
@@ -2963,7 +2963,7 @@ begin
   Dispose(ANode);
 end;
 
-function TCustomAVLTreeMap<TREE_CONSTRAINTS>.Compare(constref ALeft, ARight: TKey): Integer; inline;
+function TCustomAVLTreeMap<TREE_CONSTRAINTS>.Compare(const ALeft, ARight: TKey): Integer; inline;
 begin
   Result := FComparer.Compare(ALeft, ARight);
 end;
@@ -3194,13 +3194,13 @@ begin
   LRight.Balance := 0;
 end;
 
-procedure TCustomAVLTreeMap<TREE_CONSTRAINTS>.KeyNotify(constref AKey: TKey; ACollectionNotification: TCollectionNotification);
+procedure TCustomAVLTreeMap<TREE_CONSTRAINTS>.KeyNotify(const AKey: TKey; ACollectionNotification: TCollectionNotification);
 begin
   if Assigned(FOnKeyNotify) then
     FOnKeyNotify(Self, AKey, ACollectionNotification);
 end;
 
-procedure TCustomAVLTreeMap<TREE_CONSTRAINTS>.ValueNotify(constref AValue: TValue; ACollectionNotification: TCollectionNotification);
+procedure TCustomAVLTreeMap<TREE_CONSTRAINTS>.ValueNotify(const AValue: TValue; ACollectionNotification: TCollectionNotification);
 begin
   if Assigned(FOnValueNotify) then
     FOnValueNotify(Self, AValue, ACollectionNotification);
@@ -3214,7 +3214,7 @@ begin
   ValueNotify(ANode.Value, ACollectionNotification);
 end;
 
-procedure TCustomAVLTreeMap<TREE_CONSTRAINTS>.SetValue(var AValue: TValue; constref ANewValue: TValue);
+procedure TCustomAVLTreeMap<TREE_CONSTRAINTS>.SetValue(var AValue: TValue; const ANewValue: TValue);
 var
   LOldValue: TValue;
 begin
@@ -3538,7 +3538,7 @@ begin
   Result := ANode=InternalAdd(ANode, false);
 end;
 
-function TCustomAVLTreeMap<TREE_CONSTRAINTS>.Add(constref APair: TTreePair): PNode;
+function TCustomAVLTreeMap<TREE_CONSTRAINTS>.Add(const APair: TTreePair): PNode;
 begin
   Result := NewNode;
   Result.Data.Key := APair.Key;
@@ -3546,7 +3546,7 @@ begin
   Result := InternalAdd(Result, true);
 end;
 
-function TCustomAVLTreeMap<TREE_CONSTRAINTS>.Add(constref AKey: TKey; constref AValue: TValue): PNode;
+function TCustomAVLTreeMap<TREE_CONSTRAINTS>.Add(const AKey: TKey; const AValue: TValue): PNode;
 begin
   Result := NewNode;
   Result.Data.Key := AKey;
@@ -3554,7 +3554,7 @@ begin
   Result := InternalAdd(Result, true);
 end;
 
-function TCustomAVLTreeMap<TREE_CONSTRAINTS>.Remove(constref AKey: TKey; ADisposeNode: boolean): boolean;
+function TCustomAVLTreeMap<TREE_CONSTRAINTS>.Remove(const AKey: TKey; ADisposeNode: boolean): boolean;
 var
   LNode: PNode;
 begin
@@ -3566,7 +3566,7 @@ begin
     Result:=false;
 end;
 
-function TCustomAVLTreeMap<TREE_CONSTRAINTS>.ExtractPair(constref AKey: TKey; ADisposeNode: boolean): TTreePair;
+function TCustomAVLTreeMap<TREE_CONSTRAINTS>.ExtractPair(const AKey: TKey; ADisposeNode: boolean): TTreePair;
 var
   LNode: PNode;
 begin
@@ -3579,13 +3579,13 @@ begin
     Result := Default(TTreePair);
 end;
 
-function TCustomAVLTreeMap<TREE_CONSTRAINTS>.ExtractPair(constref ANode: PNode; ADispose: boolean = true): TTreePair;
+function TCustomAVLTreeMap<TREE_CONSTRAINTS>.ExtractPair(const ANode: PNode; ADispose: boolean = true): TTreePair;
 begin
   Result.Key := ANode.Key;
   Result.Value := DoRemove(ANode, cnExtracted, ADispose);
 end;
 
-function TCustomAVLTreeMap<TREE_CONSTRAINTS>.Extract(constref AKey: TKey; ADisposeNode: boolean): PNode;
+function TCustomAVLTreeMap<TREE_CONSTRAINTS>.Extract(const AKey: TKey; ADisposeNode: boolean): PNode;
 begin
   Result:=Find(AKey);
   if Result<>nil then
@@ -3637,7 +3637,7 @@ begin
     while Result.Right<>nil do Result:=Result.Right;
 end;
 
-function TCustomAVLTreeMap<TREE_CONSTRAINTS>.Find(constref AKey: TKey): PNode;
+function TCustomAVLTreeMap<TREE_CONSTRAINTS>.Find(const AKey: TKey): PNode;
 var
   LComp: SizeInt;
 begin
@@ -3654,13 +3654,13 @@ begin
   end;
 end;
 
-function TCustomAVLTreeMap<TREE_CONSTRAINTS>.ContainsKey(constref AKey: TKey; out ANode: PNode): boolean;
+function TCustomAVLTreeMap<TREE_CONSTRAINTS>.ContainsKey(const AKey: TKey; out ANode: PNode): boolean;
 begin
   ANode := Find(AKey);
   Result := Assigned(ANode);
 end;
 
-function TCustomAVLTreeMap<TREE_CONSTRAINTS>.ContainsKey(constref AKey: TKey): boolean; overload; inline;
+function TCustomAVLTreeMap<TREE_CONSTRAINTS>.ContainsKey(const AKey: TKey): boolean; overload; inline;
 begin
   Result := Assigned(Find(AKey));
 end;
@@ -3922,7 +3922,7 @@ end;
 
 { TAVLTree<T> }
 
-function TAVLTree<T>.Add(constref AValue: T): PNode;
+function TAVLTree<T>.Add(const AValue: T): PNode;
 begin
   Result := inherited Add(AValue, EmptyRecord);
 end;
@@ -3934,7 +3934,7 @@ end;
 
 { TIndexedAVLTree<T> }
 
-function TIndexedAVLTree<T>.Add(constref AValue: T): PNode;
+function TIndexedAVLTree<T>.Add(const AValue: T): PNode;
 begin
   Result := inherited Add(AValue, EmptyRecord);
 end;
@@ -3975,7 +3975,7 @@ end;
 
 { TSortedSet<T> }
 
-procedure TSortedSet<T>.InternalAVLTreeNotify(ASender: TObject; constref AItem: T; AAction: TCollectionNotification);
+procedure TSortedSet<T>.InternalAVLTreeNotify(ASender: TObject; const AItem: T; AAction: TCollectionNotification);
 begin
   FOnNotify(Self, AItem, AAction);
 end;
@@ -4033,7 +4033,7 @@ begin
   FInternalTree.Free;
 end;
 
-function TSortedSet<T>.Add(constref AValue: T): Boolean;
+function TSortedSet<T>.Add(const AValue: T): Boolean;
 var
   LNodePtr, LParent: TAVLTree<T>.PNode;
   LNode: TAVLTree<T>.TNode;
@@ -4059,7 +4059,7 @@ begin
   FInternalTree.NodeNotify(LNodePtr, cnAdded, false);
 end;
 
-function TSortedSet<T>.Remove(constref AValue: T): Boolean;
+function TSortedSet<T>.Remove(const AValue: T): Boolean;
 var
   LNode: TAVLTree<T>.PNode;
 begin
@@ -4069,7 +4069,7 @@ begin
     FInternalTree.Delete(LNode);
 end;
 
-function TSortedSet<T>.Extract(constref AValue: T): T;
+function TSortedSet<T>.Extract(const AValue: T): T;
 var
   LNode: TAVLTree<T>.PNode;
 begin
@@ -4085,7 +4085,7 @@ begin
   FInternalTree.Clear;
 end;
 
-function TSortedSet<T>.Contains(constref AValue: T): Boolean;
+function TSortedSet<T>.Contains(const AValue: T): Boolean;
 begin
   Result := FInternalTree.ContainsKey(AValue);
 end;
@@ -4096,7 +4096,7 @@ end;
 
 { TSortedHashSet<T>.TSortedHashSetEqualityComparer }
 
-function TSortedHashSet<T>.TSortedHashSetEqualityComparer.Equals(constref ALeft, ARight: PT): Boolean;
+function TSortedHashSet<T>.TSortedHashSetEqualityComparer.Equals(const ALeft, ARight: PT): Boolean;
 begin
   if Assigned(FComparer) then
     Result := FComparer.Compare(ALeft^, ARight^) = 0
@@ -4104,7 +4104,7 @@ begin
     Result := FEqualityComparer.Equals(ALeft^, ARight^);
 end;
 
-function TSortedHashSet<T>.TSortedHashSetEqualityComparer.GetHashCode(constref AValue: PT): UInt32;
+function TSortedHashSet<T>.TSortedHashSetEqualityComparer.GetHashCode(const AValue: PT): UInt32;
 begin
   Result := FEqualityComparer.GetHashCode(AValue^);
 end;
@@ -4157,7 +4157,7 @@ end;
 
 { TSortedHashSet<T> }
 
-procedure TSortedHashSet<T>.InternalDictionaryNotify(ASender: TObject; constref AItem: PT; AAction: TCollectionNotification);
+procedure TSortedHashSet<T>.InternalDictionaryNotify(ASender: TObject; const AItem: PT; AAction: TCollectionNotification);
 begin
   FOnNotify(Self, AItem^, AAction);
 end;
@@ -4206,7 +4206,7 @@ begin
   Result := TSortedHashSetEnumerator.Create(Self);
 end;
 
-function TSortedHashSet<T>.Add(constref AValue: T): Boolean;
+function TSortedHashSet<T>.Add(const AValue: T): Boolean;
 var
   LNode: TAVLTree<T>.PNode;
 begin
@@ -4218,7 +4218,7 @@ begin
   end;
 end;
 
-function TSortedHashSet<T>.Remove(constref AValue: T): Boolean;
+function TSortedHashSet<T>.Remove(const AValue: T): Boolean;
 var
   LIndex: SizeInt;
 begin
@@ -4231,7 +4231,7 @@ begin
   end;
 end;
 
-function TSortedHashSet<T>.Extract(constref AValue: T): T;
+function TSortedHashSet<T>.Extract(const AValue: T): T;
 var
   LIndex: SizeInt;
 begin
@@ -4251,7 +4251,7 @@ begin
   FInternalTree.Clear;
 end;
 
-function TSortedHashSet<T>.Contains(constref AValue: T): Boolean;
+function TSortedHashSet<T>.Contains(const AValue: T): Boolean;
 begin
   Result := FInternalDictionary.ContainsKey(@AValue);
 end;

文件差異過大導致無法顯示
+ 227 - 227
packages/rtl-generics/src/generics.defaults.pas


+ 53 - 53
packages/rtl-generics/src/inc/generics.dictionaries.inc

@@ -37,21 +37,21 @@ end;
 
 { TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS> }
 
-procedure TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS>.PairNotify(constref APair: TDictionaryPair;
+procedure TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS>.PairNotify(const APair: TDictionaryPair;
   ACollectionNotification: TCollectionNotification);
 begin
   KeyNotify(APair.Key, ACollectionNotification);
   ValueNotify(APair.Value, ACollectionNotification);
 end;
 
-procedure TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS>.KeyNotify(constref AKey: TKey;
+procedure TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS>.KeyNotify(const AKey: TKey;
   ACollectionNotification: TCollectionNotification);
 begin
   if Assigned(FOnKeyNotify) then
     FOnKeyNotify(Self, AKey, ACollectionNotification);
 end;
 
-procedure TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS>.SetValue(var AValue: TValue; constref ANewValue: TValue);
+procedure TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS>.SetValue(var AValue: TValue; const ANewValue: TValue);
 var
   LOldValue: TValue;
 begin
@@ -62,7 +62,7 @@ begin
   ValueNotify(ANewValue, cnAdded);
 end;
 
-procedure TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS>.ValueNotify(constref AValue: TValue;
+procedure TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS>.ValueNotify(const AValue: TValue;
   ACollectionNotification: TCollectionNotification);
 begin
   if Assigned(FOnValueNotify) then
@@ -334,7 +334,7 @@ begin
   Result := TValueCollection(FValues);
 end;
 
-function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndex(constref AKey: TKey): SizeInt;
+function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndex(const AKey: TKey): SizeInt;
 var
   LHash: UInt32;
 begin
@@ -362,14 +362,14 @@ begin
     FItemsThreshold := Pred(Round(ASize * FMaxLoadFactor));
 end;
 
-procedure TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.AddItem(var AItem: TItem; constref AKey: TKey;
-  constref AValue: TValue; const AHash: UInt32);
+procedure TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.AddItem(var AItem: TItem; const AKey: TKey;
+  const AValue: TValue; const AHash: UInt32);
 begin
   AItem.Hash := AHash;
   AItem.Pair.Key := AKey;
   AItem.Pair.Value := AValue;
 
-  // ! very important. FItemsLength must be increased after above code (because constref has meaning)
+  // ! very important. FItemsLength must be increased after above code (because const has meaning)
   Inc(FItemsLength);
 
   PairNotify(AItem.Pair, cnAdded);
@@ -380,17 +380,17 @@ begin
   Result := PPointersCollection(@FItems);
 end;
 
-procedure TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.Add(constref AKey: TKey; constref AValue: TValue);
+procedure TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.Add(const AKey: TKey; const AValue: TValue);
 begin
   DoAdd(AKey, AValue);
 end;
 
-procedure TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.Add(constref APair: TPair<TKey, TValue>);
+procedure TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.Add(const APair: TPair<TKey, TValue>);
 begin
   DoAdd(APair.Key, APair.Value);
 end;
 
-function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.DoAdd(constref AKey: TKey; constref AValue: TValue): SizeInt;
+function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.DoAdd(const AKey: TKey; const AValue: TValue): SizeInt;
 var
   LHash: UInt32;
 begin
@@ -419,7 +419,7 @@ begin
   PairNotify(LPair, ACollectionNotification);
 end;
 
-procedure TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.Remove(constref AKey: TKey);
+procedure TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.Remove(const AKey: TKey);
 var
   LIndex: SizeInt;
 begin
@@ -430,7 +430,7 @@ begin
   DoRemove(LIndex, cnRemoved);
 end;
 
-function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.ExtractPair(constref AKey: TKey): TPair<TKey, TValue>;
+function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.ExtractPair(const AKey: TKey): TPair<TKey, TValue>;
 var
   LIndex: SizeInt;
 begin
@@ -594,7 +594,7 @@ begin
   SetValue(FItems[LIndex].Pair.Value, AValue);
 end;
 
-function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.TryGetValue(constref AKey: TKey; out AValue: TValue): Boolean;
+function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.TryGetValue(const AKey: TKey; out AValue: TValue): Boolean;
 var
   LIndex: SizeInt;
 begin
@@ -607,7 +607,7 @@ begin
     AValue := Default(TValue);
 end;
 
-function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.TryAdd(constref AKey: TKey; constref AValue: TValue): Boolean;
+function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.TryAdd(const AKey: TKey; const AValue: TValue): Boolean;
 var
   LHash: UInt32;
 begin
@@ -616,7 +616,7 @@ begin
     DoAdd(AKey, AValue);
 end;
 
-procedure TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.AddOrSetValue(constref AKey: TKey; constref AValue: TValue);
+procedure TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.AddOrSetValue(const AKey: TKey; const AValue: TValue);
 var
   LIndex: SizeInt;
   LHash: UInt32;
@@ -629,7 +629,7 @@ begin
     SetValue(FItems[LIndex].Pair.Value, AValue);
 end;
 
-function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.ContainsKey(constref AKey: TKey): Boolean;
+function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.ContainsKey(const AKey: TKey): Boolean;
 var
   LIndex: SizeInt;
 begin
@@ -637,12 +637,12 @@ begin
   Result := LIndex >= 0;
 end;
 
-function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.ContainsValue(constref AValue: TValue): Boolean;
+function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.ContainsValue(const AValue: TValue): Boolean;
 begin
   Result := ContainsValue(AValue, TEqualityComparer<TValue>.Default(THashFactory));
 end;
 
-function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.ContainsValue(constref AValue: TValue;
+function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.ContainsValue(const AValue: TValue;
   const AEqualityComparer: IEqualityComparer<TValue>): Boolean;
 var
   i: SizeInt;
@@ -760,8 +760,8 @@ begin
   PairNotify(LPair, ACollectionNotification);
 end;
 
-function TOpenAddressingLP<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndex(constref AItems: TArray<TItem>;
-  constref AKey: TKey; out AHash: UInt32): SizeInt;
+function TOpenAddressingLP<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndex(const AItems: TArray<TItem>;
+  const AKey: TKey; out AHash: UInt32): SizeInt;
 var
   LItem: {TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.}_TItem; // for workaround Lazarus bug #25613
   LLengthMask: SizeInt;
@@ -833,8 +833,8 @@ begin
   Inc(FTombstonesCount);
 end;
 
-function TOpenAddressingTombstones<OPEN_ADDRESSING_CONSTRAINTS>.DoAdd(constref AKey: TKey;
-  constref AValue: TValue): SizeInt;
+function TOpenAddressingTombstones<OPEN_ADDRESSING_CONSTRAINTS>.DoAdd(const AKey: TKey;
+  const AValue: TValue): SizeInt;
 var
   LHash: UInt32;
 begin
@@ -854,8 +854,8 @@ end;
 
 { TOpenAddressingSH<OPEN_ADDRESSING_CONSTRAINTS> }
 
-function TOpenAddressingSH<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndex(constref AItems: TArray<TItem>;
-  constref AKey: TKey; out AHash: UInt32): SizeInt;
+function TOpenAddressingSH<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndex(const AItems: TArray<TItem>;
+  const AKey: TKey; out AHash: UInt32): SizeInt;
 var
   LItem: {TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.}_TItem; // for workaround Lazarus bug #25613
   LLengthMask: SizeInt;
@@ -893,8 +893,8 @@ begin
   until false;
 end;
 
-function TOpenAddressingSH<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndexOrTombstone(constref AItems: TArray<TItem>;
-  constref AKey: TKey; out AHash: UInt32): SizeInt;
+function TOpenAddressingSH<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndexOrTombstone(const AItems: TArray<TItem>;
+  const AKey: TKey; out AHash: UInt32): SizeInt;
 var
   LItem: {TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.}_TItem; // for workaround Lazarus bug #25613
   LLengthMask: SizeInt;
@@ -948,8 +948,8 @@ begin
     end;
 end;
 
-function TOpenAddressingQP<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndex(constref AItems: TArray<TItem>;
-  constref AKey: TKey; out AHash: UInt32): SizeInt;
+function TOpenAddressingQP<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndex(const AItems: TArray<TItem>;
+  const AKey: TKey; out AHash: UInt32): SizeInt;
 var
   LItem: {TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.}_TItem; // for workaround Lazarus bug #25613
   i: SizeInt;
@@ -982,8 +982,8 @@ begin
 end;
 
 
-function TOpenAddressingQP<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndexOrTombstone(constref AItems: TArray<TItem>;
-  constref AKey: TKey; out AHash: UInt32): SizeInt;
+function TOpenAddressingQP<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndexOrTombstone(const AItems: TArray<TItem>;
+  const AKey: TKey; out AHash: UInt32): SizeInt;
 var
   LItem: {TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.}_TItem; // for workaround Lazarus bug #25613
   i: SizeInt;
@@ -1098,8 +1098,8 @@ begin
       MultiplyDeBruijnBitPosition[UInt32(((ASize and -ASize) * $077CB531)) shr 27]]
 end;
 
-function TOpenAddressingDH<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndex(constref AItems: TArray<TItem>;
-  constref AKey: TKey; out AHash: UInt32): SizeInt;
+function TOpenAddressingDH<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndex(const AItems: TArray<TItem>;
+  const AKey: TKey; out AHash: UInt32): SizeInt;
 var
   LItem: {TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.}_TItem; // for workaround Lazarus bug #25613
   LLengthMask: SizeInt;
@@ -1142,8 +1142,8 @@ begin
   until false;
 end;
 
-function TOpenAddressingDH<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndexOrTombstone(constref AItems: TArray<TItem>;
-  constref AKey: TKey; out AHash: UInt32): SizeInt;
+function TOpenAddressingDH<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndexOrTombstone(const AItems: TArray<TItem>;
+  const AKey: TKey; out AHash: UInt32): SizeInt;
 var
   LItem: {TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.}_TItem; // for workaround Lazarus bug #25613
   LLengthMask: SizeInt;
@@ -1568,13 +1568,13 @@ begin
   Result := PPointersCollection(@FItems);
 end;
 
-function TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.Lookup(constref AKey: TKey;
+function TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.Lookup(const AKey: TKey;
   var AHashListOrIndex: PUInt32): SizeInt;
 begin
   Result := Lookup(FItems, AKey, AHashListOrIndex);
 end;
 
-function TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.Lookup(constref AItems: TItemsDArray; constref AKey: TKey;
+function TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.Lookup(const AItems: TItemsDArray; const AKey: TKey;
   var AHashListOrIndex: PUInt32): SizeInt;
 var
   LLengthMask: SizeInt;
@@ -1660,8 +1660,8 @@ begin
     FItemsThreshold := Pred(Round(LLength * FMaxLoadFactor));
 end;
 
-procedure TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.AddItem(constref AItems: TItemsDArray; constref AKey: TKey;
-  constref AValue: TValue; const AHashList: PUInt32);
+procedure TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.AddItem(const AItems: TItemsDArray; const AKey: TKey;
+  const AValue: TValue; const AHashList: PUInt32);
 var
   LNewItem: TItem;
   LPNewItem: PItem;
@@ -1740,7 +1740,7 @@ begin
   ValueNotify(AValue, cnAdded);
 end;
 
-procedure TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.Add(constref AKey: TKey; constref AValue: TValue);
+procedure TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.Add(const AKey: TKey; const AValue: TValue);
 var
   LHashList: array[0..TCuckooCfg.D] of UInt32;
   LHashListOrIndex: PUint32;
@@ -1753,7 +1753,7 @@ begin
   DoAdd(AKey, AValue, LHashListOrIndex);
 end;
 
-procedure TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.Add(constref APair: TPair<TKey, TValue>);
+procedure TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.Add(const APair: TPair<TKey, TValue>);
 begin
   Add(APair.Key, APair.Value);
 end;
@@ -1792,7 +1792,7 @@ begin
   PairNotify(LPair, ACollectionNotification);
 end;
 
-procedure TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.Remove(constref AKey: TKey);
+procedure TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.Remove(const AKey: TKey);
 var
   LHashList: array[0..TCuckooCfg.D] of UInt32;
   LHashListOrIndex: PUint32;
@@ -1806,7 +1806,7 @@ begin
   DoRemove(LHashListOrIndex, LLookupResult, cnRemoved);
 end;
 
-function TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.ExtractPair(constref AKey: TKey): TPair<TKey, TValue>;
+function TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.ExtractPair(const AKey: TKey): TPair<TKey, TValue>;
 var
   LHashList: array[0..TCuckooCfg.D] of UInt32;
   LHashListOrIndex: PUint32;
@@ -2011,7 +2011,7 @@ begin
   FQueue.FIdx.TrimExcess;
 end;
 
-procedure TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.SetItem(constref AValue: TValue;
+procedure TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.SetItem(const AValue: TValue;
   const AHashListOrIndex: PUInt32; ALookupResult: SizeInt);
 var
   LIndex: UInt32;
@@ -2039,7 +2039,7 @@ begin
   SetItem(AValue, LHashListOrIndex, LLookupResult);
 end;
 
-function TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.TryGetValue(constref AKey: TKey; out AValue: TValue): Boolean;
+function TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.TryGetValue(const AKey: TKey; out AValue: TValue): Boolean;
 var
   LHashList: array[0..TCuckooCfg.D] of UInt32;
   LHashListOrIndex: PUint32;
@@ -2062,7 +2062,7 @@ begin
   end;
 end;
 
-procedure TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.AddOrSetValue(constref AKey: TKey; constref AValue: TValue);
+procedure TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.AddOrSetValue(const AKey: TKey; const AValue: TValue);
 var
   LHashList: array[0..TCuckooCfg.D] of UInt32;
   LHashListOrIndex: PUint32;
@@ -2082,7 +2082,7 @@ begin
     SetItem(AValue, LHashListOrIndex, LLookupResult);
 end;
 
-function TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.ContainsKey(constref AKey: TKey): Boolean;
+function TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.ContainsKey(const AKey: TKey): Boolean;
 var
   LHashList: array[0..TCuckooCfg.D] of UInt32;
   LHashListOrIndex: PUint32;
@@ -2091,12 +2091,12 @@ begin
   Result := Lookup(AKey, LHashListOrIndex) <> LR_NIL;
 end;
 
-function TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.ContainsValue(constref AValue: TValue): Boolean;
+function TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.ContainsValue(const AValue: TValue): Boolean;
 begin
   Result := ContainsValue(AValue, TEqualityComparer<TValue>.Default(THashFactory));
 end;
 
-function TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.ContainsValue(constref AValue: TValue;
+function TDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.ContainsValue(const AValue: TValue;
   const AEqualityComparer: IEqualityComparer<TValue>): Boolean;
 var
   i, j: SizeInt;
@@ -2186,7 +2186,7 @@ end;
 { TObjectDictionary<DICTIONARY_CONSTRAINTS> }
 
 procedure TObjectDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.KeyNotify(
-  constref AKey: TKey; ACollectionNotification: TCollectionNotification);
+  const AKey: TKey; ACollectionNotification: TCollectionNotification);
 begin
   inherited;
 
@@ -2194,7 +2194,7 @@ begin
     TObject((@AKey)^).Free;
 end;
 
-procedure TObjectDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.ValueNotify(constref AValue: TValue;
+procedure TObjectDeamortizedDArrayCuckooMap<CUCKOO_CONSTRAINTS>.ValueNotify(const AValue: TValue;
   ACollectionNotification: TCollectionNotification);
 begin
   inherited;
@@ -2234,7 +2234,7 @@ begin
 end;
 
 procedure TObjectOpenAddressingLP<OPEN_ADDRESSING_CONSTRAINTS>.KeyNotify(
-  constref AKey: TKey; ACollectionNotification: TCollectionNotification);
+  const AKey: TKey; ACollectionNotification: TCollectionNotification);
 begin
   inherited;
 
@@ -2243,7 +2243,7 @@ begin
 end;
 
 procedure TObjectOpenAddressingLP<OPEN_ADDRESSING_CONSTRAINTS>.ValueNotify(
-  constref AValue: TValue; ACollectionNotification: TCollectionNotification);
+  const AValue: TValue; ACollectionNotification: TCollectionNotification);
 begin
   inherited;
 

+ 47 - 47
packages/rtl-generics/src/inc/generics.dictionariesh.inc

@@ -71,7 +71,7 @@ type
     property Capacity: SizeInt read GetCapacity write SetCapacity;
 
     procedure Clear; virtual; abstract;
-    procedure Add(constref APair: TPair<TKey, TValue>); virtual; abstract;
+    procedure Add(const APair: TPair<TKey, TValue>); virtual; abstract;
   strict private // bug #24283. workaround for this class because can't inherit from TEnumerable
     function ToArray(ACount: SizeInt): TArray<TDictionaryPair>; overload;
   public
@@ -95,10 +95,10 @@ type
   protected
     procedure UpdateItemsThreshold(ASize: SizeInt); virtual; abstract;
 
-    procedure KeyNotify(constref AKey: TKey; ACollectionNotification: TCollectionNotification); virtual;
-    procedure ValueNotify(constref AValue: TValue; ACollectionNotification: TCollectionNotification); virtual;
-    procedure PairNotify(constref APair: TDictionaryPair; ACollectionNotification: TCollectionNotification); inline;
-    procedure SetValue(var AValue: TValue; constref ANewValue: TValue);
+    procedure KeyNotify(const AKey: TKey; ACollectionNotification: TCollectionNotification); virtual;
+    procedure ValueNotify(const AValue: TValue; ACollectionNotification: TCollectionNotification); virtual;
+    procedure PairNotify(const APair: TDictionaryPair; ACollectionNotification: TCollectionNotification); inline;
+    procedure SetValue(var AValue: TValue; const ANewValue: TValue);
   public
     property OnKeyNotify: TCollectionNotifyEvent<TKey> read FOnKeyNotify write FOnKeyNotify;
     property OnValueNotify: TCollectionNotifyEvent<TValue> read FOnValueNotify write FOnValueNotify;
@@ -193,8 +193,8 @@ type
   protected
     function RealItemsLength: SizeInt; virtual;
     function Rehash(ASizePow2: SizeInt; AForce: Boolean = False): boolean; virtual;
-    function FindBucketIndex(constref AKey: TKey): SizeInt; overload; inline;
-    function FindBucketIndex(constref AItems: TArray<TItem>; constref AKey: TKey; out AHash: UInt32): SizeInt; virtual; abstract; overload;
+    function FindBucketIndex(const AKey: TKey): SizeInt; overload; inline;
+    function FindBucketIndex(const AItems: TArray<TItem>; const AKey: TKey; out AHash: UInt32): SizeInt; virtual; abstract; overload;
   public
     type
       // Enumerators
@@ -237,11 +237,11 @@ type
   private
     function GetItem(const AKey: TKey): TValue; inline;
     procedure SetItem(const AKey: TKey; const AValue: TValue); inline;
-    procedure AddItem(var AItem: TItem; constref AKey: TKey; constref AValue: TValue; const AHash: UInt32); inline;
+    procedure AddItem(var AItem: TItem; const AKey: TKey; const AValue: TValue; const AHash: UInt32); inline;
   protected
      // useful for using dictionary as array
     function DoRemove(AIndex: SizeInt; ACollectionNotification: TCollectionNotification): TValue; virtual;
-    function DoAdd(constref AKey: TKey; constref AValue: TValue): SizeInt; virtual;
+    function DoAdd(const AKey: TKey; const AValue: TValue): SizeInt; virtual;
 
     procedure UpdateItemsThreshold(ASize: SizeInt); override;
 
@@ -255,18 +255,18 @@ type
     // many constructors because bug #25607
     constructor Create(ACapacity: SizeInt; const AComparer: IEqualityComparer<TKey>); override; overload;
 
-    procedure Add(constref APair: TPair<TKey, TValue>); override; overload;
-    procedure Add(constref AKey: TKey; constref AValue: TValue); overload; inline;
-    procedure Remove(constref AKey: TKey);
-    function ExtractPair(constref AKey: TKey): TPair<TKey, TValue>;
+    procedure Add(const APair: TPair<TKey, TValue>); override; overload;
+    procedure Add(const AKey: TKey; const AValue: TValue); overload; inline;
+    procedure Remove(const AKey: TKey);
+    function ExtractPair(const AKey: TKey): TPair<TKey, TValue>;
     procedure Clear; override;
     procedure TrimExcess;
-    function TryGetValue(constref AKey: TKey; out AValue: TValue): Boolean;
-    function TryAdd(constref AKey: TKey; constref AValue: TValue): Boolean;
-    procedure AddOrSetValue(constref AKey: TKey; constref AValue: TValue);
-    function ContainsKey(constref AKey: TKey): Boolean; inline;
-    function ContainsValue(constref AValue: TValue): Boolean; overload;
-    function ContainsValue(constref AValue: TValue; const AEqualityComparer: IEqualityComparer<TValue>): Boolean; virtual; overload;
+    function TryGetValue(const AKey: TKey; out AValue: TValue): Boolean;
+    function TryAdd(const AKey: TKey; const AValue: TValue): Boolean;
+    procedure AddOrSetValue(const AKey: TKey; const AValue: TValue);
+    function ContainsKey(const AKey: TKey): Boolean; inline;
+    function ContainsValue(const AValue: TValue): Boolean; overload;
+    function ContainsValue(const AValue: TValue; const AEqualityComparer: IEqualityComparer<TValue>): Boolean; virtual; overload;
 
     property Items[Index: TKey]: TValue read GetItem write SetItem; default;
     property Keys: TKeyCollection read GetKeys;
@@ -285,7 +285,7 @@ type
   protected
     procedure NotifyIndexChange(AFrom, ATo: SizeInt); virtual;
     function DoRemove(AIndex: SizeInt; ACollectionNotification: TCollectionNotification): TValue; override;
-    function FindBucketIndex(constref AItems: TArray<TItem>; constref AKey: TKey; out AHash: UInt32): SizeInt; override; overload;
+    function FindBucketIndex(const AItems: TArray<TItem>; const AKey: TKey; out AHash: UInt32): SizeInt; override; overload;
   end;
 
   // More info and TODO
@@ -298,11 +298,11 @@ type
     function Rehash(ASizePow2: SizeInt; AForce: Boolean = False): boolean; override;
     function RealItemsLength: SizeInt; override;
 
-    function FindBucketIndexOrTombstone(constref AItems: TArray<TItem>; constref AKey: TKey;
+    function FindBucketIndexOrTombstone(const AItems: TArray<TItem>; const AKey: TKey;
       out AHash: UInt32): SizeInt; virtual; abstract;
 
     function DoRemove(AIndex: SizeInt; ACollectionNotification: TCollectionNotification): TValue; override;
-    function DoAdd(constref AKey: TKey; constref AValue: TValue): SizeInt; override;
+    function DoAdd(const AKey: TKey; const AValue: TValue): SizeInt; override;
   public
     property TombstonesCount: SizeInt read FTombstonesCount;
     procedure ClearTombstones; virtual;
@@ -316,9 +316,9 @@ type
       Pair: TPair<TKey, TValue>;
     end;
   protected
-    function FindBucketIndex(constref AItems: TArray<TItem>; constref AKey: TKey;
+    function FindBucketIndex(const AItems: TArray<TItem>; const AKey: TKey;
       out AHash: UInt32): SizeInt; override; overload;
-    function FindBucketIndexOrTombstone(constref AItems: TArray<TItem>; constref AKey: TKey;
+    function FindBucketIndexOrTombstone(const AItems: TArray<TItem>; const AKey: TKey;
       out AHash: UInt32): SizeInt; override;
   end;
 
@@ -327,10 +327,10 @@ type
     FPrimaryNumberAsSizeApproximation: SizeInt;
   protected
     procedure UpdateItemsThreshold(ASize: SizeInt); override;
-    function FindBucketIndex(constref AItems: TArray<TItem>;
-      constref AKey: TKey; out AHash: UInt32): SizeInt; override; overload;
-    function FindBucketIndexOrTombstone(constref AItems: TArray<TItem>;
-      constref AKey: TKey; out AHash: UInt32): SizeInt; override;
+    function FindBucketIndex(const AItems: TArray<TItem>;
+      const AKey: TKey; out AHash: UInt32): SizeInt; override; overload;
+    function FindBucketIndexOrTombstone(const AItems: TArray<TItem>;
+      const AKey: TKey; out AHash: UInt32): SizeInt; override;
   end;
 
   TOpenAddressingDH<OPEN_ADDRESSING_CONSTRAINTS> = class(TOpenAddressingTombstones<OPEN_ADDRESSING_CONSTRAINTS>)
@@ -343,9 +343,9 @@ type
     R: UInt32;
   protected
     procedure UpdateItemsThreshold(ASize: SizeInt); override;
-    function FindBucketIndex(constref AItems: TArray<TItem>; constref AKey: TKey;
+    function FindBucketIndex(const AItems: TArray<TItem>; const AKey: TKey;
       out AHash: UInt32): SizeInt; override; overload;
-    function FindBucketIndexOrTombstone(constref AItems: TArray<TItem>; constref AKey: TKey;
+    function FindBucketIndexOrTombstone(const AItems: TArray<TItem>; const AKey: TKey;
       out AHash: UInt32): SizeInt; override;
   strict protected
     constructor Create(ACapacity: SizeInt; const AComparer: IEqualityComparer<TKey>); override; overload;
@@ -470,8 +470,8 @@ type
     procedure PrepareAddingItem;
   protected
     procedure UpdateItemsThreshold(ASize: SizeInt); override;
-    function Lookup(constref AKey: TKey; var AHashListOrIndex: PUInt32): SizeInt; inline; overload;
-    function Lookup(constref AItems: TItemsDArray; constref AKey: TKey; var AHashListOrIndex: PUInt32): SizeInt; virtual; overload;
+    function Lookup(const AKey: TKey; var AHashListOrIndex: PUInt32): SizeInt; inline; overload;
+    function Lookup(const AItems: TItemsDArray; const AKey: TKey; var AHashListOrIndex: PUInt32): SizeInt; virtual; overload;
   public
     type
       // Enumerators
@@ -514,9 +514,9 @@ type
   private
     function GetItem(const AKey: TKey): TValue; inline;
     procedure SetItem(const AKey: TKey; const AValue: TValue); overload; inline;
-    procedure SetItem(constref AValue: TValue; const AHashListOrIndex: PUInt32; ALookupResult: SizeInt); overload;
+    procedure SetItem(const AValue: TValue; const AHashListOrIndex: PUInt32; ALookupResult: SizeInt); overload;
 
-    procedure AddItem(constref AItems: TItemsDArray; constref AKey: TKey; constref AValue: TValue; const AHashList: PUInt32); overload;
+    procedure AddItem(const AItems: TItemsDArray; const AKey: TKey; const AValue: TValue; const AHashList: PUInt32); overload;
     procedure DoAdd(const AKey: TKey; const AValue: TValue; const AHashList: PUInt32); overload; inline;
     function DoRemove(const AHashListOrIndex: PUInt32; ALookupResult: SizeInt;
       ACollectionNotification: TCollectionNotification): TValue;
@@ -553,17 +553,17 @@ type
     {$ENDIF}
     destructor Destroy; override;
 
-    procedure Add(constref APair: TPair<TKey, TValue>); override; overload;
-    procedure Add(constref AKey: TKey; constref AValue: TValue); overload;
-    procedure Remove(constref AKey: TKey);
-    function ExtractPair(constref AKey: TKey): TPair<TKey, TValue>;
+    procedure Add(const APair: TPair<TKey, TValue>); override; overload;
+    procedure Add(const AKey: TKey; const AValue: TValue); overload;
+    procedure Remove(const AKey: TKey);
+    function ExtractPair(const AKey: TKey): TPair<TKey, TValue>;
     procedure Clear; override;
     procedure TrimExcess;
-    function TryGetValue(constref AKey: TKey; out AValue: TValue): Boolean;
-    procedure AddOrSetValue(constref AKey: TKey; constref AValue: TValue);
-    function ContainsKey(constref AKey: TKey): Boolean; inline;
-    function ContainsValue(constref AValue: TValue): Boolean; overload;
-    function ContainsValue(constref AValue: TValue; const AEqualityComparer: IEqualityComparer<TValue>): Boolean; virtual; overload;
+    function TryGetValue(const AKey: TKey; out AValue: TValue): Boolean;
+    procedure AddOrSetValue(const AKey: TKey; const AValue: TValue);
+    function ContainsKey(const AKey: TKey): Boolean; inline;
+    function ContainsValue(const AValue: TValue): Boolean; overload;
+    function ContainsValue(const AValue: TValue; const AEqualityComparer: IEqualityComparer<TValue>): Boolean; virtual; overload;
 
     property Items[Index: TKey]: TValue read GetItem write SetItem; default;
     property Keys: TKeyCollection read GetKeys;
@@ -580,8 +580,8 @@ type
   private
     FOwnerships: TDictionaryOwnerships;
   protected
-    procedure KeyNotify(constref AKey: TKey; ACollectionNotification: TCollectionNotification); override;
-    procedure ValueNotify(constref AValue: TValue; ACollectionNotification: TCollectionNotification); override;
+    procedure KeyNotify(const AKey: TKey; ACollectionNotification: TCollectionNotification); override;
+    procedure ValueNotify(const AValue: TValue; ACollectionNotification: TCollectionNotification); override;
   public
     // can't be as "Create(AOwnerships: TDictionaryOwnerships; ACapacity: SizeInt = 0)"
     // because bug #25607
@@ -597,8 +597,8 @@ type
   private
     FOwnerships: TDictionaryOwnerships;
   protected
-    procedure KeyNotify(constref AKey: TKey; ACollectionNotification: TCollectionNotification); override;
-    procedure ValueNotify(constref AValue: TValue; ACollectionNotification: TCollectionNotification); override;
+    procedure KeyNotify(const AKey: TKey; ACollectionNotification: TCollectionNotification); override;
+    procedure ValueNotify(const AValue: TValue; ACollectionNotification: TCollectionNotification); override;
   public
     // can't be as "Create(AOwnerships: TDictionaryOwnerships; ACapacity: SizeInt = 0)"
     // because bug #25607

+ 4 - 4
packages/rtl-generics/tests/tests.generics.arrayhelper.pas

@@ -37,9 +37,9 @@ type
 
   TTestArrayHelper = class(TTestCase)
   protected
-    procedure CheckBinarySearch(constref AArray: TArray<Integer>;
+    procedure CheckBinarySearch(const AArray: TArray<Integer>;
       AValue: Integer; AExpectedResult: boolean; out ASearchResult: TBinarySearchResult);
-    procedure CheckSearchResult(constref ASearchResult: TBinarySearchResult;
+    procedure CheckSearchResult(const ASearchResult: TBinarySearchResult;
       AValue: Integer; ACandidateIndex, AFoundIndex: SizeInt; ACompareResult: Boolean);
   published
     procedure Test_BinarySearch_Integers;
@@ -50,7 +50,7 @@ implementation
 
 { TTestArrayHelper }
 
-procedure TTestArrayHelper.CheckBinarySearch(constref AArray: TArray<Integer>;
+procedure TTestArrayHelper.CheckBinarySearch(const AArray: TArray<Integer>;
   AValue: Integer; AExpectedResult: boolean; out
   ASearchResult: TBinarySearchResult);
 begin
@@ -59,7 +59,7 @@ begin
     'Wrong BinarySearch result for ' + AValue.ToString);
 end;
 
-procedure TTestArrayHelper.CheckSearchResult(constref
+procedure TTestArrayHelper.CheckSearchResult(const
   ASearchResult: TBinarySearchResult; AValue: Integer; ACandidateIndex,
   AFoundIndex: SizeInt; ACompareResult: Boolean);
 begin

+ 4 - 4
packages/rtl-generics/tests/tests.generics.dictionary.pas

@@ -30,8 +30,8 @@ Type
     Procedure DoneExpectKeys;
     Procedure DoneExpectValues;
     procedure DoGetValue(aKey: Integer; Match: String; ExceptionClass: TClass=nil);
-    procedure DoKeyNotify(ASender: TObject; {$ifdef fpc}constref{$else}const{$endif} AItem: Integer; AAction: TCollectionNotification);
-    procedure DoValueNotify(ASender: TObject; {$ifdef fpc}constref{$else}const{$endif} AItem: String; AAction: TCollectionNotification);
+    procedure DoKeyNotify(ASender: TObject; const AItem: Integer; AAction: TCollectionNotification);
+    procedure DoValueNotify(ASender: TObject; const AItem: String; AAction: TCollectionNotification);
   Public
     Procedure SetExpectKeys(aMessage : string; AKeys : Array of Integer; AActions : Array of TCollectionNotification; DoReverse : Boolean = False);
     Procedure SetExpectValues(aMessage : string; AKeys : Array of String; AActions : Array of TCollectionNotification; DoReverse : Boolean = False);
@@ -173,7 +173,7 @@ begin
     end;
 end;
 
-procedure TTestSimpleDictionary.DoKeyNotify(ASender: TObject;  {$ifdef fpc}constref{$else}const{$endif}  AItem: Integer; AAction: TCollectionNotification);
+procedure TTestSimpleDictionary.DoKeyNotify(ASender: TObject; const AItem: Integer; AAction: TCollectionNotification);
 begin
   Writeln(FnotifyMessage+' Notification',FCurrentKeyNotify);
   AssertSame(FnotifyMessage+' Correct sender', FDict,aSender);
@@ -183,7 +183,7 @@ begin
   Inc(FCurrentKeyNotify);
 end;
 
-procedure TTestSimpleDictionary.DoValueNotify(ASender: TObject; {$ifdef fpc}constref{$else}const{$endif} AItem: String; AAction: TCollectionNotification);
+procedure TTestSimpleDictionary.DoValueNotify(ASender: TObject; const AItem: String; AAction: TCollectionNotification);
 begin
   Writeln(FnotifyMessage+' value Notification',FCurrentValueNotify);
   AssertSame(FnotifyMessage+' value Correct sender', FDict,aSender);

+ 6 - 6
packages/rtl-generics/tests/tests.generics.hashmaps.pas

@@ -44,9 +44,9 @@ type
   private
     procedure CountAsKey_Check(const AWhat: string; AValue, AExpectedValue: Integer;
       AAction: PCollectionNotification);
-    procedure CountAsKey_Notify(const AKind: string; ASender: TObject; constref AItem: Integer; AAction: TCollectionNotification);
-    procedure CountAsKey_NotifyValue(ASender: TObject; constref AItem: Integer; AAction: TCollectionNotification);
-    procedure CountAsKey_NotifyKey(ASender: TObject; constref AItem: Integer; AAction: TCollectionNotification);
+    procedure CountAsKey_Notify(const AKind: string; ASender: TObject; const AItem: Integer; AAction: TCollectionNotification);
+    procedure CountAsKey_NotifyValue(ASender: TObject; const AItem: Integer; AAction: TCollectionNotification);
+    procedure CountAsKey_NotifyKey(ASender: TObject; const AItem: Integer; AAction: TCollectionNotification);
   published
     procedure Test_CountAsKey_OpenAddressingLP;
     procedure Test_CountAsKey_OpenAddressingLPT;
@@ -89,7 +89,7 @@ begin
   AssertEquals(AWhat + LCollectionNotificationStr, AExpectedValue, AValue);
 end;
 
-procedure TTestHashMaps.CountAsKey_Notify(const AKind: string; ASender: TObject; constref
+procedure TTestHashMaps.CountAsKey_Notify(const AKind: string; ASender: TObject; const
   AItem: Integer; AAction: TCollectionNotification);
 var
   LCount: Integer;
@@ -105,13 +105,13 @@ begin
   end;
 end;
 
-procedure TTestHashMaps.CountAsKey_NotifyValue(ASender: TObject; constref AItem: Integer;
+procedure TTestHashMaps.CountAsKey_NotifyValue(ASender: TObject; const AItem: Integer;
   AAction: TCollectionNotification);
 begin
   CountAsKey_Notify('Value', ASender, AItem, AAction);
 end;
 
-procedure TTestHashMaps.CountAsKey_NotifyKey(ASender: TObject; constref AItem: Integer;
+procedure TTestHashMaps.CountAsKey_NotifyKey(ASender: TObject; const AItem: Integer;
   AAction: TCollectionNotification);
 begin
   CountAsKey_Notify('Key', ASender, AItem, AAction);

+ 2 - 2
packages/rtl-generics/tests/tests.generics.queue.pas

@@ -27,7 +27,7 @@ Type
     procedure DoAdd2;
     Procedure DoneExpectValues;
     procedure DoGetValue(Match: String; ExceptionClass: TClass=nil);
-    procedure DoValueNotify(ASender: TObject; {$ifdef fpc}constref{$else}const{$endif} AItem: String; AAction: TCollectionNotification);
+    procedure DoValueNotify(ASender: TObject; const AItem: String; AAction: TCollectionNotification);
   Public
     Procedure SetExpectValues(aMessage : string; AKeys : Array of String; AActions : Array of TCollectionNotification; DoReverse : Boolean = False);
     Procedure SetUp; override;
@@ -244,7 +244,7 @@ begin
     end;
 end;
 
-procedure TTestSimpleQueue.DoValueNotify(ASender: TObject; {$ifdef fpc}constref{$else}const{$endif} AItem: String; AAction: TCollectionNotification);
+procedure TTestSimpleQueue.DoValueNotify(ASender: TObject; const AItem: String; AAction: TCollectionNotification);
 begin
 //  Writeln(FnotifyMessage+' value Notification',FCurrentValueNotify);
   AssertSame(FnotifyMessage+' value Correct sender', FQueue,aSender);

+ 2 - 2
packages/rtl-generics/tests/tests.generics.stack.pas

@@ -27,7 +27,7 @@ Type
     procedure DoAdd2;
     Procedure DoneExpectValues;
     procedure DoGetValue(Match: String; ExceptionClass: TClass=nil);
-    procedure DoValueNotify(ASender: TObject; {$ifdef fpc}constref{$else}const{$endif} AItem: String; AAction: TCollectionNotification);
+    procedure DoValueNotify(ASender: TObject; const AItem: String; AAction: TCollectionNotification);
   Public
     Procedure SetExpectValues(aMessage : string; AKeys : Array of String; AActions : Array of TCollectionNotification; DoReverse : Boolean = False);
     Procedure SetUp; override;
@@ -252,7 +252,7 @@ begin
     end;
 end;
 
-procedure TTestSimpleStack.DoValueNotify(ASender: TObject; {$ifdef fpc}constref{$else}const{$endif} AItem: String; AAction: TCollectionNotification);
+procedure TTestSimpleStack.DoValueNotify(ASender: TObject; const AItem: String; AAction: TCollectionNotification);
 begin
 //  Writeln(FnotifyMessage+' value Notification',FCurrentValueNotify);
   AssertSame(FnotifyMessage+' value Correct sender', FStack,aSender);

+ 1 - 1
packages/rtl-generics/tests/tests.generics.stdcollections.pas

@@ -191,7 +191,7 @@ begin
   finally FreeAndNil(Apples) end;
 end;
 
-function CompareApples(constref Left, Right: TApple): Integer;
+function CompareApples(const Left, Right: TApple): Integer;
 begin
   Result := AnsiCompareStr(Left.Name, Right.Name);
 end;

+ 4 - 4
packages/rtl-generics/tests/tests.generics.utils.pas

@@ -86,8 +86,8 @@ type
     procedure ClearNotificationsObj;
     procedure NotifyTestNodeStr(ASender: TObject; ANode: PNode_String; AAction: TCollectionNotification; ADispose: boolean);
     procedure NotifyTestNodeEmpty(ASender: TObject; ANode: PNode_Empty; AAction: TCollectionNotification; ADispose: boolean);
-    procedure NotifyTestStr(ASender: TObject; constref AItem: string; AAction: TCollectionNotification);
-    procedure NotifyTestObj(ASender: TObject; constref AItem: TObject; AAction: TCollectionNotification);
+    procedure NotifyTestStr(ASender: TObject; const AItem: string; AAction: TCollectionNotification);
+    procedure NotifyTestObj(ASender: TObject; const AItem: TObject; AAction: TCollectionNotification);
 
     procedure CreateObjects(var AArray: TArray<TObject>; ACount: Integer);
     procedure FreeObjects(AArray: TArray<TObject>);
@@ -381,7 +381,7 @@ begin
   Inc(NotificationsNodesIndex)
 end;
 
-procedure TTestCollections.NotifyTestStr(ASender: TObject; constref AItem: string; AAction: TCollectionNotification);
+procedure TTestCollections.NotifyTestStr(ASender: TObject; const AItem: string; AAction: TCollectionNotification);
 var
   LNotification: TNotificationRec_String;
 begin
@@ -396,7 +396,7 @@ begin
   Inc(NotificationsIndex)
 end;
 
-procedure TTestCollections.NotifyTestObj(ASender: TObject; constref AItem: TObject; AAction: TCollectionNotification);
+procedure TTestCollections.NotifyTestObj(ASender: TObject; const AItem: TObject; AAction: TCollectionNotification);
 var
   LNotification: TNotificationRec_TObject;
 begin

部分文件因文件數量過多而無法顯示