1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Array::sort, sort_custom and invert now return reference to Array to allow chaining of operations

This commit is contained in:
Marius Guggenmos
2017-10-07 17:49:23 +02:00
parent bd10a00240
commit 2f173a67ab
3 changed files with 19 additions and 10 deletions

View File

@@ -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) {