PushMapPosition()

Syntaxe

PushMapPosition(Map())
Description
Remembers the current element (if any) of the map so it can later be restored using PopMapPosition(). The position is remembered on a stack structure, so multiple calls to this function are possible.

Arguments

Map() Specifies the map to use.

Valeur de retour

This function has no return value.

Remarks

This function can be used to remember the current element, so an iteration can be made over the map using NextMapElement() or ForEach and the current element can be restored after the iteration using PopMapPosition(). Multiple calls can be made to this function, as long as each is balanced with a corresponding PopMapPosition() call later.

Note: It is not allowed to delete an element that is a remembered current element using the DeleteMapElement() or ClearMap() function. This may result in a crash when PopMapPosition() is called because the elements memory is no longer valid.

Exemple

  NewMap Numbers()
  Numbers("A") = 1
  Numbers("B") = 2
  Numbers("C") = 5
  Numbers("D") = 3
  Numbers("E") = 2
  Numbers("F") = 5
  
  ; A simple duplicate elimination using a nested iteration
  ;
  ForEach Numbers()
    Value = Numbers()
    PushMapPosition(Numbers())
    While NextMapElement(Numbers())
      If Numbers() = Value 
        DeleteMapElement(Numbers())
      EndIf
    Wend
    PopMapPosition(Numbers())
  Next
  
  ForEach Numbers()
    Debug Numbers()
  Next

See Also

PopMapPosition(), FindMapElement(), NextMapElement(), ResetMap(), ForEach

OS Supportés

Tous

<- PopMapPosition() - Map Index - ResetMap() ->