summaryrefslogtreecommitdiffstats
path: root/core/array.cpp
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2020-11-04 23:01:55 -0300
committerreduz <reduzio@gmail.com>2020-11-06 12:45:50 -0300
commitf2397809a84c2bf0d41e6cb2092fa8f3c5a17850 (patch)
tree1eb1930e9124c5ecf77840e80ebed64cbb85608c /core/array.cpp
parent391d29f558d122798416b5957660d9eeceecd0f5 (diff)
downloadredot-engine-f2397809a84c2bf0d41e6cb2092fa8f3c5a17850.tar.gz
Refactored Variant Operators.
-Using classes to call and a table -For typed code (GDS or GDNative), can obtain functions to call prevalidated or ptr.
Diffstat (limited to 'core/array.cpp')
-rw-r--r--core/array.cpp31
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);