Add Dictionary::erase_checked(key) method

Same as erase, but it returns a boolean value indicating whether the pair was erased or not.
This method should be removed during the next compatibility breakage, and 'Dictionary::erase(key)' should be changed to return a boolean.

(cherry picked from commit 2f69e36cef)
This commit is contained in:
Ignacio Etcheverry 2018-07-18 23:07:31 +02:00 committed by Hein-Pieter van Braam
parent 31f8d3525d
commit e7110984f3
2 changed files with 6 additions and 0 deletions

View File

@ -114,6 +114,11 @@ void Dictionary::erase(const Variant &p_key) {
_p->variant_map.erase(p_key);
}
bool Dictionary::erase_checked(const Variant &p_key) {
return _p->variant_map.erase(p_key);
}
bool Dictionary::operator==(const Dictionary &p_dictionary) const {
return _p == p_dictionary._p;

View File

@ -64,6 +64,7 @@ public:
bool has_all(const Array &p_keys) const;
void erase(const Variant &p_key);
bool erase_checked(const Variant &p_key);
bool operator==(const Dictionary &p_dictionary) const;