|
@@ -16,6 +16,14 @@
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
+ Acknowledgment
|
|
|
|
+
|
|
|
|
+ Thanks to Sphere 10 Software (http://sphere10.com) for sponsoring
|
|
|
|
+ many new types and major refactoring of entire library
|
|
|
|
+
|
|
|
|
+ Thanks to mORMot (http://synopse.info) project for the best implementations
|
|
|
|
+ of hashing functions like crc32c and xxHash32 :)
|
|
|
|
+
|
|
**********************************************************************}
|
|
**********************************************************************}
|
|
|
|
|
|
{$WARNINGS OFF}
|
|
{$WARNINGS OFF}
|
|
@@ -44,8 +52,7 @@ type
|
|
PKey = ^TKey;
|
|
PKey = ^TKey;
|
|
PValue = ^TValue;
|
|
PValue = ^TValue;
|
|
THashFactoryClass = THashFactory;
|
|
THashFactoryClass = THashFactory;
|
|
- public
|
|
|
|
- FItemsLength: SizeInt;
|
|
|
|
|
|
+ protected
|
|
FEqualityComparer: IEqualityComparer<TKey>;
|
|
FEqualityComparer: IEqualityComparer<TKey>;
|
|
FKeys: TEnumerable<TKey>;
|
|
FKeys: TEnumerable<TKey>;
|
|
FValues: TEnumerable<TValue>;
|
|
FValues: TEnumerable<TValue>;
|
|
@@ -63,8 +70,6 @@ type
|
|
property LoadFactor: single read GetLoadFactor;
|
|
property LoadFactor: single read GetLoadFactor;
|
|
property Capacity: SizeInt read GetCapacity write SetCapacity;
|
|
property Capacity: SizeInt read GetCapacity write SetCapacity;
|
|
|
|
|
|
- property Count: SizeInt read FItemsLength;
|
|
|
|
-
|
|
|
|
procedure Clear; virtual; abstract;
|
|
procedure Clear; virtual; abstract;
|
|
procedure Add(constref APair: TPair<TKey, TValue>); virtual; abstract;
|
|
procedure Add(constref APair: TPair<TKey, TValue>); virtual; abstract;
|
|
strict private // bug #24283. workaround for this class because can't inherit from TEnumerable
|
|
strict private // bug #24283. workaround for this class because can't inherit from TEnumerable
|
|
@@ -78,6 +83,8 @@ type
|
|
constructor Create(const AComparer: IEqualityComparer<TKey>); overload;
|
|
constructor Create(const AComparer: IEqualityComparer<TKey>); overload;
|
|
constructor Create(ACollection: TEnumerable<TDictionaryPair>); virtual; overload;
|
|
constructor Create(ACollection: TEnumerable<TDictionaryPair>); virtual; overload;
|
|
constructor Create(ACollection: TEnumerable<TDictionaryPair>; const AComparer: IEqualityComparer<TKey>); virtual; overload;
|
|
constructor Create(ACollection: TEnumerable<TDictionaryPair>; const AComparer: IEqualityComparer<TKey>); virtual; overload;
|
|
|
|
+ constructor Create(ACollection: TEnumerableWithPointers<TDictionaryPair>); virtual; overload;
|
|
|
|
+ constructor Create(ACollection: TEnumerableWithPointers<TDictionaryPair>; const AComparer: IEqualityComparer<TKey>); virtual; overload;
|
|
|
|
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
private
|
|
private
|
|
@@ -93,6 +100,10 @@ type
|
|
public
|
|
public
|
|
property OnKeyNotify: TCollectionNotifyEvent<TKey> read FOnKeyNotify write FOnKeyNotify;
|
|
property OnKeyNotify: TCollectionNotifyEvent<TKey> read FOnKeyNotify write FOnKeyNotify;
|
|
property OnValueNotify: TCollectionNotifyEvent<TValue> read FOnValueNotify write FOnValueNotify;
|
|
property OnValueNotify: TCollectionNotifyEvent<TValue> read FOnValueNotify write FOnValueNotify;
|
|
|
|
+ protected // FItemsLength must be declared at the end of TCustomDictionary
|
|
|
|
+ FItemsLength: SizeInt;
|
|
|
|
+ public
|
|
|
|
+ property Count: SizeInt read FItemsLength;
|
|
end;
|
|
end;
|
|
|
|
|
|
{ TCustomDictionaryEnumerator }
|
|
{ TCustomDictionaryEnumerator }
|
|
@@ -111,40 +122,51 @@ type
|
|
{ TDictionaryEnumerable }
|
|
{ TDictionaryEnumerable }
|
|
|
|
|
|
TDictionaryEnumerable<TDictionaryEnumerator: TObject; TDictionaryPointersEnumerator, // ... inherits from TCustomDictionaryEnumerator. workaround...
|
|
TDictionaryEnumerable<TDictionaryEnumerator: TObject; TDictionaryPointersEnumerator, // ... inherits from TCustomDictionaryEnumerator. workaround...
|
|
- T, PT, CUSTOM_DICTIONARY_CONSTRAINTS> = class abstract(TEnumerable<T>)
|
|
|
|
- private type
|
|
|
|
- PPointersCollection = ^TPointersCollection;
|
|
|
|
- TPointersCollection = record
|
|
|
|
- private
|
|
|
|
- function Dictionary: TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS>; inline;
|
|
|
|
- function GetCount: SizeInt; inline;
|
|
|
|
- public
|
|
|
|
- function GetEnumerator: TDictionaryPointersEnumerator;
|
|
|
|
- function ToArray: TArray<PT>;
|
|
|
|
- property Count: SizeInt read GetCount;
|
|
|
|
- end;
|
|
|
|
|
|
+ T, CUSTOM_DICTIONARY_CONSTRAINTS> = class abstract(TEnumerableWithPointers<T>)
|
|
private
|
|
private
|
|
- FPointers: TPointersCollection;
|
|
|
|
FDictionary: TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS>;
|
|
FDictionary: TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS>;
|
|
function GetCount: SizeInt;
|
|
function GetCount: SizeInt;
|
|
- function GetPointers: PPointersCollection; inline;
|
|
|
|
|
|
+ protected
|
|
|
|
+ function GetPtrEnumerator: TEnumerator<PT>; override;
|
|
|
|
+ function DoGetEnumerator: TDictionaryEnumerator; override;
|
|
public
|
|
public
|
|
constructor Create(ADictionary: TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS>);
|
|
constructor Create(ADictionary: TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS>);
|
|
- function DoGetEnumerator: TDictionaryEnumerator; override;
|
|
|
|
function ToArray: TArray<T>; override; final;
|
|
function ToArray: TArray<T>; override; final;
|
|
property Count: SizeInt read GetCount;
|
|
property Count: SizeInt read GetCount;
|
|
- property Ptr: PPointersCollection read GetPointers;
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
// more info : http://en.wikipedia.org/wiki/Open_addressing
|
|
// more info : http://en.wikipedia.org/wiki/Open_addressing
|
|
|
|
|
|
- { TDictionaryEnumerable }
|
|
|
|
|
|
+ { TOpenAddressingEnumerator }
|
|
|
|
|
|
TOpenAddressingEnumerator<T, OPEN_ADDRESSING_CONSTRAINTS> = class abstract(TCustomDictionaryEnumerator<T, CUSTOM_DICTIONARY_CONSTRAINTS>)
|
|
TOpenAddressingEnumerator<T, OPEN_ADDRESSING_CONSTRAINTS> = class abstract(TCustomDictionaryEnumerator<T, CUSTOM_DICTIONARY_CONSTRAINTS>)
|
|
protected
|
|
protected
|
|
function DoMoveNext: Boolean; override;
|
|
function DoMoveNext: Boolean; override;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ TOpenAddressingPointersEnumerator<TItem, PDictionaryPair> = class abstract(TEnumerator<PDictionaryPair>)
|
|
|
|
+ private var
|
|
|
|
+ FItems: ^TArray<TItem>;
|
|
|
|
+ FIndex: SizeInt;
|
|
|
|
+ protected
|
|
|
|
+ function DoMoveNext: boolean; override;
|
|
|
|
+ function DoGetCurrent: PDictionaryPair; override;
|
|
|
|
+ function GetCurrent: PDictionaryPair; virtual;
|
|
|
|
+ public
|
|
|
|
+ constructor Create(var AItems);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ TOpenAddressingPointersCollection<TPointersEnumerator, TItem, PDictionaryPair> = record
|
|
|
|
+ private type
|
|
|
|
+ PArray = ^TArray<TItem>;
|
|
|
|
+ function Items: PArray; inline;
|
|
|
|
+ function GetCount: SizeInt; inline;
|
|
|
|
+ public
|
|
|
|
+ function GetEnumerator: TPointersEnumerator;
|
|
|
|
+ function ToArray: TArray<PDictionaryPair>;
|
|
|
|
+ property Count: SizeInt read GetCount;
|
|
|
|
+ end;
|
|
|
|
+
|
|
TOnGetMemoryLayoutKeyPosition = procedure(Sender: TObject; AKeyPos: UInt32) of object;
|
|
TOnGetMemoryLayoutKeyPosition = procedure(Sender: TObject; AKeyPos: UInt32) of object;
|
|
|
|
|
|
TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS> = class abstract(TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS>)
|
|
TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS> = class abstract(TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS>)
|
|
@@ -156,9 +178,13 @@ type
|
|
end;
|
|
end;
|
|
|
|
|
|
TItemsArray = array of TItem;
|
|
TItemsArray = array of TItem;
|
|
- private var
|
|
|
|
- FItemsThreshold: SizeInt;
|
|
|
|
|
|
+ TPointersEnumerator = class(TOpenAddressingPointersEnumerator<TItem, PDictionaryPair>);
|
|
|
|
+ TPointersCollection = TOpenAddressingPointersCollection<TPointersEnumerator, TItem, PDictionaryPair>;
|
|
|
|
+ public type
|
|
|
|
+ PPointersCollection = ^TPointersCollection;
|
|
|
|
+ private var // FItems must be declared as first field
|
|
FItems: TItemsArray;
|
|
FItems: TItemsArray;
|
|
|
|
+ FItemsThreshold: SizeInt;
|
|
|
|
|
|
procedure Resize(ANewSize: SizeInt);
|
|
procedure Resize(ANewSize: SizeInt);
|
|
procedure PrepareAddingItem;
|
|
procedure PrepareAddingItem;
|
|
@@ -196,15 +222,16 @@ type
|
|
end;
|
|
end;
|
|
|
|
|
|
// Collections
|
|
// Collections
|
|
- TValueCollection = class(TDictionaryEnumerable<TValueEnumerator, TPValueEnumerator, TValue, PValue, CUSTOM_DICTIONARY_CONSTRAINTS>);
|
|
|
|
|
|
+ TValueCollection = class(TDictionaryEnumerable<TValueEnumerator, TPValueEnumerator, TValue, CUSTOM_DICTIONARY_CONSTRAINTS>);
|
|
|
|
|
|
- TKeyCollection = class(TDictionaryEnumerable<TKeyEnumerator, TPKeyEnumerator, TKey, PKey, CUSTOM_DICTIONARY_CONSTRAINTS>);
|
|
|
|
|
|
+ TKeyCollection = class(TDictionaryEnumerable<TKeyEnumerator, TPKeyEnumerator, TKey, CUSTOM_DICTIONARY_CONSTRAINTS>);
|
|
|
|
|
|
// bug #24283 - workaround related to lack of DoGetEnumerator
|
|
// bug #24283 - workaround related to lack of DoGetEnumerator
|
|
function GetEnumerator: TPairEnumerator; reintroduce;
|
|
function GetEnumerator: TPairEnumerator; reintroduce;
|
|
private
|
|
private
|
|
function GetKeys: TKeyCollection;
|
|
function GetKeys: TKeyCollection;
|
|
function GetValues: TValueCollection;
|
|
function GetValues: TValueCollection;
|
|
|
|
+ function GetPointers: PPointersCollection; inline;
|
|
private
|
|
private
|
|
function GetItem(const AKey: TKey): TValue; inline;
|
|
function GetItem(const AKey: TKey): TValue; inline;
|
|
procedure SetItem(const AKey: TKey; const AValue: TValue); inline;
|
|
procedure SetItem(const AKey: TKey; const AValue: TValue); inline;
|
|
@@ -241,6 +268,7 @@ type
|
|
property Items[Index: TKey]: TValue read GetItem write SetItem; default;
|
|
property Items[Index: TKey]: TValue read GetItem write SetItem; default;
|
|
property Keys: TKeyCollection read GetKeys;
|
|
property Keys: TKeyCollection read GetKeys;
|
|
property Values: TValueCollection read GetValues;
|
|
property Values: TValueCollection read GetValues;
|
|
|
|
+ property Ptr: PPointersCollection read GetPointers;
|
|
|
|
|
|
procedure GetMemoryLayout(const AOnGetMemoryLayoutKeyPosition: TOnGetMemoryLayoutKeyPosition);
|
|
procedure GetMemoryLayout(const AOnGetMemoryLayoutKeyPosition: TOnGetMemoryLayoutKeyPosition);
|
|
end;
|
|
end;
|
|
@@ -320,12 +348,15 @@ type
|
|
constructor Create(ACapacity: SizeInt; const AComparer: IEqualityComparer<TKey>); override; overload;
|
|
constructor Create(ACapacity: SizeInt; const AComparer: IEqualityComparer<TKey>); override; overload;
|
|
constructor Create(const AComparer: IEqualityComparer<TKey>); reintroduce; overload;
|
|
constructor Create(const AComparer: IEqualityComparer<TKey>); reintroduce; overload;
|
|
constructor Create(ACollection: TEnumerable<TDictionaryPair>; const AComparer: IEqualityComparer<TKey>); override; overload;
|
|
constructor Create(ACollection: TEnumerable<TDictionaryPair>; const AComparer: IEqualityComparer<TKey>); override; overload;
|
|
|
|
+ constructor Create(ACollection: TEnumerableWithPointers<TDictionaryPair>; const AComparer: IEqualityComparer<TKey>); override; overload;
|
|
public // bug #26181 (redundancy of constructors)
|
|
public // bug #26181 (redundancy of constructors)
|
|
constructor Create(ACapacity: SizeInt); override; overload;
|
|
constructor Create(ACapacity: SizeInt); override; overload;
|
|
constructor Create(ACollection: TEnumerable<TDictionaryPair>); override; overload;
|
|
constructor Create(ACollection: TEnumerable<TDictionaryPair>); override; overload;
|
|
|
|
+ constructor Create(ACollection: TEnumerableWithPointers<TDictionaryPair>); override; overload;
|
|
constructor Create(ACapacity: SizeInt; const AComparer: IExtendedEqualityComparer<TKey>); virtual; overload;
|
|
constructor Create(ACapacity: SizeInt; const AComparer: IExtendedEqualityComparer<TKey>); virtual; overload;
|
|
constructor Create(const AComparer: IExtendedEqualityComparer<TKey>); overload;
|
|
constructor Create(const AComparer: IExtendedEqualityComparer<TKey>); overload;
|
|
constructor Create(ACollection: TEnumerable<TDictionaryPair>; const AComparer: IExtendedEqualityComparer<TKey>); virtual; overload;
|
|
constructor Create(ACollection: TEnumerable<TDictionaryPair>; const AComparer: IExtendedEqualityComparer<TKey>); virtual; overload;
|
|
|
|
+ constructor Create(ACollection: TEnumerableWithPointers<TDictionaryPair>; const AComparer: IExtendedEqualityComparer<TKey>); virtual; overload;
|
|
end;
|
|
end;
|
|
|
|
|
|
TDeamortizedDArrayCuckooMapEnumerator<T, CUCKOO_CONSTRAINTS> = class abstract(TCustomDictionaryEnumerator<T, CUSTOM_DICTIONARY_CONSTRAINTS>)
|
|
TDeamortizedDArrayCuckooMapEnumerator<T, CUCKOO_CONSTRAINTS> = class abstract(TCustomDictionaryEnumerator<T, CUSTOM_DICTIONARY_CONSTRAINTS>)
|
|
@@ -343,6 +374,32 @@ type
|
|
constructor Create(ADictionary: TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS>);
|
|
constructor Create(ADictionary: TCustomDictionary<CUSTOM_DICTIONARY_CONSTRAINTS>);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ TDeamortizedDArrayPointersEnumerator<TCuckooCfg, TItemsArray, TItemsDArray, TQueueDictionary, PDictionaryPair> = class abstract(TEnumerator<PDictionaryPair>)
|
|
|
|
+ private var // FItems must be declared as first field and FQueue as second
|
|
|
|
+ FItems: ^TItemsDArray;
|
|
|
|
+ FQueue: TQueueDictionary;
|
|
|
|
+ FIndex: SizeInt;
|
|
|
|
+ FMainIndex: SizeInt;
|
|
|
|
+ protected
|
|
|
|
+ function DoMoveNext: boolean; override;
|
|
|
|
+ function DoGetCurrent: PDictionaryPair; override;
|
|
|
|
+ function GetCurrent: PDictionaryPair; virtual;
|
|
|
|
+ public
|
|
|
|
+ constructor Create(var AItems; AQueue: TQueueDictionary; ACount: SizeInt);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ TDeamortizedDArrayPointersCollection<TPointersEnumerator, TItemsDArray, TQueueDictionary, PDictionaryPair> = record
|
|
|
|
+ private type
|
|
|
|
+ PArray = ^TItemsDArray;
|
|
|
|
+ function Items: PArray; inline;
|
|
|
|
+ function GetCount: SizeInt; inline;
|
|
|
|
+ function GetQueue: TQueueDictionary; inline;
|
|
|
|
+ public
|
|
|
|
+ function GetEnumerator: TPointersEnumerator;
|
|
|
|
+ function ToArray: TArray<PDictionaryPair>;
|
|
|
|
+ property Count: SizeInt read GetCount;
|
|
|
|
+ end;
|
|
|
|
+
|
|
// more info :
|
|
// more info :
|
|
// http://arxiv.org/abs/0903.0391
|
|
// http://arxiv.org/abs/0903.0391
|
|
|
|
|
|
@@ -358,7 +415,7 @@ type
|
|
end;
|
|
end;
|
|
TValueForQueue = TItem;
|
|
TValueForQueue = TItem;
|
|
|
|
|
|
- TQueueDictionary = class(TOpenAddressingLP<TKey, TValueForQueue, TDelphiHashFactory, TLinearProbing>)
|
|
|
|
|
|
+ TQueueDictionary = class(TOpenAddressingLP<TKey, TValueForQueue, TDefaultHashFactory, TLinearProbing>)
|
|
private type // for workaround Lazarus bug #25613
|
|
private type // for workaround Lazarus bug #25613
|
|
_TItem = record
|
|
_TItem = record
|
|
Hash: UInt32;
|
|
Hash: UInt32;
|
|
@@ -379,16 +436,20 @@ type
|
|
end;
|
|
end;
|
|
|
|
|
|
// cycle-detection mechanism class
|
|
// cycle-detection mechanism class
|
|
- TCDM = class(TOpenAddressingSH<TKey, TEmptyRecord, TDelphiHashFactory, TLinearProbing>);
|
|
|
|
|
|
+ TCDM = class(TOpenAddressingSH<TKey, TEmptyRecord, TDefaultHashFactory, TLinearProbing>);
|
|
TItemsArray = array of TItem;
|
|
TItemsArray = array of TItem;
|
|
TItemsDArray = array[0..Pred(TCuckooCfg.D)] of TItemsArray;
|
|
TItemsDArray = array[0..Pred(TCuckooCfg.D)] of TItemsArray;
|
|
|
|
+ TPointersEnumerator = class(TDeamortizedDArrayPointersEnumerator<TCuckooCfg, TItemsArray, TItemsDArray, TQueueDictionary, PDictionaryPair>);
|
|
|
|
+ TPointersCollection = TDeamortizedDArrayPointersCollection<TPointersEnumerator, TItemsDArray, TQueueDictionary, PDictionaryPair>;
|
|
|
|
+ public type
|
|
|
|
+ PPointersCollection = ^TPointersCollection;
|
|
private var
|
|
private var
|
|
|
|
+ FItems: TItemsDArray;
|
|
FQueue: TQueueDictionary; // probably can be optimized - hash TItem give information from TItem.Hash for cuckoo ...
|
|
FQueue: TQueueDictionary; // probably can be optimized - hash TItem give information from TItem.Hash for cuckoo ...
|
|
// currently is kept in "TQueueDictionary = class(TOpenAddressingSH<TKey, TItem, ...>"
|
|
// currently is kept in "TQueueDictionary = class(TOpenAddressingSH<TKey, TItem, ...>"
|
|
|
|
|
|
FCDM: TCDM; // cycle-detection mechanism
|
|
FCDM: TCDM; // cycle-detection mechanism
|
|
FItemsThreshold: SizeInt;
|
|
FItemsThreshold: SizeInt;
|
|
- FItems: TItemsDArray;
|
|
|
|
// sadly there is bug #24848 for class var ...
|
|
// sadly there is bug #24848 for class var ...
|
|
{class} var
|
|
{class} var
|
|
CUCKOO_SIGN, CUCKOO_INDEX_SIZE, CUCKOO_HASH_SIGN: UInt32;
|
|
CUCKOO_SIGN, CUCKOO_INDEX_SIZE, CUCKOO_HASH_SIGN: UInt32;
|
|
@@ -431,15 +492,16 @@ type
|
|
end;
|
|
end;
|
|
|
|
|
|
// Collections
|
|
// Collections
|
|
- TValueCollection = class(TDictionaryEnumerable<TValueEnumerator, TPValueEnumerator, TValue, PValue, CUSTOM_DICTIONARY_CONSTRAINTS>);
|
|
|
|
|
|
+ TValueCollection = class(TDictionaryEnumerable<TValueEnumerator, TPValueEnumerator, TValue, CUSTOM_DICTIONARY_CONSTRAINTS>);
|
|
|
|
|
|
- TKeyCollection = class(TDictionaryEnumerable<TKeyEnumerator, TPKeyEnumerator, TKey, PKey, CUSTOM_DICTIONARY_CONSTRAINTS>);
|
|
|
|
|
|
+ TKeyCollection = class(TDictionaryEnumerable<TKeyEnumerator, TPKeyEnumerator, TKey, CUSTOM_DICTIONARY_CONSTRAINTS>);
|
|
|
|
|
|
// bug #24283 - workaround related to lack of DoGetEnumerator
|
|
// bug #24283 - workaround related to lack of DoGetEnumerator
|
|
function GetEnumerator: TPairEnumerator; reintroduce;
|
|
function GetEnumerator: TPairEnumerator; reintroduce;
|
|
private
|
|
private
|
|
function GetKeys: TKeyCollection;
|
|
function GetKeys: TKeyCollection;
|
|
function GetValues: TValueCollection;
|
|
function GetValues: TValueCollection;
|
|
|
|
+ function GetPointers: PPointersCollection; inline;
|
|
private
|
|
private
|
|
function GetItem(const AKey: TKey): TValue; inline;
|
|
function GetItem(const AKey: TKey): TValue; inline;
|
|
procedure SetItem(const AKey: TKey; const AValue: TValue); overload; inline;
|
|
procedure SetItem(const AKey: TKey; const AValue: TValue); overload; inline;
|
|
@@ -462,15 +524,18 @@ type
|
|
constructor Create(ACapacity: SizeInt; const AComparer: IEqualityComparer<TKey>); override; overload;
|
|
constructor Create(ACapacity: SizeInt; const AComparer: IEqualityComparer<TKey>); override; overload;
|
|
constructor Create(const AComparer: IEqualityComparer<TKey>); reintroduce; overload;
|
|
constructor Create(const AComparer: IEqualityComparer<TKey>); reintroduce; overload;
|
|
constructor Create(ACollection: TEnumerable<TDictionaryPair>; const AComparer: IEqualityComparer<TKey>); override; overload;
|
|
constructor Create(ACollection: TEnumerable<TDictionaryPair>; const AComparer: IEqualityComparer<TKey>); override; overload;
|
|
|
|
+ constructor Create(ACollection: TEnumerableWithPointers<TDictionaryPair>; const AComparer: IEqualityComparer<TKey>); override; overload;
|
|
public
|
|
public
|
|
// TODO: function TryFlushQueue(ACount: SizeInt): SizeInt;
|
|
// TODO: function TryFlushQueue(ACount: SizeInt): SizeInt;
|
|
|
|
|
|
constructor Create; override; overload;
|
|
constructor Create; override; overload;
|
|
constructor Create(ACapacity: SizeInt); override; overload;
|
|
constructor Create(ACapacity: SizeInt); override; overload;
|
|
constructor Create(ACollection: TEnumerable<TDictionaryPair>); override; overload;
|
|
constructor Create(ACollection: TEnumerable<TDictionaryPair>); override; overload;
|
|
|
|
+ constructor Create(ACollection: TEnumerableWithPointers<TDictionaryPair>); override; overload;
|
|
constructor Create(ACapacity: SizeInt; const AComparer: IExtendedEqualityComparer<TKey>); virtual; overload;
|
|
constructor Create(ACapacity: SizeInt; const AComparer: IExtendedEqualityComparer<TKey>); virtual; overload;
|
|
constructor Create(const AComparer: IExtendedEqualityComparer<TKey>); overload;
|
|
constructor Create(const AComparer: IExtendedEqualityComparer<TKey>); overload;
|
|
constructor Create(ACollection: TEnumerable<TDictionaryPair>; const AComparer: IExtendedEqualityComparer<TKey>); virtual; overload;
|
|
constructor Create(ACollection: TEnumerable<TDictionaryPair>; const AComparer: IExtendedEqualityComparer<TKey>); virtual; overload;
|
|
|
|
+ constructor Create(ACollection: TEnumerableWithPointers<TDictionaryPair>; const AComparer: IExtendedEqualityComparer<TKey>); virtual; overload;
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
|
|
|
|
procedure Add(constref APair: TPair<TKey, TValue>); override; overload;
|
|
procedure Add(constref APair: TPair<TKey, TValue>); override; overload;
|
|
@@ -488,6 +553,7 @@ type
|
|
property Items[Index: TKey]: TValue read GetItem write SetItem; default;
|
|
property Items[Index: TKey]: TValue read GetItem write SetItem; default;
|
|
property Keys: TKeyCollection read GetKeys;
|
|
property Keys: TKeyCollection read GetKeys;
|
|
property Values: TValueCollection read GetValues;
|
|
property Values: TValueCollection read GetValues;
|
|
|
|
+ property Ptr: PPointersCollection read GetPointers;
|
|
|
|
|
|
property QueueCount: SizeInt read GetQueueCount;
|
|
property QueueCount: SizeInt read GetQueueCount;
|
|
procedure GetMemoryLayout(const AOnGetMemoryLayoutKeyPosition: TOnGetMemoryLayoutKeyPosition);
|
|
procedure GetMemoryLayout(const AOnGetMemoryLayoutKeyPosition: TOnGetMemoryLayoutKeyPosition);
|
|
@@ -531,17 +597,17 @@ type
|
|
|
|
|
|
// useful generics overloads
|
|
// useful generics overloads
|
|
TOpenAddressingLP<TKey, TValue, THashFactory> = class(TOpenAddressingLP<TKey, TValue, THashFactory, TLinearProbing>);
|
|
TOpenAddressingLP<TKey, TValue, THashFactory> = class(TOpenAddressingLP<TKey, TValue, THashFactory, TLinearProbing>);
|
|
- TOpenAddressingLP<TKey, TValue> = class(TOpenAddressingLP<TKey, TValue, TDelphiHashFactory, TLinearProbing>);
|
|
|
|
|
|
+ TOpenAddressingLP<TKey, TValue> = class(TOpenAddressingLP<TKey, TValue, TDefaultHashFactory, TLinearProbing>);
|
|
|
|
|
|
TObjectOpenAddressingLP<TKey, TValue, THashFactory> = class(TObjectOpenAddressingLP<TKey, TValue, THashFactory, TLinearProbing>);
|
|
TObjectOpenAddressingLP<TKey, TValue, THashFactory> = class(TObjectOpenAddressingLP<TKey, TValue, THashFactory, TLinearProbing>);
|
|
- TObjectOpenAddressingLP<TKey, TValue> = class(TObjectOpenAddressingLP<TKey, TValue, TDelphiHashFactory, TLinearProbing>);
|
|
|
|
|
|
+ TObjectOpenAddressingLP<TKey, TValue> = class(TObjectOpenAddressingLP<TKey, TValue, TDefaultHashFactory, TLinearProbing>);
|
|
|
|
|
|
// Linear Probing with Tombstones (LPT)
|
|
// Linear Probing with Tombstones (LPT)
|
|
TOpenAddressingLPT<TKey, TValue, THashFactory> = class(TOpenAddressingSH<TKey, TValue, THashFactory, TLinearProbing>);
|
|
TOpenAddressingLPT<TKey, TValue, THashFactory> = class(TOpenAddressingSH<TKey, TValue, THashFactory, TLinearProbing>);
|
|
- TOpenAddressingLPT<TKey, TValue> = class(TOpenAddressingSH<TKey, TValue, TDelphiHashFactory, TLinearProbing>);
|
|
|
|
|
|
+ TOpenAddressingLPT<TKey, TValue> = class(TOpenAddressingSH<TKey, TValue, TDefaultHashFactory, TLinearProbing>);
|
|
|
|
|
|
TOpenAddressingQP<TKey, TValue, THashFactory> = class(TOpenAddressingQP<TKey, TValue, THashFactory, TQuadraticProbing>);
|
|
TOpenAddressingQP<TKey, TValue, THashFactory> = class(TOpenAddressingQP<TKey, TValue, THashFactory, TQuadraticProbing>);
|
|
- TOpenAddressingQP<TKey, TValue> = class(TOpenAddressingQP<TKey, TValue, TDelphiHashFactory, TQuadraticProbing>);
|
|
|
|
|
|
+ TOpenAddressingQP<TKey, TValue> = class(TOpenAddressingQP<TKey, TValue, TDefaultHashFactory, TQuadraticProbing>);
|
|
|
|
|
|
TOpenAddressingDH<TKey, TValue, THashFactory> = class(TOpenAddressingDH<TKey, TValue, THashFactory, TDoubleHashing>);
|
|
TOpenAddressingDH<TKey, TValue, THashFactory> = class(TOpenAddressingDH<TKey, TValue, THashFactory, TDoubleHashing>);
|
|
TOpenAddressingDH<TKey, TValue> = class(TOpenAddressingDH<TKey, TValue, TDelphiDoubleHashFactory, TDoubleHashing>);
|
|
TOpenAddressingDH<TKey, TValue> = class(TOpenAddressingDH<TKey, TValue, TDelphiDoubleHashFactory, TDoubleHashing>);
|