Class TSparsePointerArray

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TSparsePointerArray = class(TObject)

Description

TSparsePointerArray acts like an array of pointers with constant time access to Items. However, it uses less memory than an array for cases where many of the pointers are nil.

Hierarchy

Overview

Fields

Private secDir: TSecDirType;
Private slotsInDir: Cardinal;
Private indexMask: Word;
Private secShift: Word;
Private FHighBound: Integer;
Private FSectionSize: Word;
Private cachedIndex: Integer;
Private cachedValue: TCustomData;

Methods

Private function GetAt(Index: Integer): TCustomData;
Private function MakeAt(Index: Integer): PPointer;
Private procedure PutAt(Index: Integer; Item: TCustomData);
Public constructor Create(Quantum: TSPAQuantum);
Public destructor Destroy; override;
Public function ForAll(ApplyFunction: TSPAApply): Integer;
Public procedure ResetHighBound;

Properties

Public property HighBound: Integer read FHighBound;
Public property SectionSize: Word read FSectionSize;
Public property Items[Index:Integer]: TCustomData read GetAt write PutAt;

Description

Fields

Private secDir: TSecDirType;
 
Private slotsInDir: Cardinal;
 
Private indexMask: Word;
 
Private secShift: Word;
 
Private FHighBound: Integer;
 
Private FSectionSize: Word;
 
Private cachedIndex: Integer;
 
Private cachedValue: TCustomData;
 

Methods

Private function GetAt(Index: Integer): TCustomData;

Return item[i], nil if slot outside defined section.

Private function MakeAt(Index: Integer): PPointer;

Return address of item[i], creating slot if necessary.

Private procedure PutAt(Index: Integer; Item: TCustomData);

Store item at item[i], creating slot if necessary.

Public constructor Create(Quantum: TSPAQuantum);
 
Public destructor Destroy; override;
 
Public function ForAll(ApplyFunction: TSPAApply): Integer;

Traverse SPA, calling apply function for each defined non-nil item. The traversal terminates if the apply function returns a value other than 0. NOTE: must be static method so that we can take its address in TSparseList.ForAll

See TSPAApply

Public procedure ResetHighBound;

Ratchet down HighBound after a deletion

Properties

Public property HighBound: Integer read FHighBound;
 
Public property SectionSize: Word read FSectionSize;
 
Public property Items[Index:Integer]: TCustomData read GetAt write PutAt;
 

Generated by PasDoc 0.12.1 on 2013-05-13 15:42:03