MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / map

Method map

core/variant/array.cpp:632–649  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

630}
631
632Array Array::map(const Callable &p_callable) const {
633 Array new_arr;
634 new_arr.resize(size());
635
636 const Variant *argptrs[1];
637 Variant *write = new_arr._p->array.ptrw();
638 for (int i = 0; i < size(); i++) {
639 argptrs[0] = &get(i);
640
641 Callable::CallError ce;
642 p_callable.callp(argptrs, 1, write[i], ce);
643 if (ce.error != Callable::CallError::CALL_OK) {
644 ERR_FAIL_V_MSG(Array(), vformat("Error calling method from 'map': %s.", Variant::get_callable_error_text(p_callable, argptrs, 1, ce)));
645 }
646 }
647
648 return new_arr;
649}
650
651Variant Array::reduce(const Callable &p_callable, const Variant &p_accum) const {
652 int start = 0;

Callers 12

dumpBenchmarkFunction · 0.80
showFilePickerMethod · 0.80
containsLineageErrorsMethod · 0.80
constructorMethod · 0.80
indent_multilineFunction · 0.80
make_rst_objectFunction · 0.80
make_rst_classFunction · 0.80
publish.jsFile · 0.80

Calls 6

vformatFunction · 0.85
ArrayClass · 0.70
getFunction · 0.50
resizeMethod · 0.45
ptrwMethod · 0.45
callpMethod · 0.45

Tested by

no test coverage detected