[Overview][Constants][Types][Classes][Index] |
[Properties (by Name)] [Methods (by Name)] [Events (by Name)]
Name of the class that store all functions and data for an hashed array.
Source position: dynhasharray.pp line 70
type TDynHashArray = class |
||
protected |
||
procedure RebuildItems; |
|
Rebuilds the internal data structures. |
procedure SaveCacheItem(); |
|
Sets the cache. |
public |
||
constructor Create(); |
|
Constructor for the class instance. |
destructor Destroy; override; |
|
Destructor for the class instance. |
procedure Add(); |
|
Adds an item to the set/array. |
function Contains(); |
|
Returns True if the item is in the set. |
function ContainsKey(); |
|
Returns True if the item is in the set.(through OnGetKeyForHashItem). |
procedure Remove(); |
|
Removes an element from the set/hash array. |
procedure Clear; |
|
Removes all elements from the set/hash array. |
procedure ClearCache; |
|
Clears the FContainsCache cache. |
function First; |
|
Returns the first item or nil. |
|
Number of elements stored in the set/array. |
|
function IndexOf(); |
|
Returns calculated index from Item through OnGetKeyForHashItem. |
function IndexOfKey(); |
|
Returns calculated index from Item. |
function FindHashItem(); |
|
Finds an item as PDynHashArrayItem among all items. |
function FindHashItemWithKey(); |
|
Finds an item as PDynHashArrayItem among all items (through OnGetKeyForHashItem). |
function FindItemWithKey(); |
|
Finds an item among all items (through OnGetKeyForHashItem). |
function GetHashItem(); |
|
Gets a link list from the "main" array FItems by index. |
procedure Delete(); |
|
Deletes a PDynHashArrayItem from link list. |
procedure AssignTo(); |
|
Copies all items into a given TList. |
procedure ForEach(); |
|
Calls the specified function for each of the items in the hash array. |
function SlowAlternativeHashMethod(); |
|
Another hash function that can be used. |
function ConsistencyCheck; |
|
Check if data in TDynHashArray are OK. |
procedure WriteDebugReport; |
|
Prints out essential data to aid debugging TDynHashArray. |
property FirstHashItem: PDynHashArrayItem; [r] |
|
Pointer which provides access to the first TDynHashArrayItem stored in the hash array. |
property MinCapacity: Integer; [rw] |
|
The minimum number of items that will be allocated for an array. |
property MaxCapacity: Integer; [rw] |
|
The size of the array cannot be larger than this number. |
|
Space is allocated for this number of items. |
|
property CustomHashFunction: THashFunction; [rw] |
|
The pointer to the user-defined hash function. |
property OwnerHashFunction: TOwnerHashFunction; [rw] |
|
The pointer to the user-defined hash function. |
property OnGetKeyForHashItem: TOnGetKeyForHashItem; [rw] |
|
User-defined function to obtain a key from an item. |
property Options: TDynHashArrayOptions; [rw] |
|
Set of TDynHashArrayOption values enabled for the class instance. |
end; |
|
Name of the class that store all functions and data for an hashed array. |
|
| | ||
TObject |
TDynHashArray is a class which is similar to TList which allows both pointers and objects to be maintained in its internal storage. It includes common methods like Add, Remove, Contains, First, Count and Clear. Because of its hashing nature, the add, remove, and find operations are done in constant time on average.
Inner structure:
There are three parts:
Issues:
The maximum capacity is the PrimeNumber. You can store more items, but the performance decreases. The best idea is to provide your own hash function.
Important: Items in the TDynHashArray must not change their key. When changing the key of an item, remove it and add it after the change.
Version 4.0 | Generated 2025-05-03 | Home |