Class TDynArray_2

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TDynArray_2 = class(TDynArrayBase)

Description

no description available, TDynArrayBase description follows

Hierarchy

Overview

Methods

Public constructor Create; overload;
Public constructor Create(InitialLength: Integer); overload;
Public procedure AppendItem(const Item: TDynArrayItem_2);
Public procedure AppendArray(const NewItems: array of TDynArrayItem_2); overload;
Public procedure AppendArray(const NewItems: array of TDynArrayItem_2; NewItemsAddCount: integer); overload;
Public procedure AppendDynArray(Arr: TDynArray_2);
Public procedure Assign(Source: TDynArray_2);
Public procedure AssignArray(const NewItems: array of TDynArrayItem_2);
Public function EqualItems(const Item1, Item2: TDynArrayItem_2): boolean;
Public function Equal(DynArr: TDynArray_2): boolean; overload;
Public function Equal(const Arr: array of TDynArrayItem_2): boolean; overload;
Public function Equal(const Arr: array of TDynArrayItem_2; ArrCount: Integer): boolean; overload;
Public function IndexOf(const Item: TDynArrayItem_2): Integer;
Public function IndexInRange(const Item: TDynArrayItem_2; BeginIndex, EndIndex: Integer): Integer;
Public procedure DeleteFirstEqual(const Value: TDynArrayItem_2);
Public procedure DeleteAllEqual(const Value: TDynArrayItem_2);
Public procedure Delete(Index, DelCount: integer);
Public procedure Insert(Index: integer; const Item: TDynArrayItem_2);
Public procedure SetAll(const Item: TDynArrayItem_2);
Public procedure Sort(IsSmallerFunc: TDynArrayItemIsSmallerFunc_2; CountToUseSimpleSort: Integer = DefaultCountToUseSimpleSort); overload;
Public procedure Sort(IsSmallerFunc: TDynArrayItemIsSmallerFunc_2; FirstIndex, LastIndex: integer; CountToUseSimpleSort: Integer = DefaultCountToUseSimpleSort); overload;
Public procedure SortByObject(IsSmallerFunc: TDynArrayItemIsSmallerFuncByObject_2; CountToUseSimpleSort: Integer = DefaultCountToUseSimpleSort); overload;
Public procedure SortByObject(IsSmallerFunc: TDynArrayItemIsSmallerFuncByObject_2; FirstIndex, LastIndex: integer; CountToUseSimpleSort: Integer = DefaultCountToUseSimpleSort); overload;

Properties

Public property Items: PInfiniteArray_2 read GetItems;
Public property ItemsArray: PInfiniteArray_2 read GetItemsArray;
Public property Pointers[ItemNum: integer]: PDynArrayItem_2 read GetPointers;
Public property Values[ItemNum: integer]: TDynArrayItem_2 read GetValues write SetValues;

Description

Methods

Public constructor Create; overload;
 
Public constructor Create(InitialLength: Integer); overload;
 
Public procedure AppendItem(const Item: TDynArrayItem_2);

AppendItem = IncLength and set last element to Item

Public procedure AppendArray(const NewItems: array of TDynArrayItem_2); overload;
 
Public procedure AppendArray(const NewItems: array of TDynArrayItem_2; NewItemsAddCount: integer); overload;
 
Public procedure AppendDynArray(Arr: TDynArray_2);
 
Public procedure Assign(Source: TDynArray_2);

Copies contents of Source to this object.

This is equivalent to doing Length := 0 and AppendDynarray(Source). Maybe some day I will make TDynArray_2 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_2_IS_INIT_FINI_TYPE).

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

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

Public function EqualItems(const Item1, Item2: TDynArrayItem_2): boolean;
 
Public function Equal(DynArr: TDynArray_2): boolean; overload;
 
Public function Equal(const Arr: array of TDynArrayItem_2): boolean; overload;
 
Public function Equal(const Arr: array of TDynArrayItem_2; ArrCount: Integer): boolean; overload;
 
Public function IndexOf(const Item: TDynArrayItem_2): Integer;

Returns -1 if not found

Public function IndexInRange(const Item: TDynArrayItem_2; BeginIndex, EndIndex: Integer): Integer;

Returns -1 if not found, searches within Items[BeginIndex] .. Items[EndIndex]. BeginIndex may be < 0 and EndIndex may be > High, it doesn't matter, the range will be "clamped" as it should.

Public procedure DeleteFirstEqual(const Value: TDynArrayItem_2);

Searches for and deletes first item equal to Value.

Public procedure DeleteAllEqual(const Value: TDynArrayItem_2);

Searches for and deletes all items equal to Value.

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_2);

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_2);
 
Public procedure Sort(IsSmallerFunc: TDynArrayItemIsSmallerFunc_2; 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_2 here gets parameter types already casted to TDynArrayItem_2, 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_2; FirstIndex, LastIndex: integer; CountToUseSimpleSort: Integer = DefaultCountToUseSimpleSort); overload;
 
Public procedure SortByObject(IsSmallerFunc: TDynArrayItemIsSmallerFuncByObject_2; CountToUseSimpleSort: Integer = DefaultCountToUseSimpleSort); overload;
 
Public procedure SortByObject(IsSmallerFunc: TDynArrayItemIsSmallerFuncByObject_2; FirstIndex, LastIndex: integer; CountToUseSimpleSort: Integer = DefaultCountToUseSimpleSort); overload;
 

Properties

Public property Items: PInfiniteArray_2 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_2 type, for ObjFpc mode is has PDynArrayItem_2. This way you can always access items like Items[Index] (no need to write Itemsˆ[Index]).

Public property ItemsArray: PInfiniteArray_2 read GetItemsArray;

This is like Items, but it has always (both for FPC ObjFpc mode and Delphi) type PInfiniteArray_2. 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_2 read GetPointers;
 
Public property Values[ItemNum: integer]: TDynArrayItem_2 read GetValues write SetValues;
 

Generated by PasDoc 0.10.0 on 2008-02-25 00:00:31