[Overview][Constants][Types][Classes][Index] Reference for unit 'DynHashArray' (#lazutils)

Reference for unit 'DynHashArray'

Contains classes used to manage dynamic sets or associative arrays.

uses

  System,

  Classes,

  sysutils,

  LazLoggerBase;

  

Defines base logging classes used in the Lazarus IDE.

Overview

dynhasharray.pp extends the functionality of Pascal by offering alternative data structure: set like array (the order is not kept) with fast find/delete. Its size can change automatically during the execution of the program. The price is that it is somewhat slower than a number indexes access of an array.

This unit defines TDynHashArray, which is very similar to a TList, since it also stores pointer/objects.

It supports Add, Remove, Contains, First, Count and Clear.

Because of the hashing nature the operations adding, removing and finding is 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.

dynhasharray.pp is part of the LazUtils package.


Version 3.2 Generated 2024-02-25 Home