summaryrefslogtreecommitdiff
path: root/core/vector.h
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-05-14 23:09:03 +0200
committerGitHub <noreply@github.com>2020-05-14 23:09:03 +0200
commit00949f0c5fcc6a4f8382a4a97d5591fd9ec380f8 (patch)
tree2b1c31f45add24085b64425ce440f577424c16a1 /core/vector.h
parent5046f666a1181675b39f156c38346525dc1c444e (diff)
parent0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 (diff)
Merge pull request #38738 from akien-mga/cause-we-never-go-out-of-style
Style: Remove new line at block start, enforce line between functions, enforce braces in if and loop blocks
Diffstat (limited to 'core/vector.h')
-rw-r--r--core/vector.h18
1 files changed, 8 insertions, 10 deletions
diff --git a/core/vector.h b/core/vector.h
index 7ab464fe11..696984ac28 100644
--- a/core/vector.h
+++ b/core/vector.h
@@ -70,8 +70,9 @@ public:
void remove(int p_index) { _cowdata.remove(p_index); }
void erase(const T &p_val) {
int idx = find(p_val);
- if (idx >= 0)
+ if (idx >= 0) {
remove(idx);
+ }
}
void invert();
@@ -93,10 +94,10 @@ public:
template <class C>
void sort_custom() {
-
int len = _cowdata.size();
- if (len == 0)
+ if (len == 0) {
return;
+ }
T *data = ptrw();
SortArray<T, C> sorter;
@@ -104,14 +105,12 @@ public:
}
void sort() {
-
sort_custom<_DefaultComparator<T>>();
}
void ordered_insert(const T &p_val) {
int i;
for (i = 0; i < _cowdata.size(); i++) {
-
if (p_val < operator[](i)) {
break;
};
@@ -132,7 +131,6 @@ public:
}
Vector<T> subarray(int p_from, int p_to) const {
-
if (p_from < 0) {
p_from = size() + p_from;
}
@@ -163,7 +161,6 @@ public:
template <class T>
void Vector<T>::invert() {
-
for (int i = 0; i < size() / 2; i++) {
T *p = ptrw();
SWAP(p[i], p[size() - i - 1]);
@@ -173,17 +170,18 @@ void Vector<T>::invert() {
template <class T>
void Vector<T>::append_array(Vector<T> p_other) {
const int ds = p_other.size();
- if (ds == 0)
+ if (ds == 0) {
return;
+ }
const int bs = size();
resize(bs + ds);
- for (int i = 0; i < ds; ++i)
+ for (int i = 0; i < ds; ++i) {
ptrw()[bs + i] = p_other[i];
+ }
}
template <class T>
bool Vector<T>::push_back(T p_elem) {
-
Error err = resize(size() + 1);
ERR_FAIL_COND_V(err, true);
set(size() - 1, p_elem);