Skip to content

Commit b05aa8a

Browse files
committed
Add new FixedVector type to the types table.
Add notes to `Dictionary`, `HashMap` and `Array`. Add a link to Godot's container types to relevant FAQ entry.
1 parent 5ebc3a7 commit b05aa8a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

about/faq.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,8 @@ general-purpose library, but we had special requirements for Godot.
579579
* We use our custom String type, as the one provided by STL is too basic and lacks proper
580580
internationalization support.
581581

582+
Check out :ref:`Godot's container types <doc_cpp_godot_types>` for alternatives.
583+
582584
Why does Godot not use exceptions?
583585
----------------------------------
584586

contributing/development/cpp_usage_guidelines.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ variables and ``nullptr`` is encouraged when possible. Still, try to keep your
4545
use of modern C++ features conservative. Their use needs to serve a real
4646
purpose, such as improving code readability or performance.
4747

48+
.. _doc_cpp_godot_types:
49+
4850
Standard Template Library
4951
~~~~~~~~~~~~~~~~~~~~~~~~~
5052

@@ -75,6 +77,7 @@ scripting API.
7577
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
7678
| ``Array`` 📜 | ``std::vector`` | Values can be of any Variant type. No static typing is imposed. |
7779
| | | Uses shared reference counting, similar to ``std::shared_ptr``. |
80+
| | | Uses Vector<Variant> internally. |
7881
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
7982
| ``TypedArray`` 📜 | ``std::vector`` | Subclass of ``Array`` but with static typing for its elements. |
8083
| | | Not to be confused with ``Packed*Array``, which is internally a ``Vector``. |
@@ -83,6 +86,8 @@ scripting API.
8386
| | | Only a limited list of packed array types are available |
8487
| | | (use ``TypedArray`` otherwise). |
8588
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
89+
| ``FixedVector`` | ``std::array`` | Vector with a fixed capacity (more similar to ``boost::container::static_vector``). |
90+
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
8691
| ``List`` | ``std::list`` | Linked list type. Generally slower than other array/vector types. Prefer using |
8792
| | | other types in new code, unless using ``List`` avoids the need for type conversions. |
8893
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
@@ -99,7 +104,7 @@ scripting API.
99104
| | | This means it's generally slower but can be copied around almost for free. |
100105
| | | The performance benefits of ``VSet`` aren't established, so prefer using other types. |
101106
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
102-
| ``HashMap`` | ``std::unordered_map`` | **Use this as the "default" map type.** Does not preserve insertion order. |
107+
| ``HashMap`` | ``std::unordered_map`` | **Use this as the "default" map type.** Preserves insertion order. |
103108
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
104109
| ``AHashMap`` | ``std::unordered_map`` | Array-based implementation of a hash map. Does not preserve insertion order. |
105110
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
@@ -114,6 +119,7 @@ scripting API.
114119
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
115120
| ``Dictionary`` 📜 | ``std::unordered_map`` | Keys and values can be of any Variant type. No static typing is imposed. |
116121
| | | Uses shared reference counting, similar to ``std::shared_ptr``. |
122+
| | | Preserves insertion order. Uses ``HashMap<Variant>`` internally. |
117123
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
118124
| ``TypedDictionary`` 📜 | ``std::unordered_map`` | Subclass of ``Dictionary`` but with static typing for its keys and values. |
119125
+------------------------+--------------------------+---------------------------------------------------------------------------------------+

0 commit comments

Comments
 (0)