Important: The information in this document is obsolete and should not be used for new development.
Lists and Iteration
A list is a data structure that stores a variable number of items of similar types. MacApp provides classes for creating and manipulating lists, making it possible for your application to use lists without having to implement the low-level details.MacApp's list classes are implemented on top of a dynamic array model. Each item in a list has a unique index--you can access items in a list by index or by standard list-traversal methods.
The following list describes some of MacApp's list classes:
Iteration is a general-purpose mechanism for traversing the items in a list. MacApp provides the
- TDynamicArray. The
TDynamicArrayclass descends fromTObjectand is the base class for all MacApp list classes. Objects of this class manage a dynamically allocated array of elements.- TSortedDynamicArray. The
TSortedDynamicArrayclass adds ordering to the array with the addition of methods for comparing array elements and for adding elements in order.- TSortedList. The
TSortedListclass adds methods and fields for an ordered list in which each element is a reference to an object.TSortedListand its descendant classes work only with objects that descend from theTObjectclass.- TList. The
TListclass is a special case ofTSortedListthat doesn't sort the objects. This class is used widely by MacApp and can be a valuable tool in your application as well.- TAssociation. The
TAssociationclass manages a sorted list of entries, in which each entry associates aCStringkey with aCStringvalue.TAssociationis useful for storing a list of strings that can be accessed by their associated keys.- THandleList. The
THandleListclass stores references to handles. It can be useful for dealing with a variety of developer-defined data types.
CIteratorclass and a large number of specialized subclasses that operate on lists containing items of various types. Iteration classes can traverse the items in a list without knowing the exact details of the data structures involved.The use of iteration classes with MacApp's failure-handling mechanism can require extra caution. See "Failure Handling Embedded in Objects" on page 59 for more information. For additional information on using lists and iterators in your application, see Chapter 25, "Working With Lists and Iteration."