Class TRealList

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TRealList = class(TObject)

Description

TRealList is similar to TList except that it stores doubles instead of pointers.

Hierarchy

Overview

Fields

Private FList: TList;
Private FSorted: boolean;

Methods

Private function GetCapacity: integer;
Private function GetCount: integer;
Private function GetItem(Index: integer): double;
Private procedure SetCapacity(ACapacity: Integer);
Private procedure SetCount(Value: integer);
Private procedure SetItem(Index: integer; const AReal: double);
Private procedure SetSorted(const Value: boolean);
Public function Add(const AReal: double): integer;
Public function AddUnique(const AReal: double): integer;
Public procedure Assign(ARealList: TRealList);
Public procedure Clear;
Public constructor Create;
Public procedure Delete(const Index: Integer);
Public destructor Destroy; override;
Public class procedure Error(const Msg: string; Data: Integer); virtual;
Public procedure Exchange(Index1, Index2: Integer);
Public function First: double;
Public function IndexOf(const AReal: double): integer;
Public function IndexOfClosest(const AReal: double): integer;
Public procedure Insert(Index: Integer; AReal: double);
Public function Last: double;
Public procedure Move(CurIndex, NewIndex: Integer);
Public procedure Reverse;
Public procedure Sort;

Properties

Public property Capacity: integer read GetCapacity write SetCapacity;
Public property Count: integer read GetCount write SetCount;
Public property Items[Index:integer]: double read GetItem write SetItem;
Public property Sorted: boolean read FSorted write SetSorted;

Description

Fields

Private FList: TList;

FList: TList; FList is the internal list used to store the real numbers. It actually stores instances of TRealClass (defined in the implementation. Each of these stores one of the real numbers stored by TRealList.

Private FSorted: boolean;

FSorted: boolean;

Methods

Private function GetCapacity: integer;

See Capacity.

Private function GetCount: integer;

See Count.

Private function GetItem(Index: integer): double;

See Items.

Private procedure SetCapacity(ACapacity: Integer);

See Capacity.

Private procedure SetCount(Value: integer);

See Count.

Private procedure SetItem(Index: integer; const AReal: double);

See Items.

Private procedure SetSorted(const Value: boolean);

See Sorted.

Public function Add(const AReal: double): integer;

Add increases the count of the list by one. If the list is sorted, AReal is inserted at the appropriate place. Otherwise it is added at the end.

Public function AddUnique(const AReal: double): integer;

AddUnique adds AReal to the list if it isn't already in the list. otherwise it returns the position of AReal in the list.

Public procedure Assign(ARealList: TRealList);

Assign copies the contents of ARealList into the TRealList that calls Assign.

Public procedure Clear;

Clear removes all real numbers from the list.

Public constructor Create;

see inherited Create.

Public procedure Delete(const Index: Integer);

Delete removes the item at the position designated by Index

Public destructor Destroy; override;

see inherited Destroy.

Public class procedure Error(const Msg: string; Data: Integer); virtual;

Error generate an error message. See TList.Error.

Public procedure Exchange(Index1, Index2: Integer);

Exchange exchanges the real numbers at positions Index1 and Index2.

Public function First: double;

First returns the first real number in the list.

Public function IndexOf(const AReal: double): integer;

IndexOf returns the position of AReal in the list. If AReal is not in the list, IndexOf returns -1.

Public function IndexOfClosest(const AReal: double): integer;

IndexOfClosest, returns the position of the number in the list that is closest to AReal.

Public procedure Insert(Index: Integer; AReal: double);

Insert inserts AReal at Index.

Public function Last: double;

Last returns the last real number in the TRealList.

Public procedure Move(CurIndex, NewIndex: Integer);

Move moves the number at CurIndex to NewIndex.

Public procedure Reverse;
 
Public procedure Sort;

Sort sorts the numbers in the TRealList in ascending order and sets Sorted to true.

Properties

Public property Capacity: integer read GetCapacity write SetCapacity;

Capacity is the number of numbers that the TRealList can hold without reallocating memory. If you plan to add a large number of items to the TRealList, setting Capacity to a large enough number first can improve performance.

Public property Count: integer read GetCount write SetCount;

Count is the number of real numbers in the TRealList. Setting Count to a number larger than the current Count results in 0's being added to the end of TRealList.

Public property Items[Index:integer]: double read GetItem write SetItem;

Items is used to set or retrieve real numbers from the TRealList. Use Count to determine how many real numbers are in the TRealList.

Public property Sorted: boolean read FSorted write SetSorted;

If Sorted is true, the numbers in the list are in ascending order and when a new number is added (see Add ) to the list, it will be inserted in the correct position to keep the list sorted.


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