diff options
| author | Marius Guggenmos | 2017-10-07 17:49:23 +0200 |
|---|---|---|
| committer | Marius Guggenmos | 2017-10-09 16:36:09 +0200 |
| commit | 2f173a67abebd14805d6f7c44db2e8b5c4b5cf83 (patch) | |
| tree | ba1b1b8181978719615df5f0e46e019462dce438 /core | |
| parent | bd10a002402de6e3a69a17af604784ea7f5b3330 (diff) | |
| download | godot-2f173a67abebd14805d6f7c44db2e8b5c4b5cf83.tar.gz godot-2f173a67abebd14805d6f7c44db2e8b5c4b5cf83.tar.zst godot-2f173a67abebd14805d6f7c44db2e8b5c4b5cf83.zip | |
Diffstat (limited to 'core')
| -rw-r--r-- | core/array.cpp | 11 | ||||
| -rw-r--r-- | core/array.h | 6 |
2 files changed, 10 insertions, 7 deletions
diff --git a/core/array.cpp b/core/array.cpp index 30184a002..171c11776 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) { diff --git a/core/array.h b/core/array.h index 8a647dd13..2c2910310 100644 --- a/core/array.h +++ b/core/array.h @@ -68,9 +68,9 @@ public: Variant front() const; Variant back() const; - void sort(); - void sort_custom(Object *p_obj, const StringName &p_function); - void invert(); + Array &sort(); + Array &sort_custom(Object *p_obj, const StringName &p_function); + Array &invert(); int find(const Variant &p_value, int p_from = 0) const; int rfind(const Variant &p_value, int p_from = -1) const; |
