Aracılığıyla paylaş


CMapStringToOb::GetNextAssoc

Harita öğede alır rNextPosition, daha sonra güncelleştirmeleri rNextPosition Haritası'nda bir sonraki öğeye başvuruda bulunmak için.

void GetNextAssoc(
   POSITION& rNextPosition,
   CString& rKey,
   CObject*& rValue 
) const;

Parametreler

  • rNextPosition
    Başvuru belirtir bir konumu bir önceki tarafından döndürülen değeri GetNextAssoc veya GetStartPosition çağırın.

  • rKey
    (Dize) alınan öğe döndürülen anahtarı belirtir.

  • rValue
    Alınan öğe döndürülen değeri belirtir (bir CObject işaretçisi).Bu parametre hakkında daha fazla bilgi için Açıklamalar'a bakın.

Notlar

Bu işlev Haritası içindeki tüm öğeleri arasında dolaşmak için kullanışlıdır.Konum sırası mutlaka anahtar değeri sırası ile aynı olmadığını unutmayın.

Alınan öğe eşlemedeki son sonra yeni değeri ise rNextPosition ayarlamak null.

İçin rValue parametresi, nesne türü'ne atama yapmak mutlaka CObject * &, olduğu ne derleyici gerektirir, aşağıdaki örnekte gösterildiği gibi:

CObject* ob;
map.GetNextAssoc(pos, key, (CObject*&)ob);      

Bu doğru değil GetNextAssoc şablonları temel alan eşlemeleri.

Diğer üye benzer işlevleri aşağıdaki tabloda gösterilmektedir CMapStringToOb::GetNextAssoc.

Sınıf

Üye işlevi

CMapPtrToPtr

void GetNextAssoc (konum & rNextPosition, void * & rKey, void * & rValue ) const;

CMapPtrToWord

void GetNextAssoc (konum & rNextPosition, void * & rKey, Word'Ü & rValue ) const;

CMapStringToPtr

void GetNextAssoc (konum & rNextPosition, CString & rKey, void * & rValue ) const;

CMapStringToString

void GetNextAssoc (konum & rNextPosition, CString & rKey, CString & rValue ) const;

CMapWordToOb

void GetNextAssoc (konum & rNextPosition, Word'Ü & rKey, CObject * & rValue ) const;

CMapWordToPtr

void GetNextAssoc (konum & rNextPosition, Word'Ü & rKey, void * & rValue ) const;

Örnek

Bkz: CObList::CObList bir listesi için CAge tüm koleksiyon örneklerde kullanılan sınıf.

CMapStringToOb map;
POSITION pos;
CString key;
CAge* pa;

map.SetAt(_T("Bart"), new CAge(13));
map.SetAt(_T("Lisa"), new CAge(11));
map.SetAt(_T("Homer"), new CAge(36));
map.SetAt(_T("Marge"), new CAge(35));
// Iterate through the entire map, dumping both name and age.
for (pos = map.GetStartPosition(); pos != NULL;)
{
   map.GetNextAssoc(pos, key, (CObject*&)pa);
   #ifdef _DEBUG
         afxDump << key << _T(" : ") << pa << _T("\n");
   #endif
}

Bu programdan sonuçlar aşağıdaki gibidir:

Lisa : a CAge at $4724 11

Marge : a CAge at $47A8 35

Homer : a CAge at $4766 36

Bart : a CAge at $45D4 13

Gereksinimler

Başlık: afxcoll.h

Ayrıca bkz.

Başvuru

CMapStringToOb sınıfı

Hiyerarşi grafik

CMapStringToOb::GetStartPosition