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.
CMapStringToOb::GetNextAssoc
CMapStringToOb                              Up Contents Index Back
──Microsoft Foundation Classes──────────────────────────────────────────────
 
  void GetNextAssoc( POSITION& rNextPosition, CString& rKey,
                     CObject*& rValue ) const;
 
  Parameter       Description
 
  <rNextPosition> Specifies a reference to a POSITION value returned by a
                  previous GetNextAssoc or GetStartPosition call.
 
  <rKey>          Specifies the returned key of the retrieved element (a
                  string).
 
  <rValue>        Specifies the returned value of the retrieved element (a
                  CObject pointer).
 
  Remarks
 
  Retrieves the map element at <rNextPosition>, then updates
  <rNextPosition> to refer to the next element in the map. This function
  is most useful for iterating through all the elements in the map. Note
  that the position sequence is not necessarily the same as the key value
  sequence.
 
  If the retrieved element is the last in the map, then the new value of
  <rNextPosition> is set to NULL.
 
  Example
 
  CMapStringToOb map;
  POSITION pos;
  CString key;
  CAge* pa;
 
  map.SetAt( "Bart", new CAge( 13 ) );
  map.SetAt( "Lisa", new CAge( 11 ) );
  map.SetAt( "Homer", new CAge( 36 ) );
  map.SetAt( "Marge", new CAge( 35 ) );
  // Iterate through the entire map, dumping both name and age
  for( pos = map.GetStartPosition(); pos != NULL; )
  {
      map.GetNextAssoc( pos, key, pa );
  }
 
 
  The results from this program are as follows:
 
  Lisa : a CAge at $4724 11
  Marge : a CAge at $47A8 35
  Homer : a CAge at $4766 36
  Bart : a CAge at $45D4 13
 
  See Also
 
  CMapStringToOb::GetStartPosition
 
 
                                     -♦-