Castle Game Engine: CastleClassUtils: Class TCastleObjectList

# Class TCastleObjectList
Description | Hierarchy | Fields | Methods | Properties
## Unit CastleClassUtils ## Declaration `type TCastleObjectList = class(TObjectList)` ## Description Extended TObjectList for Castle Game Engine. ## Hierarchy TObjectList TCastleObjectList ## Overview ### Methods
| `constructor CreateFromArray(const FreeObjects: boolean; const AItems: array of TObject);`
| `procedure AddArray(const A: array of TObject);`
| `procedure AddList(AList: TObjectList);`
| `function MakeSingle(ReplaceClass: TClass; NewItem: TObject; AddBeginning: boolean = false): TObject;`
| `function Extract(Index: Integer): TObject; overload;`
| `function Extract(RemoveClass: TClass): TObject; overload;`
| `function DeleteAll(Item: TObject): Cardinal;`
| `function IsFirst(Value: TObject): boolean;`
| `function IsLast(Value: TObject): boolean;`
| `procedure InsertIfNotExists(Index: Integer; Value: TObject);`
| `procedure AddIfNotExists(Value: TObject);`
## Description ### Methods
| `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]);`.
| `procedure AddArray(const A: array of TObject);`
Add contents of given array to the list.
| `procedure AddList(AList: TObjectList);`
Add contents of other TObjectList instance to the list.
| `function MakeSingle(ReplaceClass: TClass; NewItem: TObject; AddBeginning: boolean = false): 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 AddBeginning 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 TCastleWindowBase.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 TCastleWindowBase.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.
| `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.
| `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).
| `function DeleteAll(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).
| `function IsFirst(Value: TObject): boolean;`
| `function IsLast(Value: TObject): boolean;`
| `procedure InsertIfNotExists(Index: Integer; Value: TObject);`
| `procedure AddIfNotExists(Value: TObject);`
Generated by PasDoc 0.13.0 on 2013-08-17 21:27:12