Sign in Join
FPDoc Onlineexperiment

TCache.Add function

Member of TCachepublicIn unit CacheCls

Add a data element to the list.

Declaration

pascal
function Add(AData: Pointer): Integer

Arguments

AData

Data pointer to add to the cache.

Function result

Index at which item was added.

Description

Add checks whether AData is already in the list. If so, the item is added to the top of the MRU list. If the item is not yet in the list, then the item is added to the list and placed at the top of the MRU list using the AddNew call.

The function returns the index at which the item was added.

If the maximum number of slots is reached, and a new item is being added, the least used item is dropped from the list.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.