CompareMap()

Syntax

Result = CompareMap(Map1(), Map2() [, Flags])
Description
Compare each elements of the two maps for equality. Recursively compares also contents of structured maps with dynamic elements (such as embedded arrays, lists or maps). The two maps are considered the equal if they have the same type and size and if each pair of elements is equal.

Parameters

Map1(), Map2() The maps to compare.
Flags (optional) Can be a combination of the following values:
  #PB_String_CaseSensitive : String comparison is case sensitive (a=a). (default)
  #PB_String_NoCase        : String comparison is case insensitive(a=A).
  #PB_Memory_FollowPointers: If a structure element is a pointer that is not 0, recursively compare the pointer target. 
                              The default is to compare only the pointer value itself. See remarks below for details.

Return value

Returns nonzero if both maps are the same or zero if they differ.

Remarks

The #PB_Memory_FollowPointers option is for advanced users and requires special care to avoid crashes. If this option is used then all pointer values must point to valid and initialized memory or have the value 0. It is also not allowed to have loops in the pointed elements (a chain of pointers that refers back to itself).

Example

  NewMap A()
  A("de") = 49
  A("fr") = 33
  A("uk") = 44

  NewMap B() ; one element missing
  B("de") = 49
  B("uk") = 44 

  Debug CompareMap(A(), B()) ; Not equal

See Also

CompareArray(), CompareList()

Supported OS

All

<- ClearMap() - Map Index - CopyMap() ->