type
TMap = specialize TFPGMap<TKey, TData>;
function ContentEquals(m,n : TMap): Boolean;
var
key: TKey;
data, data2: TData;
idx: integer;
begin
Result := False;
if m.count <> n.count then
Exit;
for idx := 0 to m.count-1 do
begin
key := m.keys[idx];
Result := n.TryGetData(key, data2);
if Result then
begin
data := m.data[idx];
Result := data2 = data;
end;
if not Result then
Exit;
end;
end;
begin
...
b := ContentEquals(m,n);
TKey and TData can be of any kind (except a class).
use Data::Compare;
$b = Compare( \%hash1, \%hash2 );
Comparison of hash keys is easy. Comparison of values is not, because perl hash values can be hashes or lists and nested arbitrarily. The best solution is to use CPAN Data::Compare unless the values are only strings or numbers.
Returns false if the key count differs; or if the keys don't match; or if the numeric values don't match. For string values, substitute operator eq for ==. Dies if a value is not a scalar (e.g. a hash or list).
type
TMap = specialize TFPGMap<TKey, TData>;
function ContentEquals(m,n : TMap): Boolean;
var
key: TKey;
data, data2: TData;
idx: integer;
begin
Result := False;
if m.count <> n.count then
Exit;
for idx := 0 to m.count-1 do
begin
key := m.keys[idx];
Result := n.TryGetData(key, data2);
if Result then
begin
data := m.data[idx];
Result := data2 = data;
end;
if not Result then
Exit;
end;
end;
begin
...
b := ContentEquals(m,n);