Skip to content

TCustomBucketList

Custom bucket list class.

Declaration

Source position: contnrs.pp line 547

type

  TCustomBucketList = class(TObject)
  public
    destructor Destroy;
    procedure Clear;
    function Add : Pointer;
    procedure Assign;
    function Exists : Boolean;
    function Find : Boolean;
    function ForEach(AProc: TBucketProc; AInfo: Pointer=Nil) : Boolean;
    function ForEach(AProc: TBucketProcObject) : Boolean;
    function Remove : Pointer;
    property Data[AItem : Pointer]: Pointer; {rw}
  end;

Description

TCustomBucketList is an associative list using buckets for storage. It scales better than a regular TList list class, especially when an item must be searched in the list.

Since the list associates a data pointer with each item pointer, it follows that each item pointer must be unique, and can be added to the list only once.

The TCustomBucketList class does not determine the number of buckets or the bucket hash mechanism, this must be done by descendent classes such as TBucketList. TCustomBucketList only takes care of storage and retrieval of items in the various buckets.

Because TCustomBucketList is an abstract class - it does not determine the number of buckets - one should never instantiate an instance of TCustomBucketList, but always use a descendent class such as TCustomBucketList.

Properties

Member Visibility Description
Data public Associative array for data pointers.
See all Properties

Methods

Member Visibility Description
Add public Add an item to the list.
Assign public Assign one bucket list to another.
Clear public Clear the list.
Destroy public Frees the bucketlist from memory.
Exists public Check if an item exists in the list.
Find public Find an item in the list.
ForEach public Loop over all items.
Remove public Remove an item from the list.
See all Methods

See also

Name Description
TBucketList Default bucket list implementation.