mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 11:56:49 +01:00
Backported comparison operators to Array from godot4.
This commit is contained in:
parent
0f07cedf57
commit
7779439e28
@ -487,6 +487,33 @@ Variant Array::max() const {
|
||||
return maxval;
|
||||
}
|
||||
|
||||
bool Array::operator<(const Array &p_array) const {
|
||||
int a_len = size();
|
||||
int b_len = p_array.size();
|
||||
|
||||
int min_cmp = MIN(a_len, b_len);
|
||||
|
||||
for (int i = 0; i < min_cmp; i++) {
|
||||
if (operator[](i) < p_array[i]) {
|
||||
return true;
|
||||
} else if (p_array[i] < operator[](i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return a_len < b_len;
|
||||
}
|
||||
|
||||
bool Array::operator<=(const Array &p_array) const {
|
||||
return !operator>(p_array);
|
||||
}
|
||||
bool Array::operator>(const Array &p_array) const {
|
||||
return p_array < *this;
|
||||
}
|
||||
bool Array::operator>=(const Array &p_array) const {
|
||||
return !operator<(p_array);
|
||||
}
|
||||
|
||||
const void *Array::id() const {
|
||||
return _p;
|
||||
}
|
||||
|
@ -103,6 +103,11 @@ public:
|
||||
Variant min() const;
|
||||
Variant max() const;
|
||||
|
||||
bool operator<(const Array &p_array) const;
|
||||
bool operator<=(const Array &p_array) const;
|
||||
bool operator>(const Array &p_array) const;
|
||||
bool operator>=(const Array &p_array) const;
|
||||
|
||||
const void *id() const;
|
||||
|
||||
Array(const Array &p_from);
|
||||
|
Loading…
Reference in New Issue
Block a user