The following example
compares H1 to H2 hash objects:
length eq k 8;
declare hash h1();
h1.defineKey('k');
h1.defineDone();
declare hash h2();
h2.defineKey('k');
h2.defineDone();
rc = h1.equals(hash: 'h2', result: eq);
if eq then
put 'hash objects equal';
else
put 'hash objects not equal';
The two hash objects
are defined as equal when all of the following conditions occur:
-
Both hash objects are the same
size—that is, the HASHEXP sizes are equal.
-
Both hash objects have the same
number of items—that is, H1.NUM_ITEMS = H2.NUM_ITEMS.
-
Both hash objects have the same
key and data structure.
-
In an unordered iteration over
H1 and H2 hash objects, each successive record from H1 has the same
key and data fields as the corresponding record in H2—that
is, each record is in the same position in each hash object and each
such record is identical to the corresponding record in the other
hash object.