Commit graph

28 commits

Author SHA1 Message Date
mashumafi
9c2bfeb2fb Const Ref Callable for custom sort/search 2022-03-27 22:10:36 -04:00
Rémi Verschelde
668d6a1c5c
Merge pull request #56337 from cdemirer/fix-array-dictionary-id 2022-01-23 00:46:53 +01:00
Rémi Verschelde
c6cefb1b79
Array: Relax slice bound checks to properly handle negative indices
The same is done for `Vector` (and thus `Packed*Array`).

`begin` and `end` can now take any value and will be clamped to
`[-size(), size()]`. Negative values are a shorthand for indexing the array
from the last element upward.

`end` is given a default `INT_MAX` value (which will be clamped to `size()`)
so that the `end` parameter can be omitted to go from `begin` to the max size
of the array.

This makes `slice` works similarly to numpy's and JavaScript's.
2022-01-10 22:42:03 +01:00
Rémi Verschelde
fe52458154
Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-03 21:27:34 +01:00
cdemirer
e2ed9d13eb Fix Array and Dictionary id() and dictionary test bug 2021-12-30 13:14:09 +08:00
Nathan Franke
dd30253cdc
PackedByteArray, Array slice end exclusive, rename subarray to slice 2021-11-26 22:13:12 -06:00
Lightning_A
e078f970db Rename remove() to remove_at() when removing by index 2021-11-23 18:58:57 -07:00
Emmanuel Leblond
f9ba2efe1e
Modify Dictionary::operator== to do real key/value comparison with recursive support (and add unittests) 2021-10-30 13:11:01 +02:00
mashumafi
214bbfbefe Implement bsearch for Vector and Packed*Array 2021-09-30 23:57:26 +00:00
Max Hilbrunner
04c64b59a1
Merge pull request #47406 from mashumafi/master-Array-insert-rc
Array::insert consistent with Pool*Array::insert
2021-08-28 21:18:39 +02:00
Hugo Locurcio
60116b17b5
Add an Array.pop_at() method to pop an element at an arbitrary index
Negative indices are supported to pop an element relative from the end.
2021-08-27 00:51:17 +02:00
Marcel Admiraal
afdc5edb2a Remove alloca from loop and use a single fixed size array declaration 2021-05-21 13:04:55 +01:00
Tomasz Chabora
c50acc7339 Add filter, map and reduce to Array 2021-05-05 15:54:57 +02:00
Matheus Lima Cunha
efd27a63c1 Add fill method to Arrays and PackedArrays 2021-04-21 11:33:53 -03:00
Rémi Verschelde
4b6e9f3157
Merge pull request #46991 from madmiraal/rename-invert-reverse
Rename Array.invert() to Array.reverse()
2021-04-01 13:32:22 +02:00
mashumafi
c2d1c1c3ee Array::insert consistent with Pool*Array::insert 2021-03-27 17:27:19 -04:00
Marcel Admiraal
755c70b871 Rename Array.invert() to Array.reverse()
Does the same internally for List and Vector<>, which includes all
PackedArray types.
2021-03-21 10:20:08 +00:00
George Marques
fbfdd5e110
Add functions to retrieve type of a typed Array 2021-03-18 10:18:58 -03:00
George Marques
497dab94be
Don't check type when assigning Array
The array should just assimilate the type of the other one since
assignment in this case means a change in the reference.

This also adds a `typed_assign` function for the cases where type
validation is wanted.
2021-03-18 10:18:58 -03:00
Anshul7sp1
91181c2086 Fixes small typos and grammar correction 2021-03-12 19:05:16 +05:30
kobewi
fb83d905da Change sort_custom/bsearch_custom to use Callables 2021-02-04 14:37:52 +01:00
Rémi Verschelde
b5334d14f7
Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆
2021-01-01 20:19:21 +01:00
Marcel Admiraal
5b937d493f Rename empty() to is_empty() 2020-12-28 10:39:56 +00:00
Rafał Mikrut
7bd03b7188 Initialize class/struct variables with default values in core/ and drivers/ 2020-11-23 17:38:46 +01:00
Rémi Verschelde
03ae26bb74
Merge pull request #43398 from KoBeWi/add_an_array_to_another_array_but_with_a_method
Add append_array() method to Array class
2020-11-10 13:53:58 +01:00
reduz
221a2a1742 Refactored variant constructor logic 2020-11-09 08:54:43 -03:00
Tomasz Chabora
9f23a94b8a Add append_array() method to Array class 2020-11-08 21:09:45 +01:00
reduz
127458ed17 Reorganized core/ directory, it was too fatty already
-Removed FuncRef, since Callable makes it obsolete
-Removed int_types.h as its obsolete in c++11+
-Changed color names code
2020-11-07 20:17:12 -03:00
Renamed from core/array.cpp (Browse further)