mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 00:13:30 +00:00
[Core] Add iteration support to Array
This commit is contained in:
parent
1f0f81049f
commit
64146cb7f3
15 changed files with 251 additions and 73 deletions
|
@ -81,6 +81,22 @@ void Array::_unref() const {
|
|||
_p = nullptr;
|
||||
}
|
||||
|
||||
Array::Iterator Array::begin() {
|
||||
return Iterator(_p->array.ptrw(), _p->read_only);
|
||||
}
|
||||
|
||||
Array::Iterator Array::end() {
|
||||
return Iterator(_p->array.ptrw() + _p->array.size(), _p->read_only);
|
||||
}
|
||||
|
||||
Array::ConstIterator Array::begin() const {
|
||||
return ConstIterator(_p->array.ptr(), _p->read_only);
|
||||
}
|
||||
|
||||
Array::ConstIterator Array::end() const {
|
||||
return ConstIterator(_p->array.ptr() + _p->array.size(), _p->read_only);
|
||||
}
|
||||
|
||||
Variant &Array::operator[](int p_idx) {
|
||||
if (unlikely(_p->read_only)) {
|
||||
*_p->read_only = _p->array[p_idx];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue