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

Method insert

core/variant/array.cpp:324–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322}
323
324Error Array::insert(int p_pos, const Variant &p_value) {
325 ERR_FAIL_COND_V_MSG(_p->read_only, ERR_LOCKED, "Array is in read-only state.");
326 Variant value = p_value;
327 ERR_FAIL_COND_V(!_p->typed.validate(value, "insert"), ERR_INVALID_PARAMETER);
328
329 if (p_pos < 0) {
330 // Relative offset from the end.
331 p_pos = _p->array.size() + p_pos;
332 }
333
334 ERR_FAIL_INDEX_V_MSG(p_pos, _p->array.size() + 1, ERR_INVALID_PARAMETER, vformat("The calculated index %d is out of bounds (the array has %d elements). Leaving the array untouched.", p_pos, _p->array.size()));
335
336 return _p->array.insert(p_pos, std::move(value));
337}
338
339void Array::fill(const Variant &p_value) {
340 ERR_FAIL_COND_MSG(_p->read_only, "Array is in read-only state.");

Callers 15

detect_mvkFunction · 0.45
detect_modulesFunction · 0.45
sort_module_listFunction · 0.45
generate_vs_projectFunction · 0.45
set_cell_itemMethod · 0.45
reload_assembliesMethod · 0.45
insert_script_bindingMethod · 0.45
get_membersMethod · 0.45

Calls 4

vformatFunction · 0.85
moveFunction · 0.85
sizeMethod · 0.65
validateMethod · 0.45

Tested by 10

set_objectsMethod · 0.36
test_array_namesMethod · 0.36
_move_elementMethod · 0.36
update_treeMethod · 0.36
expand_revertableMethod · 0.36
_edit_request_changeMethod · 0.36
_prepare_historyMethod · 0.36
register_test_commandFunction · 0.36
add_exposed_classesFunction · 0.36