|
@@ -140,6 +140,34 @@ bool Dictionary::erase(const Variant &p_key) {
|
|
|
return _p->variant_map.erase(p_key);
|
|
|
}
|
|
|
|
|
|
+bool Dictionary::deep_equal(const Dictionary &p_dictionary, int p_recursion_count) const {
|
|
|
+ // Cheap checks
|
|
|
+ ERR_FAIL_COND_V_MSG(p_recursion_count > MAX_RECURSION, 0, "Max recursion reached");
|
|
|
+ if (_p == p_dictionary._p) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (_p->variant_map.size() != p_dictionary._p->variant_map.size()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Heavy O(n) check
|
|
|
+ OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element this_E = _p->variant_map.front();
|
|
|
+ OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element other_E = p_dictionary._p->variant_map.front();
|
|
|
+ p_recursion_count++;
|
|
|
+ while (this_E && other_E) {
|
|
|
+ if (
|
|
|
+ !this_E.key().deep_equal(other_E.key(), p_recursion_count) ||
|
|
|
+ !this_E.value().deep_equal(other_E.value(), p_recursion_count)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ this_E = this_E.next();
|
|
|
+ other_E = other_E.next();
|
|
|
+ }
|
|
|
+
|
|
|
+ return !this_E && !other_E;
|
|
|
+}
|
|
|
+
|
|
|
bool Dictionary::operator==(const Dictionary &p_dictionary) const {
|
|
|
return _p == p_dictionary._p;
|
|
|
}
|