Skip to content

Commit 9fb7efd

Browse files
committed
Add notes to Dictionary, HashMap and Array.
Add a link to Godot's container types to relevant FAQ entry.
1 parent 5ebc3a7 commit 9fb7efd

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-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: 5 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``. |
@@ -99,7 +102,7 @@ scripting API.
99102
| | | This means it's generally slower but can be copied around almost for free. |
100103
| | | The performance benefits of ``VSet`` aren't established, so prefer using other types. |
101104
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
102-
| ``HashMap`` | ``std::unordered_map`` | **Use this as the "default" map type.** Does not preserve insertion order. |
105+
| ``HashMap`` | ``std::unordered_map`` | **Use this as the "default" map type.** Preserves insertion order. |
103106
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
104107
| ``AHashMap`` | ``std::unordered_map`` | Array-based implementation of a hash map. Does not preserve insertion order. |
105108
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
@@ -114,6 +117,7 @@ scripting API.
114117
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
115118
| ``Dictionary`` 📜 | ``std::unordered_map`` | Keys and values can be of any Variant type. No static typing is imposed. |
116119
| | | Uses shared reference counting, similar to ``std::shared_ptr``. |
120+
| | | Preserves insertion order. Uses ``HashMap<Variant>`` internally. |
117121
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
118122
| ``TypedDictionary`` 📜 | ``std::unordered_map`` | Subclass of ``Dictionary`` but with static typing for its keys and values. |
119123
+------------------------+--------------------------+---------------------------------------------------------------------------------------+

0 commit comments

Comments
 (0)