summaryrefslogtreecommitdiff
path: root/core/array.cpp
diff options
context:
space:
mode:
authorMarius Guggenmos <MariusGuggenmos@gmail.com>2017-10-07 17:49:23 +0200
committerMarius Guggenmos <MariusGuggenmos@gmail.com>2017-10-09 16:36:09 +0200
commit2f173a67abebd14805d6f7c44db2e8b5c4b5cf83 (patch)
treeba1b1b8181978719615df5f0e46e019462dce438 /core/array.cpp
parentbd10a002402de6e3a69a17af604784ea7f5b3330 (diff)
Array::sort, sort_custom and invert now return reference to Array to allow chaining of operations
Diffstat (limited to 'core/array.cpp')
-rw-r--r--core/array.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/core/array.cpp b/core/array.cpp
index 30184a002e..171c11776c 100644
--- a/core/array.cpp
+++ b/core/array.cpp
@@ -233,9 +233,10 @@ struct _ArrayVariantSort {
}
};
-void Array::sort() {
+Array &Array::sort() {
_p->array.sort_custom<_ArrayVariantSort>();
+ return *this;
}
struct _ArrayVariantSortCustom {
@@ -253,19 +254,21 @@ struct _ArrayVariantSortCustom {
return res;
}
};
-void Array::sort_custom(Object *p_obj, const StringName &p_function) {
+Array &Array::sort_custom(Object *p_obj, const StringName &p_function) {
- ERR_FAIL_NULL(p_obj);
+ ERR_FAIL_NULL_V(p_obj, *this);
SortArray<Variant, _ArrayVariantSortCustom> avs;
avs.compare.obj = p_obj;
avs.compare.func = p_function;
avs.sort(_p->array.ptr(), _p->array.size());
+ return *this;
}
-void Array::invert() {
+Array &Array::invert() {
_p->array.invert();
+ return *this;
}
void Array::push_front(const Variant &p_value) {