You've already forked godot
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user