Click here to Skip to main content
15,896,457 members
Articles / Desktop Programming / MFC

Quick and Dirty Collection Class Notes

Rate me:
Please Sign up or sign in to vote.
4.11/5 (10 votes)
28 Nov 2000 97K   1K   33  
An article describing MFC Collection Classes
The Short and Dirty on Template Collections

===============================================================================
A Word From Microsoft:

The nontemplate collection classes have been provided by MFC beginning with MFC
version 1.0. If your code already uses these classes, you can continue to use
them. If you write new type-safe collection classes for your own data types,
consider using the newer template-based classes.

===============================================================================

                                        Not referenced in this paper
Arrays
        CArray                          CByteArray
        CTypedPtrArray                  CDWordArray
                CObArray                CStringArray
                CPtrArray               CUintArray
                                        CWordArray

Lists
        CList                           CStringList
        CTypedPtrList
                CObList
                CPtrList

Maps
        CMap                            CMapWordToOb
        CTypedPtrMap                    CMapStringToOb
                CMapWordToPtr           CMapStringToString
                CMapPtrToWord
                CMapPtrToPtr
                CMapStringToPtr

===============================================================================
Collection contents           Arrays          Lists           Maps
----------------------------  --------------- --------------- --------------
Collections of OBJECTS
of any type                   CArray          CList           CMap

Collections of POINTERS       CTypedPtrArray  CTypedPtrList   CTypedPtrMap
to objects of any type
Must be one of the non-
template pointer collect-
ions predefined by MFC,
such as CPtrList or CPtrArray

===============================================================================
CArray
        A non-unique array of simple types, objects or pointers.
CList
        An ordered list of nonunique objects.
CMap
        An ordered list of unique objects.
CTypedPtrArray
        A type-safe �wrapper� for objects of class CPtrArray or CObArray.
CTypedPtrList
        A type-safe �wrapper� for objects of class CPtrList or CObList.
CTypedPtrMap
        A type-safe �wrapper� for objects of the pointer-map classes
        CMapPtrToPtr, CMapPtrToWord, CMapWordToPtr, and CMapStringToPtr

===============================================================================
                         Insert     Search for        Duplicate
Shape  Ordered? Indexed? an element specified element elements?
------ -------- -------- ---------- ----------------- ---------
List   Yes      No       Fast       Slow              Yes
Array  Yes      By int   Slow       Slow              Yes
Map    No       By key   Fast       Fast              No (keys)
                                                      Yes (values)

Note: All collections can grow dynamically. Even arrays have SetAtGrow.
===============================================================================



By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions