티스토리 뷰

정보 보관 ver1.0

Map(Nontemplate)

James Wetzel 2011. 11. 8. 13:41

CMapStringToString

The CMapStringToString class supports maps of CString objects keyed by CString objects.

The member functions of CMapStringToString are similar to the member functions of class CMapStringToOb. Because of this similarity, you can use the CMapStringToOb reference documentation for member function specifics. Wherever you see a CObject pointer as a return value or “output” function parameter, substitute a pointer to char. Wherever you see a CObject pointer as an “input” function parameter, substitute a pointer to char.

BOOL CMapStringToOb::Lookup( const char* <key>,
                             CObject*& <rValue> ) const;

for example, translates to

BOOL CMapStringToString::Lookup( LPCTSTR <key>,
                                 CString& <rValue> ) const;

CMapStringToString incorporates the IMPLEMENT_SERIAL macro to support serialization and dumping of its elements. Each element is serialized in turn if a map is stored to an archive, either with the overloaded insertion (<<) operator or with the Serialize member function.

If you need a dump of individual CString-CString elements, you must set the depth of the dump context to 1 or greater.

When a CMapStringToString object is deleted, or when its elements are removed, the CString objects are removed as appropriate.

For more information on CMapStringToString, see the article Collections in Visual C++ Programmer’s Guide.

#include <afxcoll.h>

Class Members | Base Class | Hierarchy Chart

Sample MFC Sample COLLECT 

 

CMapWordToPtr

The CMapWordToPtr class supports maps of void pointers keyed by 16-bit words.

The member functions of CMapWordToPtr are similar to the member functions of class CMapStringToOb. Because of this similarity, you can use the CMapStringToOb reference documentation for member function specifics. Wherever you see a CObject pointer as a function parameter or return value, substitute a pointer to void. Wherever you see a CString or a const pointer to char as a function parameter or return value, substitute WORD.

BOOL CMapStringToOb::Lookup( const char* <key>,
                             CObject*& <rValue> ) const;

for example, translates to

BOOL CMapWordToPtr::Lookup( WORD <key>, void*& <rValue> ) const;

CMapWordToPtr incorporates the IMPLEMENT_DYNAMIC macro to support run-time type access and dumping to a CDumpContext object. If you need a dump of individual map elements, you must set the depth of the dump context to 1 or greater.

Word-to-pointer maps may not be serialized.

When a CMapWordToPtr object is deleted, or when its elements are removed, the words and the pointers are removed. The entities referenced by the pointers are not removed.

For more information on CMapWordToPtr, see the article Collections in Visual C++ Programmer’s Guide.

#include <afxcoll.h>

Class Members | Base Class | Hierarchy Chart 

CMapPtrToWord

The CMapPtrToWord class supports maps of 16-bit words keyed by void pointers.

The member functions of CMapPtrToWord are similar to the member functions of class CMapStringToOb. Because of this similarity, you can use the CMapStringToOb reference documentation for member function specifics.

At a Glance

Header file: Afxcoll.h
Platforms:
Versions: 1.0 and later
Complete documentation: Visual C++ documentation

See Also

Class Members, Map Classes, CMapStringToOb

 

CMapPtrToPtr

The CMapPtrToPtr class supports maps of void pointers keyed by void pointers.

The member functions of CMapPtrToPtr are similar to the member functions of class CMapStringToOb. Because of this similarity, you can use the CMapStringToOb reference documentation for member function specifics. Wherever you see a CObject pointer as a function parameter or return value, substitute a pointer to void. Wherever you see a CString or a const pointer to char as a function parameter or return value, substitute a pointer to void.

BOOL CMapStringToOb::Lookup( const char* <key>,
                             CObject*& <rValue> ) const;

for example, translates to

BOOL CMapPtrToPtr::Lookup( void* <key>, void*& <rValue> ) const;

CMapPtrToPtr incorporates the IMPLEMENT_DYNAMIC macro to support run-time type access and dumping to a CDumpContext object. If you need a dump of individual map elements (pointer values), you must set the depth of the dump context to 1 or greater.

Pointer-to-pointer maps may not be serialized.

When a CMapPtrToPtr object is deleted, or when its elements are removed, only the pointers are removed, not the entities they reference.

For more information on CMapPtrToPtr, see the article Collections in Visual C++ Programmer’s Guide.

#include <afxcoll.h>

Class Members | Base Class | Hierarchy Chart   

 

CMapStringToOb

CMapStringToOb is a dictionary collection class that maps unique CString objects to CObject pointers. Once you have inserted a CString-CObject* pair (element) into the map, you can efficiently retrieve or delete the pair using a string or a CString value as a key. You can also iterate over all the elements in the map.

A variable of type POSITION is used for alternate entry access in all map variations. You can use a POSITION to “remember” an entry and to iterate through the map. You might think that this iteration is sequential by key value; it is not. The sequence of retrieved elements is indeterminate.

CMapStringToOb incorporates the IMPLEMENT_SERIAL macro to support serialization and dumping of its elements. Each element is serialized in turn if a map is stored to an archive, either with the overloaded insertion (<<) operator or with the Serialize member function.

If you need a diagnostic dump of the individual elements in the map (the CString value and the CObject contents), you must set the depth of the dump context to 1 or greater.

When a CMapStringToOb object is deleted, or when its elements are removed, the CString objects and the CObject pointers are removed. The objects referenced by the CObject pointers are not destroyed.

Map class derivation is similar to list derivation. See the article Collections in Visual C++ Programmer’s Guide for an illustration of the derivation of a special-purpose list class.

#include <afxcoll.h>

Class Members | Base Class | Hierarchy Chart

See Also CMapPtrToPtr, CMapPtrToWord, CMapStringToPtr, CMapStringToString, CMapWordToOb, CMapWordToPtr 

CMapStringToPtr

The CMapStringToPtr class supports maps of void pointers keyed by CString objects.

The member functions of CMapStringToPtr are similar to the member functions of class CMapStringToOb. Because of this similarity, you can use the CMapStringToOb reference documentation for member function specifics. Wherever you see a CObject pointer as a function parameter or return value, substitute a pointer to void.

BOOL CMapStringToOb::Lookup( const char* <key>,
                             CObject*& <rValue> ) const;

for example, translates to

BOOL CMapStringToPtr::Lookup( LPCTSTR <key>, void*& <rValue> )
                              const;

CMapStringToPtr incorporates the IMPLEMENT_DYNAMIC macro to support run-time type access and dumping to a CDumpContext object. If you need a dump of individual map elements, you must set the depth of the dump context to 1 or greater.

String-to-pointer maps may not be serialized.

When a CMapStringToPtr object is deleted, or when its elements are removed, the CString key objects and the words are removed.

#include <afxcoll.h>

Class Members | Base Class | Hierarchy Chart 

 

CMapStringToString

The CMapStringToString class supports maps of CString objects keyed by CString objects.

The member functions of CMapStringToString are similar to the member functions of class CMapStringToOb. Because of this similarity, you can use the CMapStringToOb reference documentation for member function specifics. Wherever you see a CObject pointer as a return value or “output” function parameter, substitute a pointer to char. Wherever you see a CObject pointer as an “input” function parameter, substitute a pointer to char.

BOOL CMapStringToOb::Lookup( const char* <key>,
                             CObject*& <rValue> ) const;

for example, translates to

BOOL CMapStringToString::Lookup( LPCTSTR <key>,
                                 CString& <rValue> ) const;

CMapStringToString incorporates the IMPLEMENT_SERIAL macro to support serialization and dumping of its elements. Each element is serialized in turn if a map is stored to an archive, either with the overloaded insertion (<<) operator or with the Serialize member function.

If you need a dump of individual CString-CString elements, you must set the depth of the dump context to 1 or greater.

When a CMapStringToString object is deleted, or when its elements are removed, the CString objects are removed as appropriate.

For more information on CMapStringToString, see the article Collections in Visual C++ Programmer’s Guide.

#include <afxcoll.h>

Class Members | Base Class | Hierarchy Chart

Sample MFC Sample COLLECT 

 

Class Members

Construction

CMapStringToString Constructs a collection that maps CString objects to CString objects.

Operations

Lookup Returns a CString using a CString value as a key.
SetAt Inserts an element into the map; replaces an existing element if a matching key is found.
operator [] Inserts an element into the map — operator substitution for SetAt.
RemoveKey Removes an element specified by a key.
RemoveAll Removes all the elements from this map.
GetStartPosition Returns the position of the first element.
GetNextAssoc Gets the next element for iterating.

Status

GetCount Returns the number of elements in this map.
IsEmpty Tests for the empty-map condition (no elements).

CMapStringToString Overview | Base Class Members | Hierarchy Chart

728x90
반응형