[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Objects' (#rtl)

# TCollection

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Manage a collection of pointers of objects

## Declaration

Source position: objects.pp line 404

`type TCollection = object(TObject)`
`Items: PItemList;` |  | Pointer to list of items.
`Count: Sw_Integer;` |  | Current count of items
`Limit: Sw_Integer;` |  | Max number of items
`Delta: Sw_Integer;` |  | Number of pointers to allocate when adding items.
`constructor Init();` |  | Instantiate a new collection.
`constructor Load();` |  | Initialize a new collection and load collection from a stream.
`destructor Done; virtual;` |  | Clean up collection, release all memory.
`function At();` |  | Return the item at a certain index.
`function IndexOf(); virtual;` |  | Find the position of a certain item.
`function GetItem(); virtual;` |  | Read one item off the stream.
`function LastThat();` |  | Return last item which matches a test.
`function FirstThat();` |  | Return first item which matches a test.
`procedure Pack;` |  | Remove all >Nil pointers from the collection.
`procedure FreeAll;` |  | Release all objects from the collection.
`procedure DeleteAll;` |  | Delete all elements from the collection. Objects are not destroyed.
`procedure Free();` |  | Free item from collection, calling it's destructor.
`procedure Insert(); virtual;` |  | Insert a new item in the collection at the end.
`procedure Delete();` |  | Delete an item from the collection, but does not destroy it.
`procedure AtFree();` |  | Free an item at the indicates position, calling it's destructor.
`procedure FreeItem(); virtual;` |  | Destroy a non-nil item.
`procedure AtDelete();` |  | Delete item at certain position.
`procedure ForEach();` |  | Execute procedure for each item in the list.
`procedure SetLimit(); virtual;` |  | Set maximum number of elements in the collection.
`procedure Error(); virtual;` |  | Set error code.
`procedure AtPut();` |  | Set collection item, overwriting an existing value.
`procedure AtInsert();` |  | Insert an element at a certain position in the collection.
`procedure Store();` |  | Write collection to a stream.
`procedure PutItem(); virtual;` |  | Put one item on the stream
`end;`

## Inheritance

`TCollection` |  | Manage a collection of pointers of objects
`TObject` |  | Basis of all objects

## Description

The TCollection object manages a collection of pointers or objects. It also provides a series of methods to manipulate these pointers or objects.

Whether or not objects are used depends on the kind of calls you use. All kinds come in 2 flavors, one for objects, one for pointers.

Documentation generated on: May 14 2021