Class TDynArray_1

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TDynArray_1 = class(TDynArrayBase)

Description

no description available, TDynArrayBase description follows

Hierarchy

Overview

Methods

Public constructor Create; overload;
Public constructor Create(InitialLength: Integer); overload;
Public constructor CreateCopy(Source: TDynArray_1);
Public procedure SetLength(NewLength: Integer); override;
Public procedure AppendItem(const Item: TDynArrayItem_1);
Public procedure AppendArray(const NewItems: array of TDynArrayItem_1); overload;
Public procedure AppendArray(const NewItems: array of TDynArrayItem_1; NewItemsAddCount: integer); overload;
Public procedure AppendDynArray(Arr: TDynArray_1); overload;
Public procedure AppendDynArray(Arr: TDynArray_1; Index, ACount: Integer); overload;
Public procedure Assign(Source: TDynArray_1);
Public procedure AssignArray(const NewItems: array of TDynArrayItem_1);
Public procedure Delete(Index, DelCount: integer);
Public procedure Insert(Index: integer; const Item: TDynArrayItem_1);
Public procedure SetAll(const Item: TDynArrayItem_1);
Public procedure Sort(IsSmallerFunc: TDynArrayItemIsSmallerFunc_1; CountToUseSimpleSort: Integer = DefaultCountToUseSimpleSort); overload;
Public procedure Sort(IsSmallerFunc: TDynArrayItemIsSmallerFunc_1; FirstIndex, LastIndex: integer; CountToUseSimpleSort: Integer = DefaultCountToUseSimpleSort); overload;
Public procedure SortByObject(IsSmallerFunc: TDynArrayItemIsSmallerFuncByObject_1; CountToUseSimpleSort: Integer = DefaultCountToUseSimpleSort); overload;
Public procedure SortByObject(IsSmallerFunc: TDynArrayItemIsSmallerFuncByObject_1; FirstIndex, LastIndex: integer; CountToUseSimpleSort: Integer = DefaultCountToUseSimpleSort); overload;

Properties

Public property Items: PInfiniteArray_1 read GetItems;
Public property ItemsArray: PInfiniteArray_1 read GetItemsArray;
Public property Pointers[ItemNum: integer]: PDynArrayItem_1 read GetPointers;

Description

Methods

Public constructor Create; overload;
 
Public constructor Create(InitialLength: Integer); overload;
 
Public constructor CreateCopy(Source: TDynArray_1);
 
Public procedure SetLength(NewLength: Integer); override;
 
Public procedure AppendItem(const Item: TDynArrayItem_1);

AppendItem = IncLength and set last element to Item

Public procedure AppendArray(const NewItems: array of TDynArrayItem_1); overload;
 
Public procedure AppendArray(const NewItems: array of TDynArrayItem_1; NewItemsAddCount: integer); overload;
 
Public procedure AppendDynArray(Arr: TDynArray_1); overload;
 
Public procedure AppendDynArray(Arr: TDynArray_1; Index, ACount: Integer); overload;
 
Public procedure Assign(Source: TDynArray_1);

Copies contents of Source to this object.

This is equivalent to doing Length := 0 and AppendDynarray(Source). Maybe some day I will make TDynArray_1 descendant of TPersistent, then I will make Assign compatible with the TPersistent.Assign interface.

Remember that this is *not* a so-called deep copy, because if Source contains some pointers we're simply copying these pointers (not duplicating their content constructing new objects or something like that). This is just a simple copy of memory contents (well, with proper Initialize/Finalize in case DYNARRAY_1_IS_INIT_FINI_TYPE).

Public procedure AssignArray(const NewItems: array of TDynArrayItem_1);

This is equivalent to Count := 0 and then AppendArray(NewItems).

Public procedure Delete(Index, DelCount: integer);

Just like Delete from Pascal's RTL on strings: deletes Count items starting from position Index. Length of array will be decreased by Count items, and the last items of array will be shifted to the left to take positions of deleted items.

Note that Index and DelCount parameters will be checked for correctness and eventually corrected. So if Index is >= Count then nothing will be removed. And if DelCount items from Index would be larger than Count then DelCount will be corrected to be smaller.

Public procedure Insert(Index: integer; const Item: TDynArrayItem_1);

Inserts Item at position Index into array. Index must be in range 0 .. Count (yes, we can insert element at the end of the array). After insertion array has Count increased by 1, Items[Index] = Item and all items that were on positions [Index..old High] are now at [Index+1..new High].

Public procedure SetAll(const Item: TDynArrayItem_1);
 
Public procedure Sort(IsSmallerFunc: TDynArrayItemIsSmallerFunc_1; CountToUseSimpleSort: Integer = DefaultCountToUseSimpleSort); overload;

Sorts items. All you have to do is to pass some IsSmallerFunc – see KambiUtils.Sort for specification what it should do, but note that TDynArrayItemIsSmallerFunc_1 here gets parameter types already casted to TDynArrayItem_1, instead of dirty pointers (like IsSmallerFunc that must be passed to KambiUtils.Sort).

If you don't give First/LastIndex it assumes FirstIndex = 0 and LastIndex = High, so the whole array will be sorted.

Public procedure Sort(IsSmallerFunc: TDynArrayItemIsSmallerFunc_1; FirstIndex, LastIndex: integer; CountToUseSimpleSort: Integer = DefaultCountToUseSimpleSort); overload;
 
Public procedure SortByObject(IsSmallerFunc: TDynArrayItemIsSmallerFuncByObject_1; CountToUseSimpleSort: Integer = DefaultCountToUseSimpleSort); overload;
 
Public procedure SortByObject(IsSmallerFunc: TDynArrayItemIsSmallerFuncByObject_1; FirstIndex, LastIndex: integer; CountToUseSimpleSort: Integer = DefaultCountToUseSimpleSort); overload;
 

Properties

Public property Items: PInfiniteArray_1 read GetItems;

This is a comfortable Items property, that allows you to both read and write items in this array.

Note that it has different types: for Delphi (and FPC Delphi mode) it has PInfiniteArray_1 type, for ObjFpc mode is has PDynArrayItem_1. This way you can always access items like Items[Index] (no need to write Itemsˆ[Index]).

Public property ItemsArray: PInfiniteArray_1 read GetItemsArray;

This is like Items, but it has always (both for FPC ObjFpc mode and Delphi) type PInfiniteArray_1. This means that you can always read/write items like ItemsArrayˆ[Index]. Under ObjFpc you will not be able to write ItemsArray[Index] (i.e. omit this ˆ character).

Public property Pointers[ItemNum: integer]: PDynArrayItem_1 read GetPointers;
 

Generated by PasDoc 0.11.0 on 2008-09-12 11:58:32