[tvision Index] [tvision Hierarchy] [Headers]
A non-streamable collection of objects More...
#include <tvobjs.h>
Inherits: TObject
A non-streamable collection of objects.
This class stores an array of pointers to generic objects. This array may grow or shrink at run-time. Note: type `ccIndex' is defined in file `ttypes.h' as `int'.
[public]
Constructor.
`aLimit' is the initial size of the array of pointers. `aDelta' is used every time the array must be enlarged. In this case a number of `aDelta' pointers will be added to the array.
[public]
Destructor.
Deletes the array of pointers. Does not delete the objects.
[public virtual]
Releases all the resources allocated by this class.
If class flag `shouldDelete' is True the function freeAll() is called. This will delete each object of the array.
[public]
Returns the address of the object at position `index'.
[public virtual]
Returns the position of an object in the array.
The address is passed in the `item' parameter. If the object does not exist the function error() will be called.
[public]
Removes the object at position `index' from the array.
Then calls delete on the object.
[public]
Removes the object at position `index' from the array.
Does not call delete on the object.
[public]
Removes the object at address `item' from the array.
It just does `atRemove(indexOf(item))'. Does not call delete on the object.
[public]
It just sets class variable `count' to 0.
[public]
Removes the object at address `index' from the array.
It just does `atRemove(indexOf(item))'. Then calls delete on the object.
[public]
Deletes all the objects in the array.
The array is cleared out but not deleted.
[public]
Inserts a new object at position `index'.
Objects starting from position `index' to the end of the array are moved one position forward.
[public]
Replaces the object at position `index'.
Old object is lost.
[public virtual]
Inserts an object at the end of the array.
[public virtual]
This function is called on error conditions.
By default calls function exit() to terminate the program.
[public]
Applies a test function to each object in the array.
`Test' is a pointer to a function whose type `ccTestFunc' is defined as:
typedef Boolean (*ccTestFunc)(void *, void *)
This method returns when one object of the array passes the test or when each object is tested without success. In the first case it returns the address of the object. In the latter case it returns 0. `arg' stores the argument of the function (if you need it).
This method scans the array forward. This is an example:
#define Uses_TNSCollection
#include "tv.h"
class XObject {
int value;
public:
XObject(int aValue): value(aValue) {}
int getValue() { return value; }
};
Boolean matchTest(void *obj, void *value) {
if (((XObject *) obj)->getValue() == *((int *) value)) return True;
return False;
}
void main() {
TNSCollection array(10, 5);
array.insert(new XObject(14));
array.insert(new XObject(32));
array.insert(new XObject(23));
array.insert(new XObject(41));
int find = 23;
XObject *p = (XObject *) array.firstThat(&matchTest, &find);
if (p != 0) array.free(p);
}
[public]
Applies a test function to each object in the array.
This method scans the array backward.
[public]
Applies a function to each object in the array.
`action' is a pointer to a function whose type `ccAppFunc' is defined as:
typedef void (*ccAppFunc)(void *, void *);
This method scans the array forward.
[public]
Packs the array by removing null pointers from it.
[public virtual]
Resizes the array.
`aLimit' is the new size. If it is lesser than `count' the new size will be forced to be `count'. It it is grater than `maxCollectionSize' the new size will be forced to be `maxCollectionSize'. Integer constant `maxCollectionSize' is defined in `tvconfig.h' as `INT_MAX / sizeof(void *)'.
[public]
Returns the number of pointers stored in the array.
[protected]
Constructor.
[protected]
This variable stores the array starting address.
[protected]
This variable stores the number of objects in the array.
[protected]
Current size of the array. Greater or equal to `count'.
[protected]
This value is used every time the array must be enlarged. In this case a number of `delta' pointers will be added to the array.
[protected]
If this flag is True, all objects will be deleted when method shutDown() is called. Its initial value is True.
Documentation generated by sergio@athena.milk.it on Wed Feb 10 22:11:47 CET 1999 | Kdoc |