Class TCastleObjectList

Unit

Declaration

type TCastleObjectList = class(TObjectList)

Description

Extended TObjectList for Castle Game Engine.

Hierarchy

Overview

Methods

Public constructor CreateFromArray(const FreeObjects: boolean; const AItems: array of TObject);
Public procedure AddRange(const A: array of TObject); overload;
Public procedure AddArray(const A: array of TObject); deprecated 'use AddRange, consistent with other lists';
Public procedure AddRange(AList: Contnrs.TObjectList); overload;
Public procedure AddList(AList: Contnrs.TObjectList); deprecated 'use AddRange, consistent with other lists';
Public function MakeSingle(ReplaceClass: TClass; NewItem: TObject; AddEnd: boolean): TObject;
Public function Extract(Index: Integer): TObject; overload;
Public function Extract(RemoveClass: TClass): TObject; overload;
Public function RemoveAll(Item: TObject): Cardinal;
Public function IsFirst(Value: TObject): boolean;
Public function IsLast(Value: TObject): boolean;
Public procedure InsertIfNotExists(Index: Integer; Value: TObject);
Public procedure AddIfNotExists(Value: TObject);

Description

Methods

Public constructor CreateFromArray(const FreeObjects: boolean; const AItems: array of TObject);

Create and fill with the contents of given array.

Since in ObjectPascal you can create open array parameter on the fly, this constructor is often comfortable to use, for example you can write List := TCastleObjectList.Create(..., [Item1, Item2]);.

Public procedure AddRange(const A: array of TObject); overload;

Add contents of given array to the list.

Public procedure AddArray(const A: array of TObject); deprecated 'use AddRange, consistent with other lists';

Warning: this symbol is deprecated: use AddRange, consistent with other lists

 
Public procedure AddRange(AList: Contnrs.TObjectList); overload;

Add contents of other TObjectList instance to the list.

Public procedure AddList(AList: Contnrs.TObjectList); deprecated 'use AddRange, consistent with other lists';

Warning: this symbol is deprecated: use AddRange, consistent with other lists

 
Public function MakeSingle(ReplaceClass: TClass; NewItem: TObject; AddEnd: boolean): TObject;

Replace first found descendant of ReplaceClass with NewItem. In case no descendant of ReplaceClass was found, we'll we add NewItem to the list (depending on AddEnd value: at the beginning or at the end of the list).

If NewItem is Nil, this simply removes the first found descendant of ReplaceClass.

Returns the replaced (or removed) old item. It is removed from the list just like the Extract method, so it's never freed. Or Nil, if none was found (or there was Nil inside the list).

The typical use scenario for this method is when NewItem is also a descendant from ReplaceClass, and you always keep at most one ReplaceClass descendant on the list. For example, you have UI controls list (like TCastleWindow.Controls), and you want your NewItem to be the only instance of TCastleOnScreenMenu class inside. Moreover, in case order on the list is important (for example on TCastleWindow.Controls order corresponds to screen depth — what control is under / above each other), you want to place NewItem at the same position as previous TCastleOnScreenMenu instance, if any.

Public function Extract(Index: Integer): TObject; overload;

Extract (remove from the list, but never free) given item index. This is similar TObjectList.Extract, except it takes an index.

Public function Extract(RemoveClass: TClass): TObject; overload;

Extract (remove from the list, but never free) first found descendant of RemoveClass. Returns the removed item. Or Nil, if none was found (or there was Nil inside the list and it got removed).

Public function RemoveAll(Item: TObject): Cardinal;

Delete (do not free) all found instances of the given Item. Shifts all other pointers to the left. Returns how many instances were removed (that is, how much Count was decreased).

Public function IsFirst(Value: TObject): boolean;
 
Public function IsLast(Value: TObject): boolean;
 
Public procedure InsertIfNotExists(Index: Integer; Value: TObject);
 
Public procedure AddIfNotExists(Value: TObject);
 

Generated by PasDoc 0.16.0.