Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
This commit is contained in:
@ -35,13 +35,11 @@
|
||||
#include "core/variant.h"
|
||||
|
||||
struct DictionaryPrivate {
|
||||
|
||||
SafeRefCount refcount;
|
||||
OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator> variant_map;
|
||||
};
|
||||
|
||||
void Dictionary::get_key_list(List<Variant> *p_keys) const {
|
||||
|
||||
if (_p->variant_map.empty())
|
||||
return;
|
||||
|
||||
@ -51,7 +49,6 @@ void Dictionary::get_key_list(List<Variant> *p_keys) const {
|
||||
}
|
||||
|
||||
Variant Dictionary::get_key_at_index(int p_index) const {
|
||||
|
||||
int index = 0;
|
||||
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
|
||||
if (index == p_index) {
|
||||
@ -64,7 +61,6 @@ Variant Dictionary::get_key_at_index(int p_index) const {
|
||||
}
|
||||
|
||||
Variant Dictionary::get_value_at_index(int p_index) const {
|
||||
|
||||
int index = 0;
|
||||
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
|
||||
if (index == p_index) {
|
||||
@ -77,16 +73,13 @@ Variant Dictionary::get_value_at_index(int p_index) const {
|
||||
}
|
||||
|
||||
Variant &Dictionary::operator[](const Variant &p_key) {
|
||||
|
||||
return _p->variant_map[p_key];
|
||||
}
|
||||
|
||||
const Variant &Dictionary::operator[](const Variant &p_key) const {
|
||||
|
||||
return _p->variant_map[p_key];
|
||||
}
|
||||
const Variant *Dictionary::getptr(const Variant &p_key) const {
|
||||
|
||||
OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::ConstElement E = ((const OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator> *)&_p->variant_map)->find(p_key);
|
||||
|
||||
if (!E)
|
||||
@ -95,7 +88,6 @@ const Variant *Dictionary::getptr(const Variant &p_key) const {
|
||||
}
|
||||
|
||||
Variant *Dictionary::getptr(const Variant &p_key) {
|
||||
|
||||
OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.find(p_key);
|
||||
|
||||
if (!E)
|
||||
@ -104,7 +96,6 @@ Variant *Dictionary::getptr(const Variant &p_key) {
|
||||
}
|
||||
|
||||
Variant Dictionary::get_valid(const Variant &p_key) const {
|
||||
|
||||
OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::ConstElement E = ((const OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator> *)&_p->variant_map)->find(p_key);
|
||||
|
||||
if (!E)
|
||||
@ -122,16 +113,13 @@ Variant Dictionary::get(const Variant &p_key, const Variant &p_default) const {
|
||||
}
|
||||
|
||||
int Dictionary::size() const {
|
||||
|
||||
return _p->variant_map.size();
|
||||
}
|
||||
bool Dictionary::empty() const {
|
||||
|
||||
return !_p->variant_map.size();
|
||||
}
|
||||
|
||||
bool Dictionary::has(const Variant &p_key) const {
|
||||
|
||||
return _p->variant_map.has(p_key);
|
||||
}
|
||||
|
||||
@ -145,22 +133,18 @@ bool Dictionary::has_all(const Array &p_keys) const {
|
||||
}
|
||||
|
||||
bool Dictionary::erase(const Variant &p_key) {
|
||||
|
||||
return _p->variant_map.erase(p_key);
|
||||
}
|
||||
|
||||
bool Dictionary::operator==(const Dictionary &p_dictionary) const {
|
||||
|
||||
return _p == p_dictionary._p;
|
||||
}
|
||||
|
||||
bool Dictionary::operator!=(const Dictionary &p_dictionary) const {
|
||||
|
||||
return _p != p_dictionary._p;
|
||||
}
|
||||
|
||||
void Dictionary::_ref(const Dictionary &p_from) const {
|
||||
|
||||
//make a copy first (thread safe)
|
||||
if (!p_from._p->refcount.ref())
|
||||
return; // couldn't copy
|
||||
@ -176,12 +160,10 @@ void Dictionary::_ref(const Dictionary &p_from) const {
|
||||
}
|
||||
|
||||
void Dictionary::clear() {
|
||||
|
||||
_p->variant_map.clear();
|
||||
}
|
||||
|
||||
void Dictionary::_unref() const {
|
||||
|
||||
ERR_FAIL_COND(!_p);
|
||||
if (_p->refcount.unref()) {
|
||||
memdelete(_p);
|
||||
@ -189,7 +171,6 @@ void Dictionary::_unref() const {
|
||||
_p = NULL;
|
||||
}
|
||||
uint32_t Dictionary::hash() const {
|
||||
|
||||
uint32_t h = hash_djb2_one_32(Variant::DICTIONARY);
|
||||
|
||||
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
|
||||
@ -201,7 +182,6 @@ uint32_t Dictionary::hash() const {
|
||||
}
|
||||
|
||||
Array Dictionary::keys() const {
|
||||
|
||||
Array varr;
|
||||
if (_p->variant_map.empty())
|
||||
return varr;
|
||||
@ -218,7 +198,6 @@ Array Dictionary::keys() const {
|
||||
}
|
||||
|
||||
Array Dictionary::values() const {
|
||||
|
||||
Array varr;
|
||||
if (_p->variant_map.empty())
|
||||
return varr;
|
||||
@ -235,7 +214,6 @@ Array Dictionary::values() const {
|
||||
}
|
||||
|
||||
const Variant *Dictionary::next(const Variant *p_key) const {
|
||||
|
||||
if (p_key == NULL) {
|
||||
// caller wants to get the first element
|
||||
if (_p->variant_map.front())
|
||||
@ -250,7 +228,6 @@ const Variant *Dictionary::next(const Variant *p_key) const {
|
||||
}
|
||||
|
||||
Dictionary Dictionary::duplicate(bool p_deep) const {
|
||||
|
||||
Dictionary n;
|
||||
|
||||
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
|
||||
@ -261,7 +238,6 @@ Dictionary Dictionary::duplicate(bool p_deep) const {
|
||||
}
|
||||
|
||||
void Dictionary::operator=(const Dictionary &p_dictionary) {
|
||||
|
||||
_ref(p_dictionary);
|
||||
}
|
||||
|
||||
@ -275,11 +251,9 @@ Dictionary::Dictionary(const Dictionary &p_from) {
|
||||
}
|
||||
|
||||
Dictionary::Dictionary() {
|
||||
|
||||
_p = memnew(DictionaryPrivate);
|
||||
_p->refcount.init();
|
||||
}
|
||||
Dictionary::~Dictionary() {
|
||||
|
||||
_unref();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user