summaryrefslogtreecommitdiff
path: root/core/list.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/list.h')
-rw-r--r--core/list.h70
1 files changed, 46 insertions, 24 deletions
diff --git a/core/list.h b/core/list.h
index fc943790de..86e4a45036 100644
--- a/core/list.h
+++ b/core/list.h
@@ -149,14 +149,17 @@ private:
first = p_I->next_ptr;
};
- if (last == p_I)
+ if (last == p_I) {
last = p_I->prev_ptr;
+ }
- if (p_I->prev_ptr)
+ if (p_I->prev_ptr) {
p_I->prev_ptr->next_ptr = p_I->next_ptr;
+ }
- if (p_I->next_ptr)
+ if (p_I->next_ptr) {
p_I->next_ptr->prev_ptr = p_I->prev_ptr;
+ }
memdelete_allocator<Element, A>(const_cast<Element *>(p_I));
size_cache--;
@@ -220,8 +223,9 @@ public:
_data->last = n;
- if (!_data->first)
+ if (!_data->first) {
_data->first = n;
+ }
_data->size_cache++;
@@ -229,8 +233,9 @@ public:
};
void pop_back() {
- if (_data && _data->last)
+ if (_data && _data->last) {
erase(_data->last);
+ }
}
/**
@@ -256,8 +261,9 @@ public:
_data->first = n;
- if (!_data->last)
+ if (!_data->last) {
_data->last = n;
+ }
_data->size_cache++;
@@ -265,8 +271,9 @@ public:
};
void pop_front() {
- if (_data && _data->first)
+ if (_data && _data->first) {
erase(_data->first);
+ }
}
Element *insert_after(Element *p_element, const T &p_value) {
@@ -328,8 +335,9 @@ public:
Element *find(const T_v &p_val) {
Element *it = front();
while (it) {
- if (it->value == p_val)
+ if (it->value == p_val) {
return it;
+ }
it = it->next();
};
@@ -396,15 +404,19 @@ public:
p_B->next_ptr = A_next;
p_B->prev_ptr = A_prev;
- if (p_A->prev_ptr)
+ if (p_A->prev_ptr) {
p_A->prev_ptr->next_ptr = p_A;
- if (p_A->next_ptr)
+ }
+ if (p_A->next_ptr) {
p_A->next_ptr->prev_ptr = p_A;
+ }
- if (p_B->prev_ptr)
+ if (p_B->prev_ptr) {
p_B->prev_ptr->next_ptr = p_B;
- if (p_B->next_ptr)
+ }
+ if (p_B->next_ptr) {
p_B->next_ptr->prev_ptr = p_B;
+ }
}
/**
* copy the list
@@ -446,18 +458,21 @@ public:
void move_to_back(Element *p_I) {
ERR_FAIL_COND(p_I->data != _data);
- if (!p_I->next_ptr)
+ if (!p_I->next_ptr) {
return;
+ }
if (_data->first == p_I) {
_data->first = p_I->next_ptr;
};
- if (_data->last == p_I)
+ if (_data->last == p_I) {
_data->last = p_I->prev_ptr;
+ }
- if (p_I->prev_ptr)
+ if (p_I->prev_ptr) {
p_I->prev_ptr->next_ptr = p_I->next_ptr;
+ }
p_I->next_ptr->prev_ptr = p_I->prev_ptr;
@@ -480,20 +495,23 @@ public:
void move_to_front(Element *p_I) {
ERR_FAIL_COND(p_I->data != _data);
- if (!p_I->prev_ptr)
+ if (!p_I->prev_ptr) {
return;
+ }
if (_data->first == p_I) {
_data->first = p_I->next_ptr;
};
- if (_data->last == p_I)
+ if (_data->last == p_I) {
_data->last = p_I->prev_ptr;
+ }
p_I->prev_ptr->next_ptr = p_I->next_ptr;
- if (p_I->next_ptr)
+ if (p_I->next_ptr) {
p_I->next_ptr->prev_ptr = p_I->prev_ptr;
+ }
_data->first->prev_ptr = p_I;
p_I->next_ptr = _data->first;
@@ -541,8 +559,9 @@ public:
template <class C>
void sort_custom_inplace() {
- if (size() < 2)
+ if (size() < 2) {
return;
+ }
Element *from = front();
Element *current = from;
@@ -563,15 +582,17 @@ public:
find = find->next_ptr;
}
- if (current->prev_ptr)
+ if (current->prev_ptr) {
current->prev_ptr->next_ptr = current;
- else
+ } else {
from = current;
+ }
- if (current->next_ptr)
+ if (current->next_ptr) {
current->next_ptr->prev_ptr = current;
- else
+ } else {
to = current;
+ }
} else {
current->prev_ptr = nullptr;
current->next_ptr = nullptr;
@@ -597,8 +618,9 @@ public:
//if you don't want to use auxiliary memory, use the in_place version
int s = size();
- if (s < 2)
+ if (s < 2) {
return;
+ }
Element **aux_buffer = memnew_arr(Element *, s);