diff options
Diffstat (limited to 'core/array.cpp')
-rw-r--r-- | core/array.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/core/array.cpp b/core/array.cpp index c6e90d71ec..514f5a5dad 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -98,6 +98,37 @@ bool Array::operator==(const Array &p_array) const { return _p == p_array._p; } +bool Array::operator!=(const Array &p_array) const { + return !operator==(p_array); +} + +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); +} + uint32_t Array::hash() const { uint32_t h = hash_djb2_one_32(0); |