Foundation Class Collections Limited to 32K Total ObjectsLast reviewed: July 17, 1997Article ID: Q85515 |
7.00 | 1.00 1.50 1.51 1.52
MS-DOS | WINDOWS
kbprg
The information in this article applies to:
SUMMARYEach object of the "collection" classes provided by the Microsoft Foundation Classes can store no more than 32,767 objects. Collection classes include the following:
Arrays Lists Maps ---------------------------------------------------- CByteArray CObList CMapPtrToWord CDWordArray CPtrList CMapPtrToPtr CObArray CStringList CMapStringToOb CPtrArray CMapStringToOb CStringArray CMapStringToString CWordArray CMapWordToOb CMapWordToPtr MORE INFORMATIONEach of the Microsoft Foundation Classes collection classes uses a signed integers to store the total number of objects in an object of the class. In MS-DOS and 16-bit Windows, a signed integer is limited to 32K. In Windows NT, a 32-bit signed integer can index up to 2 billion items. If you need to store more than 32K objects in a collection object, you can create a collection class that does not use an "int" to index the array. The TEMPLDEF sample program includes a sample "list" implementation, which may be modified to implement a collection of more than 32K objects. Changing the type of the list's index variable from an "int" to a "long" allows an application to create a list that contains up to 2,048,000 objects. To implement the modified "list" class, perform the following six steps:
NOTE: You cannot serialize a CLongList object because serialization does not support more than 32K objects in an instance of a class. The TEMPLDEF sample program also provides the source code for ARRAY and MAP classes in the ARRAY.CTT and MAP.CTT files, respectively. You can modify these files as above to create map classes that support more than 32K elements. The ARRAY class has an additional limitation. The CObArray class implements an "array" of pointers to CObjects or objects derived from CObject. This array, and about 100 bytes of overhead, must reside in one 64K segment. Therefore, the array is limited to approximately 32,000 elements if the CObject pointers are 16-bit near pointers (as appropriate for the small or medium memory models) or 16,000 elements if the pointers are 32-bit far pointers (as appropriate for the compact and large memory models).
|
Additional reference words: kbinf 7.00 1.00 1.50 2.00 2.50 2.51 2.52
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |