Skip to content

Add a table listing STL datatypes and their Godot equivalents in C++ usage guidelines #10873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Apr 18, 2025

This is more comprehensive than the previous advice.

@Ivorforce Could you take a look at this? There are probably some inaccuracies in here, as I'm not fully up-to-date on which scenarios are most optimal for each datatype. I also don't know whether OAHashMap, AHashMap and HashMap all preserve insertion order or only some of them (the class comments don't make an explicit notice of this).

@Calinou Calinou added enhancement area:contributing Issues and PRs related to the Contributing/Development section of the documentation cherrypick:4.4 labels Apr 18, 2025
Copy link
Member

@Ivorforce Ivorforce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this a lot! I think a table like this could be really helpful to get people started with the codebase.

As I was reading this, I was thinking that perhaps it might be better to structure it by Godot datatype than STL datatype? That would allow us to add some more nuance.

Godot Datatype  |  Closest STL datatype  |  Comments
Vector   |   std::vector   |   Uses copy-on-write semantics. That means it's generally slower but can be copied around almost for free.

etc.

What do you think?

@Calinou Calinou force-pushed the cpp-usage-guidelines-stl-datatypes branch from 9637bd2 to af319b9 Compare April 22, 2025 13:48
@Calinou
Copy link
Member Author

Calinou commented Apr 22, 2025

As I was reading this, I was thinking that perhaps it might be better to structure it by Godot datatype than STL datatype? That would allow us to add some more nuance.

Done 🙂

Copy link
Member

@mhilbrunner mhilbrunner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the addition, the other feedback still applies :) Thanks for working on this!

…usage guidelines

This is more comprehensive than the previous advice.
@Calinou Calinou force-pushed the cpp-usage-guidelines-stl-datatypes branch from af319b9 to 7724b0d Compare April 26, 2025 16:42
Copy link
Member

@Ivorforce Ivorforce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great! I'm happy we finally have a reference point for this info ☺️

+------------------------+--------------------------+--------------------------------------------------------------------------------------+
| ``HashSet`` | ``std::unordered_set`` | **Use this as the "default" set type.** |
+------------------------+--------------------------+--------------------------------------------------------------------------------------+
| ``RBSet`` | ``std::unordered_set`` | Uses a `red-black tree <https://en.wikipedia.org/wiki/Red-black_tree>`__ |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| ``RBSet`` | ``std::unordered_set`` | Uses a `red-black tree <https://en.wikipedia.org/wiki/Red-black_tree>`__ |
| ``RBSet`` | ``std::set`` | Uses a `red-black tree <https://en.wikipedia.org/wiki/Red-black_tree>`__ |

This was correctly in that sense, also I think a description of RBMap is needed as well, might also want to describe VSet and VMap, which are equivalent to std::flat_set/map (which are in C++23, or in Boost)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:contributing Issues and PRs related to the Contributing/Development section of the documentation cherrypick:4.4 enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants