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

TStringHashList

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Implements a container used to store hashed item values, keys, and data.

Declaration

Source position: stringhashlist.pas line 41

type TStringHashList = class(TObject)

protected

  function HashOf();

  

Calculates the hash value for the specified String.

  procedure Insert();

  

Stores a hash item at the specified position in the container.

public

  constructor Create();

  

Constructor for the class instance.

  destructor Destroy; override;

  

Destructor for the class instance.

  function Add();

  

Adds a hash item and optional data to the container.

  procedure Clear;

  

Frees resources allocated for hash items and the storage for the list.

  function Find();

  

Gets the ordinal position in List where the specified key (and data) are stored.

  function Remove();

  

Frees resources allocated for the hash item and deletes it from the List.

  property CaseSensitive: Boolean; [rw]

  

Indicates if case sensitivity is used for hash item keys.

  property Count: Integer; [r]

  

Number of hash items stored in the List property.

  property Data []: Pointer; default; [rw]

  

Provided indexed access to the data for a hash item using its key value.

  property List: PStringHashItemList; [r]

  

Provides indexed access to the storage used in the container.

end;

Inheritance

TStringHashList

  

Implements a container used to store hashed item values, keys, and data.

|

TObject

Description

TStringHashList is a TObject descendant which implements a container for hash values, keys, and data for String types.

TStringHashList uses the PStringHashItem type to represent the items stored in the container. This provides a 32-bit hash value, which can reflect the case for the String value if desired. It also includes an untyped pointer to arbitrary data associated with the hashed item (when provided). Items in the container are stored in hash value order, and uses a binary search for retrieval.

Use the Add method to add String values, and optional pointers to their data, to the container.

Use the Find method to get the position of an item in the container using its String value.

Use the Remove method to delete a hash item with the specified String value.

Use the Clear method to remove all hashed items in the container.

Use the Count property to determine the number of hashed items stored in the container.

Use the List property to access the storage for the container. It can be used for indexed access to the PStringHashItemList pointers with the hash value, key, and data for the items.

Use the Data property to get an untyped pointer to the arbitrary data associated with the hash item with a given key (String). The pointer must be cast to the type needed in the application.

Use the CaseSensitive property to control whether the case for a Key value is used when the hash value is generated, or retrieved in the Find method. When set to False, the key value is converted to its uppercase equivalent when the hash value is generated or retrieved. The value in CaseSensitive must be assigned before any hash items are added to the container; an exception is raised when the property value is changed and the container is not empty.


Version 4.0 Generated 2025-05-03 Home