summaryrefslogtreecommitdiff
path: root/core/vset.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/vset.h')
-rw-r--r--core/vset.h27
1 files changed, 12 insertions, 15 deletions
diff --git a/core/vset.h b/core/vset.h
index b96a115d21..034b8fe851 100644
--- a/core/vset.h
+++ b/core/vset.h
@@ -36,14 +36,13 @@
template <class T>
class VSet {
-
Vector<T> _data;
_FORCE_INLINE_ int _find(const T &p_val, bool &r_exact) const {
-
r_exact = false;
- if (_data.empty())
+ if (_data.empty()) {
return 0;
+ }
int low = 0;
int high = _data.size() - 1;
@@ -51,8 +50,9 @@ class VSet {
int middle = 0;
#ifdef DEBUG_ENABLED
- if (low > high)
+ if (low > high) {
ERR_PRINT("low > high, this may be a bug");
+ }
#endif
while (low <= high) {
@@ -69,15 +69,16 @@ class VSet {
}
//return the position where this would be inserted
- if (a[middle] < p_val)
+ if (a[middle] < p_val) {
middle++;
+ }
return middle;
}
_FORCE_INLINE_ int _find_exact(const T &p_val) const {
-
- if (_data.empty())
+ if (_data.empty()) {
return -1;
+ }
int low = 0;
int high = _data.size() - 1;
@@ -101,29 +102,27 @@ class VSet {
public:
void insert(const T &p_val) {
-
bool exact;
int pos = _find(p_val, exact);
- if (exact)
+ if (exact) {
return;
+ }
_data.insert(pos, p_val);
}
bool has(const T &p_val) const {
-
return _find_exact(p_val) != -1;
}
void erase(const T &p_val) {
-
int pos = _find_exact(p_val);
- if (pos < 0)
+ if (pos < 0) {
return;
+ }
_data.remove(pos);
}
int find(const T &p_val) const {
-
return _find_exact(p_val);
}
@@ -132,12 +131,10 @@ public:
_FORCE_INLINE_ int size() const { return _data.size(); }
inline T &operator[](int p_index) {
-
return _data.write[p_index];
}
inline const T &operator[](int p_index) const {
-
return _data[p_index];
}
};