Microsoft Foundation Classes (mfc.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
class CObArray
CObject                                     Up Contents Index Back
──Microsoft Foundation Classes──────────────────────────────────────────────
 
  Description
 
  The CObArray class supports arrays of CObject pointers. These object
  arrays are similar to C arrays, but they can dynamically shrink and grow
  as necessary.
 
  Array indexes always start at position 0. You can decide whether to fix
  the upper bound or allow the array to expand when you add elements past
  the current bound. Memory is allocated contiguously to the upper bound,
  even if some elements are null.
 
  The elements of a CObArray object must fit in one 64K segment together
  with approximately 100 allocation overhead bytes. If CObject pointers
  are 16-bit near pointers (as they are in the small and medium memory
  models), then an array size limit is about 32,000 elements, but because
  there is only one data segment, the objects themselves will probably
  exhaust memory before the array does. If CObject pointers are 32-bit far
  pointers (as they are in the compact and large memory models), then an
  array size limit is about 16,000 elements.
 
  As with a C array, the access time for a CObArray indexed element is
  constant and is independent of the array size.
 
  CObArray incorporates the IMPLEMENT_SERIAL macro to support
  serialization and dumping of its elements. If an array of CObject
  pointers is stored to an archive, either with the overloaded insertion
  operator or with the Serialize member function, each CObject element is,
  in turn, serialized along with its array index.
 
  If you need a dump of individual CObject elements in an array, you must
  set the depth of the CDumpContext object to 1 or greater.
 
  When a CObArray object is deleted, or when its elements are removed,
  only the CObject pointers are removed, not the objects they reference.
 
  #include <afxcoll.h>
 
  See Also
 
  CStringArray, CPtrArray, CByteArray, CWordArray, CDWordArray
 
  Derivation
 
  Array class derivation is similar to list derivation. For details on the
  derivation of a special-purpose list class, see the tutorial in the
  <Class Library User's Guide>.
 
  NOTE: You must use the IMPLEMENT_SERIAL macro in the implementation of
        your derived class if you intend to serialize the array.
 
  Public Members
 
  Construction/Destruction
 
  CObArray   Constructs an empty array for CObject pointers.
 
  ~CObArray   Destroys a CObArray object.
 
  Bounds
 
  GetSize         Gets the number of elements in this array.
 
  GetUpperBound   Returns the largest valid index.
 
  SetSize         Sets the number of elements to be contained in this
                    array.
 
  Operations
 
  FreeExtra   Frees all unused memory above the current upper bound.
 
  RemoveAll   Removes all the elements from this array.
 
  Element Access
 
  GetAt       Returns the value at a given index.
 
  SetAt       Sets the value for a given index; array not allowed to
                grow.
 
  ElementAt   Returns a temporary reference to the element pointer
                within the array.
 
  Growing the Array
 
  SetAtGrow   Sets the value for a given index; grows the array if
                necessary.
 
  Add         Adds an element to the end of the array; grows the array
                if necessary.
 
  Insertion/Removal
 
  InsertAt   Inserts an element (or all the elements in another array)
               at a specified index.
 
  RemoveAt   Removes an element at a specific index.
 
  Operators
 
  operator []   Sets or gets the element at the specified index.
 
 
                                     -♦-