BList

A BList object is a compact, ordered list of data pointers. BList objects can contain pointers to any type of data, including—and especially—objects.

An item assigned to a BList is identified by an index to its position in the list. Indices start at 0 and are neither arbitrary nor permanent. If, for example, you insert an item into the middle of a list, the indices of the items at the tail of the list are incremented (by one). Similarly, removing an item decrements the indices of the following items.

A BList stores its items as type void*, so it's necessary to cast an item to the correct type when you retrieve it. For example, items retrieved from a list of BBitmap objects must be cast as BBitmap pointers:

BBitmap *theImage = (BBitmap *)myList->ItemAt(anIndex);
Warning
Warning

There's nothing to prevent you from adding a NULL pointer to a BList. However, functions that retrieve items from the list (such as ItemAt()) return NULL when the requested item can't be found. Thus, you can't distinguish between a valid NULL item and an invalid attempt to access an item that isn't there.

Creative Commons License
Legal Notice
This work is licensed under a Creative Commons Attribution-Non commercial-No Derivative Works 3.0 License.