From 1b0aac602835af6b0ccce168eb854ba1dbca6fa7 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 15 Jan 2023 19:12:50 +0100 Subject: [PATCH] Renamed Map to RBMap. --- core/bind/core_bind.cpp | 4 +- core/config/engine.cpp | 2 +- core/config/engine.h | 2 +- core/config/project_settings.cpp | 24 +- core/config/project_settings.h | 12 +- core/containers/map.h | 677 ------------------ core/containers/packed_data_container.cpp | 4 +- core/containers/packed_data_container.h | 2 +- core/containers/rb_map.h | 203 ++---- core/input/input_map.cpp | 8 +- core/input/input_map.h | 4 +- core/io/file_access_memory.cpp | 8 +- core/io/file_access_network.h | 2 +- core/io/file_access_pack.cpp | 4 +- core/io/file_access_pack.h | 8 +- core/io/file_access_zip.h | 4 +- core/io/ip.cpp | 8 +- core/io/ip.h | 2 +- core/io/multiplayer_api.cpp | 16 +- core/io/multiplayer_api.h | 8 +- core/io/resource_format_binary.cpp | 6 +- core/io/resource_format_binary.h | 16 +- core/io/resource_importer.h | 6 +- core/io/resource_loader.cpp | 6 +- core/io/resource_loader.h | 4 +- core/math/color.cpp | 4 +- core/math/color_names.inc | 4 +- core/math/disjoint_set.h | 4 +- core/math/geometry.cpp | 2 +- core/math/octree_definition.inc | 6 +- core/math/quick_hull.cpp | 20 +- core/math/triangle_mesh.cpp | 6 +- core/object/message_queue.cpp | 12 +- core/object/object.cpp | 2 +- core/object/object.h | 2 +- core/object/resource.cpp | 8 +- core/object/resource.h | 4 +- core/object/script_debugger_local.cpp | 6 +- core/object/script_debugger_local.h | 2 +- core/object/script_language.cpp | 12 +- core/object/script_language.h | 14 +- core/string/compressed_translation.cpp | 8 +- core/string/translation.cpp | 8 +- core/string/translation.h | 4 +- core/variant/variant_call.cpp | 30 +- core/variant/variant_parser.h | 2 +- drivers/gles2/rasterizer_scene_gles2.cpp | 2 +- drivers/gles2/rasterizer_scene_gles2.h | 2 +- drivers/gles2/rasterizer_storage_gles2.cpp | 30 +- drivers/gles2/rasterizer_storage_gles2.h | 10 +- drivers/gles2/shader_compiler_gles2.cpp | 4 +- drivers/gles2/shader_compiler_gles2.h | 18 +- drivers/gles2/shader_gles2.cpp | 6 +- drivers/gles2/shader_gles2.h | 6 +- drivers/unix/ip_unix.cpp | 10 +- drivers/unix/ip_unix.h | 2 +- drivers/unix/net_socket_posix.cpp | 4 +- editor/animation_bezier_editor.cpp | 10 +- editor/animation_bezier_editor.h | 4 +- editor/animation_track_editor.cpp | 56 +- editor/animation_track_editor.h | 4 +- editor/audio_stream_preview.cpp | 2 +- editor/audio_stream_preview.h | 4 +- editor/connections_dialog.cpp | 6 +- editor/connections_dialog.h | 4 +- editor/create_dialog.cpp | 2 +- editor/dependency_editor.cpp | 18 +- editor/dependency_editor.h | 6 +- editor/doc/doc_data.cpp | 8 +- editor/doc/doc_data.h | 6 +- editor/editor_autoload_settings.cpp | 6 +- editor/editor_data.cpp | 8 +- editor/editor_data.h | 10 +- editor/editor_export.cpp | 6 +- editor/editor_export.h | 10 +- editor/editor_file_system.cpp | 16 +- editor/editor_file_system.h | 4 +- editor/editor_help.cpp | 16 +- editor/editor_help.h | 16 +- editor/editor_help_search.h | 10 +- editor/editor_inspector.cpp | 18 +- editor/editor_inspector.h | 10 +- editor/editor_network_profiler.cpp | 2 +- editor/editor_network_profiler.h | 4 +- editor/editor_node.cpp | 18 +- editor/editor_node.h | 16 +- editor/editor_profiler.cpp | 22 +- editor/editor_profiler.h | 6 +- editor/editor_property_name_processor.cpp | 2 +- editor/editor_property_name_processor.h | 4 +- editor/editor_resource_picker.cpp | 2 +- editor/editor_resource_preview.h | 4 +- editor/editor_run_native.cpp | 2 +- editor/editor_run_native.h | 4 +- editor/editor_sectioned_inspector.h | 4 +- editor/editor_settings.cpp | 8 +- editor/editor_settings.h | 4 +- editor/fileserver/editor_file_server.h | 2 +- editor/filesystem_dock.cpp | 26 +- editor/filesystem_dock.h | 16 +- editor/find_in_files.cpp | 10 +- editor/find_in_files.h | 6 +- editor/import/editor_import_plugin.cpp | 8 +- editor/import/editor_import_plugin.h | 4 +- editor/import/resource_importer_bitmask.cpp | 4 +- editor/import/resource_importer_bitmask.h | 4 +- .../resource_importer_csv_translation.cpp | 4 +- .../resource_importer_csv_translation.h | 4 +- editor/import/resource_importer_image.cpp | 4 +- editor/import/resource_importer_image.h | 4 +- .../resource_importer_layered_texture.cpp | 4 +- .../resource_importer_layered_texture.h | 4 +- editor/import/resource_importer_scene.cpp | 18 +- editor/import/resource_importer_scene.h | 10 +- editor/import/resource_importer_texture.cpp | 6 +- editor/import/resource_importer_texture.h | 6 +- .../resource_importer_texture_atlas.cpp | 12 +- .../import/resource_importer_texture_atlas.h | 6 +- editor/import/resource_importer_wav.cpp | 4 +- editor/import/resource_importer_wav.h | 4 +- editor/import_defaults_editor.cpp | 8 +- editor/import_dock.cpp | 4 +- editor/import_dock.h | 4 +- editor/inspector_dock.cpp | 4 +- .../animation_blend_tree_editor_plugin.cpp | 6 +- .../animation_blend_tree_editor_plugin.h | 4 +- editor/plugins/canvas_item_editor_plugin.cpp | 24 +- editor/plugins/canvas_item_editor_plugin.h | 6 +- editor/plugins/multimesh_editor_plugin.cpp | 6 +- editor/plugins/particles_editor_plugin.cpp | 6 +- editor/plugins/root_motion_editor_plugin.cpp | 4 +- editor/plugins/script_editor_plugin.cpp | 14 +- editor/plugins/script_text_editor.cpp | 4 +- editor/plugins/script_text_editor.h | 4 +- editor/plugins/shader_editor_plugin.cpp | 6 +- editor/plugins/spatial_editor_plugin.cpp | 28 +- editor/plugins/spatial_editor_plugin.h | 2 +- editor/plugins/text_editor.cpp | 4 +- editor/plugins/text_editor.h | 4 +- editor/plugins/texture_region_editor_plugin.h | 4 +- editor/plugins/theme_editor_plugin.cpp | 4 +- editor/plugins/theme_editor_plugin.h | 4 +- editor/progress_dialog.cpp | 2 +- editor/progress_dialog.h | 8 +- editor/project_settings_editor.cpp | 4 +- editor/property_editor.cpp | 2 +- editor/property_selector.cpp | 6 +- editor/scene_tree_dock.cpp | 52 +- editor/scene_tree_dock.h | 18 +- editor/script_create_dialog.cpp | 2 +- editor/script_create_dialog.h | 4 +- editor/script_editor_debugger.cpp | 14 +- editor/script_editor_debugger.h | 8 +- editor/settings_config_dialog.cpp | 8 +- editor/spatial_editor_gizmos.cpp | 8 +- editor_modules/gltf/gltf_document.cpp | 38 +- editor_modules/gltf/gltf_state.cpp | 2 +- editor_modules/gltf/gltf_state.h | 12 +- editor_modules/gltf/gltf_template_convert.h | 6 +- .../gltf/structures/gltf_animation.cpp | 2 +- .../gltf/structures/gltf_animation.h | 4 +- .../gltf/structures/gltf_skeleton.cpp | 2 +- .../gltf/structures/gltf_skeleton.h | 2 +- editor_modules/gltf/structures/gltf_skin.cpp | 8 +- editor_modules/gltf/structures/gltf_skin.h | 4 +- main/input_default.cpp | 18 +- main/input_default.h | 10 +- main/main.cpp | 2 +- main/tests/test_gdscript.cpp | 6 +- main/tests/test_math.cpp | 4 +- main/tests/test_physics.cpp | 6 +- main/tests/test_physics_2d.cpp | 2 +- main/tests/test_shader_lang.cpp | 10 +- modules/cscript/cscript.cpp | 90 +-- modules/cscript/cscript.h | 46 +- modules/cscript/cscript_compiler.cpp | 14 +- modules/cscript/cscript_compiler.h | 12 +- modules/cscript/cscript_editor.cpp | 70 +- modules/cscript/cscript_function.cpp | 8 +- modules/cscript/cscript_functions.cpp | 4 +- modules/cscript/cscript_parser.cpp | 22 +- modules/cscript/cscript_parser.h | 10 +- modules/cscript/cscript_tokenizer.cpp | 22 +- .../cscript/editor/cscript_highlighter.cpp | 6 +- modules/cscript/editor/cscript_highlighter.h | 2 +- modules/database/database_multi_threaded.cpp | 4 +- modules/database/database_multi_threaded.h | 4 +- modules/enet/networked_multiplayer_enet.cpp | 16 +- modules/enet/networked_multiplayer_enet.h | 2 +- modules/entity_spell_system/singletons/ess.h | 2 +- .../gdscript/editor/gdscript_highlighter.cpp | 6 +- .../gdscript/editor/gdscript_highlighter.h | 2 +- modules/gdscript/gdscript.cpp | 90 +-- modules/gdscript/gdscript.h | 46 +- modules/gdscript/gdscript_compiler.cpp | 14 +- modules/gdscript/gdscript_compiler.h | 12 +- modules/gdscript/gdscript_editor.cpp | 70 +- modules/gdscript/gdscript_function.cpp | 8 +- modules/gdscript/gdscript_functions.cpp | 4 +- modules/gdscript/gdscript_parser.cpp | 22 +- modules/gdscript/gdscript_parser.h | 10 +- modules/gdscript/gdscript_tokenizer.cpp | 22 +- modules/gridmap/grid_map.cpp | 56 +- modules/gridmap/grid_map.h | 6 +- modules/gridmap/mesh_library.cpp | 6 +- modules/gridmap/mesh_library.h | 4 +- .../gridmap/mesh_library_editor_plugin.cpp | 2 +- .../http_server_simple/http_server_simple.h | 2 +- .../plugin/mdr_import_plugin_base.cpp | 18 +- .../plugin/mdr_import_plugin_base.h | 18 +- .../plugin_gltf/editor_import_gltf_mdr.cpp | 2 +- .../plugin_gltf/editor_import_gltf_mdr.h | 2 +- modules/minimp3/resource_importer_mp3.cpp | 4 +- modules/minimp3/resource_importer_mp3.h | 4 +- modules/navigation/nav_map.cpp | 6 +- modules/navigation/nav_map.h | 2 +- .../tests/test_interpolator.h | 4 +- modules/props/singleton/prop_cache.h | 6 +- modules/props_2d/singleton/prop_2d_cache.h | 6 +- modules/regex/regex.cpp | 4 +- modules/regex/regex.h | 4 +- .../editor/skeleton_editor_plugin.cpp | 2 +- .../resource_importer_ogg_vorbis.cpp | 4 +- .../stb_vorbis/resource_importer_ogg_vorbis.h | 4 +- .../terraman/library/terrain_library_merger.h | 2 +- .../library/terrain_library_merger_pcm.h | 8 +- .../library/terrain_2d_library_merger.h | 2 +- .../library/terrain_2d_library_merger_pcm.h | 6 +- .../packer_image_resource_importer.cpp | 4 +- .../packer_image_resource_importer.h | 4 +- modules/tile_map/tile_map.cpp | 94 +-- modules/tile_map/tile_map.h | 14 +- modules/tile_map/tile_map_editor_plugin.cpp | 14 +- modules/tile_map/tile_map_editor_plugin.h | 4 +- modules/tile_map/tile_set.cpp | 44 +- modules/tile_map/tile_set.h | 22 +- modules/tile_map/tile_set_editor_plugin.cpp | 36 +- modules/tile_map/tile_set_editor_plugin.h | 6 +- modules/ui_extensions/input_map_editor.cpp | 2 +- .../voxelman/library/voxel_library_merger.h | 2 +- .../library/voxel_library_merger_pcm.h | 6 +- modules/web/file_cache.cpp | 2 +- modules/web/file_cache.h | 4 +- .../websocket/websocket_multiplayer_peer.cpp | 8 +- .../websocket/websocket_multiplayer_peer.h | 2 +- modules/websocket/wsl_client.cpp | 2 +- modules/websocket/wsl_server.cpp | 6 +- platform/android/api/java_class_wrapper.h | 6 +- platform/android/api/jni_singleton.h | 4 +- platform/android/export/export_plugin.cpp | 6 +- .../vending/licensing/APKExpansionPolicy.java | 6 +- .../licensing/ServerManagedPolicy.java | 6 +- .../vending/licensing/StrictPolicy.java | 6 +- .../licensing/util/URIQueryDecoder.java | 2 +- .../pandemonium/plugin/PandemoniumPlugin.java | 4 +- platform/android/java_class_wrapper.cpp | 2 +- platform/javascript/export/export.cpp | 12 +- platform/osx/export/export.cpp | 4 +- platform/osx/export/plist.cpp | 6 +- platform/osx/export/plist.h | 2 +- platform/osx/os_osx.h | 4 +- platform/osx/os_osx.mm | 2 +- platform/windows/export/export.cpp | 4 +- platform/windows/os_windows.cpp | 8 +- platform/windows/os_windows.h | 6 +- platform/x11/os_x11.cpp | 16 +- platform/x11/os_x11.h | 14 +- scene/2d/animated_sprite.cpp | 22 +- scene/2d/animated_sprite.h | 10 +- scene/2d/area_2d.cpp | 28 +- scene/2d/area_2d.h | 4 +- scene/2d/canvas_item.cpp | 2 +- scene/2d/canvas_item.h | 2 +- scene/2d/collision_object_2d.cpp | 8 +- scene/2d/collision_object_2d.h | 2 +- scene/2d/navigation_polygon.cpp | 4 +- scene/2d/physics_body_2d.cpp | 16 +- scene/2d/physics_body_2d.h | 2 +- scene/2d/visibility_notifier_2d.cpp | 6 +- scene/2d/visibility_notifier_2d.h | 2 +- scene/3d/area.cpp | 28 +- scene/3d/area.h | 4 +- scene/3d/collision_object.cpp | 16 +- scene/3d/collision_object.h | 2 +- scene/3d/mesh_instance.cpp | 6 +- scene/3d/mesh_instance.h | 2 +- scene/3d/physics_body.cpp | 16 +- scene/3d/physics_body.h | 2 +- scene/3d/proximity_group.cpp | 6 +- scene/3d/proximity_group.h | 2 +- scene/3d/visibility_notifier.cpp | 6 +- scene/3d/visibility_notifier.h | 2 +- scene/animation/animation_blend_tree.cpp | 18 +- scene/animation/animation_blend_tree.h | 2 +- .../animation_node_state_machine.cpp | 10 +- .../animation/animation_node_state_machine.h | 2 +- scene/animation/animation_player.cpp | 22 +- scene/animation/animation_player.h | 10 +- scene/debugger/script_debugger_remote.cpp | 14 +- scene/debugger/script_debugger_remote.h | 2 +- scene/gui/box_container.cpp | 2 +- scene/gui/flow_container.cpp | 2 +- scene/gui/graph_node.cpp | 4 +- scene/gui/graph_node.h | 2 +- scene/gui/grid_container.cpp | 16 +- scene/gui/popup_menu.h | 2 +- scene/gui/text_edit.cpp | 28 +- scene/gui/text_edit.h | 16 +- scene/main/node.cpp | 36 +- scene/main/node.h | 22 +- scene/main/resource_preloader.cpp | 6 +- scene/main/resource_preloader.h | 2 +- scene/main/scene_tree.cpp | 44 +- scene/main/scene_tree.h | 12 +- scene/main/viewport.cpp | 10 +- scene/main/viewport.h | 4 +- scene/resources/curve.cpp | 12 +- scene/resources/curve.h | 4 +- .../resources/default_theme/default_theme.cpp | 2 +- scene/resources/dynamic_font.h | 2 +- scene/resources/font.cpp | 10 +- scene/resources/font.h | 4 +- scene/resources/material.cpp | 2 +- scene/resources/material.h | 2 +- scene/resources/mesh.cpp | 8 +- scene/resources/mesh_data_tool.cpp | 2 +- scene/resources/navigation_mesh.cpp | 6 +- scene/resources/packed_scene.cpp | 26 +- scene/resources/packed_scene.h | 6 +- scene/resources/particles_material.cpp | 2 +- scene/resources/particles_material.h | 2 +- scene/resources/resource_format_text.cpp | 16 +- scene/resources/resource_format_text.h | 22 +- scene/resources/shader.cpp | 2 +- scene/resources/shader.h | 6 +- scene/resources/surface_tool.h | 2 +- scene/resources/world_2d.cpp | 44 +- scene/resources/world_3d.cpp | 26 +- servers/audio/effects/audio_effect_eq.cpp | 4 +- servers/audio/effects/audio_effect_eq.h | 2 +- servers/audio_server.h | 4 +- servers/physics/area_sw.cpp | 12 +- servers/physics/area_sw.h | 4 +- servers/physics/body_sw.cpp | 2 +- servers/physics/body_sw.h | 4 +- servers/physics/broad_phase_basic.cpp | 26 +- servers/physics/broad_phase_basic.h | 6 +- servers/physics/shape_sw.cpp | 8 +- servers/physics/shape_sw.h | 4 +- servers/physics/step_sw.cpp | 2 +- servers/physics_2d/area_2d_sw.cpp | 12 +- servers/physics_2d/area_2d_sw.h | 4 +- servers/physics_2d/body_2d_sw.cpp | 2 +- servers/physics_2d/body_2d_sw.h | 4 +- servers/physics_2d/broad_phase_2d_basic.cpp | 22 +- servers/physics_2d/broad_phase_2d_basic.h | 6 +- .../physics_2d/broad_phase_2d_hash_grid.cpp | 46 +- servers/physics_2d/broad_phase_2d_hash_grid.h | 14 +- servers/physics_2d/shape_2d_sw.cpp | 12 +- servers/physics_2d/shape_2d_sw.h | 4 +- servers/physics_2d/step_2d_sw.cpp | 2 +- servers/rendering/rendering_server_canvas.cpp | 2 +- .../rendering/rendering_server_viewport.cpp | 8 +- servers/rendering/rendering_server_viewport.h | 2 +- servers/rendering/shader_language.cpp | 58 +- servers/rendering/shader_language.h | 32 +- servers/rendering/shader_types.cpp | 2 +- servers/rendering/shader_types.h | 6 +- thirdparty/enet/pandemonium.cpp | 6 +- 369 files changed, 1866 insertions(+), 2626 deletions(-) delete mode 100644 core/containers/map.h diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index dd311d8fc..b309544b3 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -1067,7 +1067,7 @@ void _OS::print_resources_by_type(const Vector &p_types) { print_line(vformat("Resources currently in use for the following types: %s", p_types)); - Map type_count; + RBMap type_count; List> resources; ResourceCache::get_cached_resources(&resources); @@ -1100,7 +1100,7 @@ void _OS::print_resources_by_type(const Vector &p_types) { } } - for (Map::Element *E = type_count.front(); E; E = E->next()) { + for (RBMap::Element *E = type_count.front(); E; E = E->next()) { print_line(vformat("%s count: %d", E->key(), E->get())); } } diff --git a/core/config/engine.cpp b/core/config/engine.cpp index 44ceba997..d82fa169c 100644 --- a/core/config/engine.cpp +++ b/core/config/engine.cpp @@ -234,7 +234,7 @@ void Engine::add_singleton(const Singleton &p_singleton) { } Object *Engine::get_singleton_object(const String &p_name) const { - const Map::Element *E = singleton_ptrs.find(p_name); + const RBMap::Element *E = singleton_ptrs.find(p_name); ERR_FAIL_COND_V_MSG(!E, nullptr, "Failed to retrieve non-existent singleton '" + p_name + "'."); return E->get(); }; diff --git a/core/config/engine.h b/core/config/engine.h index bd1e4d32f..7d6dd972f 100644 --- a/core/config/engine.h +++ b/core/config/engine.h @@ -137,7 +137,7 @@ private: bool _in_physics; List singletons; - Map singleton_ptrs; + RBMap singleton_ptrs; bool editor_hint; diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index bdf9ef96e..0da8ccec6 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -235,7 +235,7 @@ void ProjectSettings::_get_property_list(List *p_list) const { Set<_VCSort> vclist; - for (Map::Element *E = props.front(); E; E = E->next()) { + for (RBMap::Element *E = props.front(); E; E = E->next()) { const VariantContainer *v = &E->get(); if (v->hide_from_editor) { @@ -297,7 +297,7 @@ bool ProjectSettings::_load_resource_pack(const String &p_pack, bool p_replace_f void ProjectSettings::_convert_to_last_version(int p_from_version) { if (p_from_version <= 3) { // Converts the actions from array to dictionary (array of events to dictionary with deadzone + events) - for (Map::Element *E = props.front(); E; E = E->next()) { + for (RBMap::Element *E = props.front(); E; E = E->next()) { Variant value = E->get().variant; if (String(E->key()).begins_with("input/") && value.get_type() == Variant::ARRAY) { Array array = value; @@ -670,7 +670,7 @@ Error ProjectSettings::save() { return error; } -Error ProjectSettings::_save_settings_binary(const String &p_file, const Map> &props, const CustomMap &p_custom, const String &p_custom_features) { +Error ProjectSettings::_save_settings_binary(const String &p_file, const RBMap> &props, const CustomMap &p_custom, const String &p_custom_features) { Error err; FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err); ERR_FAIL_COND_V_MSG(err != OK, err, "Couldn't save project.binary at " + p_file + "."); @@ -680,7 +680,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map>::Element *E = props.front(); E; E = E->next()) { + for (RBMap>::Element *E = props.front(); E; E = E->next()) { for (List::Element *F = E->get().front(); F; F = F->next()) { count++; } @@ -714,7 +714,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Mapstore_32(count); //store how many properties are saved } - for (Map>::Element *E = props.front(); E; E = E->next()) { + for (RBMap>::Element *E = props.front(); E; E = E->next()) { for (List::Element *F = E->get().front(); F; F = F->next()) { String key = F->get(); if (E->key() != "") { @@ -755,7 +755,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map> &props, const CustomMap &p_custom, const String &p_custom_features) { +Error ProjectSettings::_save_settings_text(const String &p_file, const RBMap> &props, const CustomMap &p_custom, const String &p_custom_features) { Error err; FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err); @@ -776,7 +776,7 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Mapstore_string("\n"); - for (Map>::Element *E = props.front(); E; E = E->next()) { + for (RBMap>::Element *E = props.front(); E; E = E->next()) { if (E != props.front()) { file->store_string("\n"); } @@ -819,7 +819,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust Set<_VCSort> vclist; if (p_merge_with_current) { - for (Map::Element *G = props.front(); G; G = G->next()) { + for (RBMap::Element *G = props.front(); G; G = G->next()) { const VariantContainer *v = &G->get(); if (v->hide_from_editor) { @@ -843,9 +843,9 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust } } - for (const Map::Element *E = p_custom.front(); E; E = E->next()) { + for (const RBMap::Element *E = p_custom.front(); E; E = E->next()) { // Lookup global prop to store in the same order - Map::Element *global_prop = props.find(E->key()); + RBMap::Element *global_prop = props.find(E->key()); _VCSort vc; vc.name = E->key(); @@ -855,7 +855,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust vclist.insert(vc); } - Map> props; + RBMap> props; for (Set<_VCSort>::Element *E = vclist.front(); E; E = E->next()) { String category = E->get().name; @@ -962,7 +962,7 @@ void ProjectSettings::set_custom_property_info(const String &p_prop, const Prope custom_prop_info[p_prop].name = p_prop; } -const Map &ProjectSettings::get_custom_property_info() const { +const RBMap &ProjectSettings::get_custom_property_info() const { return custom_prop_info; } diff --git a/core/config/project_settings.h b/core/config/project_settings.h index 3142afc1b..94f4390b4 100644 --- a/core/config/project_settings.h +++ b/core/config/project_settings.h @@ -66,7 +66,7 @@ class ProjectSettings : public Object { int _dirty_this_frame = 2; public: - typedef Map CustomMap; + typedef RBMap CustomMap; static const String PROJECT_DATA_DIR_NAME_SUFFIX; enum { @@ -108,9 +108,9 @@ protected: int last_order; int last_builtin_order; uint64_t last_save_time = 0; - Map props; + RBMap props; String resource_path; - Map custom_prop_info; + RBMap custom_prop_info; bool using_datapack; List input_presets; @@ -128,8 +128,8 @@ protected: Error _load_settings_binary(const String &p_path); Error _load_settings_text_or_binary(const String &p_text_path, const String &p_bin_path); - Error _save_settings_text(const String &p_file, const Map> &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String()); - Error _save_settings_binary(const String &p_file, const Map> &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String()); + Error _save_settings_text(const String &p_file, const RBMap> &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String()); + Error _save_settings_binary(const String &p_file, const RBMap> &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String()); Error _save_custom_bnd(const String &p_file); @@ -177,7 +177,7 @@ public: Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Vector &p_custom_features = Vector(), bool p_merge_with_current = true); Error save(); void set_custom_property_info(const String &p_prop, const PropertyInfo &p_info); - const Map &get_custom_property_info() const; + const RBMap &get_custom_property_info() const; uint64_t get_last_saved_time() { return last_save_time; } Vector get_optimizer_presets() const; diff --git a/core/containers/map.h b/core/containers/map.h deleted file mode 100644 index 9c9031328..000000000 --- a/core/containers/map.h +++ /dev/null @@ -1,677 +0,0 @@ -#ifndef MAP_H -#define MAP_H -/*************************************************************************/ -/* map.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "core/error/error_macros.h" -#include "core/os/memory.h" - -// based on the very nice implementation of rb-trees by: -// https://web.archive.org/web/20120507164830/http://web.mit.edu/~emin/www/source_code/red_black_tree/index.html - -template , class A = DefaultAllocator> -class Map { - enum Color { - RED, - BLACK - }; - struct _Data; - -public: - class Element { - private: - friend class Map; - int color; - Element *right; - Element *left; - Element *parent; - Element *_next; - Element *_prev; - K _key; - V _value; - //_Data *data; - - public: - const Element *next() const { - return _next; - } - Element *next() { - return _next; - } - const Element *prev() const { - return _prev; - } - Element *prev() { - return _prev; - } - const K &key() const { - return _key; - }; - V &value() { - return _value; - }; - const V &value() const { - return _value; - }; - V &get() { - return _value; - }; - const V &get() const { - return _value; - }; - Element() { - color = RED; - right = nullptr; - left = nullptr; - parent = nullptr; - _next = nullptr; - _prev = nullptr; - }; - }; - -private: - struct _Data { - Element *_root; - Element *_nil; - int size_cache; - - _FORCE_INLINE_ _Data() { -#ifdef GLOBALNIL_DISABLED - _nil = memnew_allocator(Element, A); - _nil->parent = _nil->left = _nil->right = _nil; - _nil->color = BLACK; -#else - _nil = (Element *)&_GlobalNilClass::_nil; -#endif - _root = nullptr; - size_cache = 0; - } - - void _create_root() { - _root = memnew_allocator(Element, A); - _root->parent = _root->left = _root->right = _nil; - _root->color = BLACK; - } - - void _free_root() { - if (_root) { - memdelete_allocator(_root); - _root = nullptr; - } - } - - ~_Data() { - _free_root(); - -#ifdef GLOBALNIL_DISABLED - memdelete_allocator(_nil); -#endif - } - }; - - _Data _data; - - inline void _set_color(Element *p_node, int p_color) { - ERR_FAIL_COND(p_node == _data._nil && p_color == RED); - p_node->color = p_color; - } - - inline void _rotate_left(Element *p_node) { - Element *r = p_node->right; - p_node->right = r->left; - if (r->left != _data._nil) { - r->left->parent = p_node; - } - r->parent = p_node->parent; - if (p_node == p_node->parent->left) { - p_node->parent->left = r; - } else { - p_node->parent->right = r; - } - - r->left = p_node; - p_node->parent = r; - } - - inline void _rotate_right(Element *p_node) { - Element *l = p_node->left; - p_node->left = l->right; - if (l->right != _data._nil) { - l->right->parent = p_node; - } - l->parent = p_node->parent; - if (p_node == p_node->parent->right) { - p_node->parent->right = l; - } else { - p_node->parent->left = l; - } - - l->right = p_node; - p_node->parent = l; - } - - inline Element *_successor(Element *p_node) const { - Element *node = p_node; - - if (node->right != _data._nil) { - node = node->right; - while (node->left != _data._nil) { /* returns the minimum of the right subtree of node */ - node = node->left; - } - return node; - } else { - while (node == node->parent->right) { - node = node->parent; - } - - if (node->parent == _data._root) { - return nullptr; // No successor, as p_node = last node - } - return node->parent; - } - } - - inline Element *_predecessor(Element *p_node) const { - Element *node = p_node; - - if (node->left != _data._nil) { - node = node->left; - while (node->right != _data._nil) { /* returns the minimum of the left subtree of node */ - node = node->right; - } - return node; - } else { - while (node == node->parent->left) { - node = node->parent; - } - - if (node == _data._root) { - return nullptr; // No predecessor, as p_node = first node - } - return node->parent; - } - } - - Element *_find(const K &p_key) const { - Element *node = _data._root->left; - C less; - - while (node != _data._nil) { - if (less(p_key, node->_key)) { - node = node->left; - } else if (less(node->_key, p_key)) { - node = node->right; - } else { - return node; // found - } - } - - return nullptr; - } - - Element *_find_closest(const K &p_key) const { - Element *node = _data._root->left; - Element *prev = nullptr; - C less; - - while (node != _data._nil) { - prev = node; - - if (less(p_key, node->_key)) { - node = node->left; - } else if (less(node->_key, p_key)) { - node = node->right; - } else { - return node; // found - } - } - - if (prev == nullptr) { - return nullptr; // tree empty - } - - if (less(p_key, prev->_key)) { - prev = prev->_prev; - } - - return prev; - } - - void _insert_rb_fix(Element *p_new_node) { - Element *node = p_new_node; - Element *nparent = node->parent; - Element *ngrand_parent; - - while (nparent->color == RED) { - ngrand_parent = nparent->parent; - - if (nparent == ngrand_parent->left) { - if (ngrand_parent->right->color == RED) { - _set_color(nparent, BLACK); - _set_color(ngrand_parent->right, BLACK); - _set_color(ngrand_parent, RED); - node = ngrand_parent; - nparent = node->parent; - } else { - if (node == nparent->right) { - _rotate_left(nparent); - node = nparent; - nparent = node->parent; - } - _set_color(nparent, BLACK); - _set_color(ngrand_parent, RED); - _rotate_right(ngrand_parent); - } - } else { - if (ngrand_parent->left->color == RED) { - _set_color(nparent, BLACK); - _set_color(ngrand_parent->left, BLACK); - _set_color(ngrand_parent, RED); - node = ngrand_parent; - nparent = node->parent; - } else { - if (node == nparent->left) { - _rotate_right(nparent); - node = nparent; - nparent = node->parent; - } - _set_color(nparent, BLACK); - _set_color(ngrand_parent, RED); - _rotate_left(ngrand_parent); - } - } - } - - _set_color(_data._root->left, BLACK); - } - - Element *_insert(const K &p_key, const V &p_value) { - Element *new_parent = _data._root; - Element *node = _data._root->left; - C less; - - while (node != _data._nil) { - new_parent = node; - - if (less(p_key, node->_key)) { - node = node->left; - } else if (less(node->_key, p_key)) { - node = node->right; - } else { - node->_value = p_value; - return node; // Return existing node with new value - } - } - - Element *new_node = memnew_allocator(Element, A); - new_node->parent = new_parent; - new_node->right = _data._nil; - new_node->left = _data._nil; - new_node->_key = p_key; - new_node->_value = p_value; - //new_node->data=_data; - - if (new_parent == _data._root || less(p_key, new_parent->_key)) { - new_parent->left = new_node; - } else { - new_parent->right = new_node; - } - - new_node->_next = _successor(new_node); - new_node->_prev = _predecessor(new_node); - if (new_node->_next) { - new_node->_next->_prev = new_node; - } - if (new_node->_prev) { - new_node->_prev->_next = new_node; - } - - _data.size_cache++; - _insert_rb_fix(new_node); - return new_node; - } - - void _erase_fix_rb(Element *p_node) { - Element *root = _data._root->left; - Element *node = _data._nil; - Element *sibling = p_node; - Element *parent = sibling->parent; - - while (node != root) { // If red node found, will exit at a break - if (sibling->color == RED) { - _set_color(sibling, BLACK); - _set_color(parent, RED); - if (sibling == parent->right) { - sibling = sibling->left; - _rotate_left(parent); - } else { - sibling = sibling->right; - _rotate_right(parent); - } - } - if ((sibling->left->color == BLACK) && (sibling->right->color == BLACK)) { - _set_color(sibling, RED); - if (parent->color == RED) { - _set_color(parent, BLACK); - break; - } else { // loop: haven't found any red nodes yet - node = parent; - parent = node->parent; - sibling = (node == parent->left) ? parent->right : parent->left; - } - } else { - if (sibling == parent->right) { - if (sibling->right->color == BLACK) { - _set_color(sibling->left, BLACK); - _set_color(sibling, RED); - _rotate_right(sibling); - sibling = sibling->parent; - } - _set_color(sibling, parent->color); - _set_color(parent, BLACK); - _set_color(sibling->right, BLACK); - _rotate_left(parent); - break; - } else { - if (sibling->left->color == BLACK) { - _set_color(sibling->right, BLACK); - _set_color(sibling, RED); - _rotate_left(sibling); - sibling = sibling->parent; - } - - _set_color(sibling, parent->color); - _set_color(parent, BLACK); - _set_color(sibling->left, BLACK); - _rotate_right(parent); - break; - } - } - } - - ERR_FAIL_COND(_data._nil->color != BLACK); - } - - void _erase(Element *p_node) { - Element *rp = ((p_node->left == _data._nil) || (p_node->right == _data._nil)) ? p_node : p_node->_next; - Element *node = (rp->left == _data._nil) ? rp->right : rp->left; - - Element *sibling; - if (rp == rp->parent->left) { - rp->parent->left = node; - sibling = rp->parent->right; - } else { - rp->parent->right = node; - sibling = rp->parent->left; - } - - if (node->color == RED) { - node->parent = rp->parent; - _set_color(node, BLACK); - } else if (rp->color == BLACK && rp->parent != _data._root) { - _erase_fix_rb(sibling); - } - - if (rp != p_node) { - ERR_FAIL_COND(rp == _data._nil); - - rp->left = p_node->left; - rp->right = p_node->right; - rp->parent = p_node->parent; - rp->color = p_node->color; - if (p_node->left != _data._nil) { - p_node->left->parent = rp; - } - if (p_node->right != _data._nil) { - p_node->right->parent = rp; - } - - if (p_node == p_node->parent->left) { - p_node->parent->left = rp; - } else { - p_node->parent->right = rp; - } - } - - if (p_node->_next) { - p_node->_next->_prev = p_node->_prev; - } - if (p_node->_prev) { - p_node->_prev->_next = p_node->_next; - } - - memdelete_allocator(p_node); - _data.size_cache--; - ERR_FAIL_COND(_data._nil->color == RED); - } - - void _calculate_depth(Element *p_element, int &max_d, int d) const { - if (p_element == _data._nil) { - return; - } - - _calculate_depth(p_element->left, max_d, d + 1); - _calculate_depth(p_element->right, max_d, d + 1); - - if (d > max_d) { - max_d = d; - } - } - - void _cleanup_tree(Element *p_element) { - if (p_element == _data._nil) { - return; - } - - _cleanup_tree(p_element->left); - _cleanup_tree(p_element->right); - memdelete_allocator(p_element); - } - - void _copy_from(const Map &p_map) { - clear(); - // not the fastest way, but safeset to write. - for (Element *I = p_map.front(); I; I = I->next()) { - insert(I->key(), I->value()); - } - } - -public: - const Element *find(const K &p_key) const { - if (!_data._root) { - return nullptr; - } - - const Element *res = _find(p_key); - return res; - } - - Element *find(const K &p_key) { - if (!_data._root) { - return nullptr; - } - - Element *res = _find(p_key); - return res; - } - - const Element *find_closest(const K &p_key) const { - if (!_data._root) { - return NULL; - } - - const Element *res = _find_closest(p_key); - return res; - } - - Element *find_closest(const K &p_key) { - if (!_data._root) { - return nullptr; - } - - Element *res = _find_closest(p_key); - return res; - } - - bool has(const K &p_key) const { - return find(p_key) != nullptr; - } - - Element *insert(const K &p_key, const V &p_value) { - if (!_data._root) { - _data._create_root(); - } - return _insert(p_key, p_value); - } - - void erase(Element *p_element) { - if (!_data._root || !p_element) { - return; - } - - _erase(p_element); - if (_data.size_cache == 0 && _data._root) { - _data._free_root(); - } - } - - bool erase(const K &p_key) { - if (!_data._root) { - return false; - } - - Element *e = find(p_key); - if (!e) { - return false; - } - - _erase(e); - if (_data.size_cache == 0 && _data._root) { - _data._free_root(); - } - return true; - } - - const V &operator[](const K &p_key) const { - CRASH_COND(!_data._root); - const Element *e = find(p_key); - CRASH_COND(!e); - return e->_value; - } - - V &operator[](const K &p_key) { - if (!_data._root) { - _data._create_root(); - } - - Element *e = find(p_key); - if (!e) { - e = insert(p_key, V()); - } - - return e->_value; - } - - Element *front() const { - if (!_data._root) { - return nullptr; - } - - Element *e = _data._root->left; - if (e == _data._nil) { - return nullptr; - } - - while (e->left != _data._nil) { - e = e->left; - } - - return e; - } - - Element *back() const { - if (!_data._root) { - return nullptr; - } - - Element *e = _data._root->left; - if (e == _data._nil) { - return nullptr; - } - - while (e->right != _data._nil) { - e = e->right; - } - - return e; - } - - inline bool empty() const { return _data.size_cache == 0; } - inline int size() const { return _data.size_cache; } - - int calculate_depth() const { - // used for debug mostly - if (!_data._root) { - return 0; - } - - int max_d = 0; - _calculate_depth(_data._root->left, max_d, 0); - return max_d; - } - - void clear() { - if (!_data._root) { - return; - } - - _cleanup_tree(_data._root->left); - _data._root->left = _data._nil; - _data.size_cache = 0; - _data._free_root(); - } - - void operator=(const Map &p_map) { - _copy_from(p_map); - } - - Map(const Map &p_map) { - _copy_from(p_map); - } - - _FORCE_INLINE_ Map() { - } - - ~Map() { - clear(); - } -}; - -#endif diff --git a/core/containers/packed_data_container.cpp b/core/containers/packed_data_container.cpp index d6c6b40a5..5b07965e6 100644 --- a/core/containers/packed_data_container.cpp +++ b/core/containers/packed_data_container.cpp @@ -207,7 +207,7 @@ Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, b } } -uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector &tmpdata, Map &string_cache) { +uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector &tmpdata, RBMap &string_cache) { switch (p_data.get_type()) { case Variant::STRING: { String s = p_data; @@ -316,7 +316,7 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector &tmpd Error PackedDataContainer::pack(const Variant &p_data) { Vector tmpdata; - Map string_cache; + RBMap string_cache; _pack(p_data, tmpdata, string_cache); datalen = tmpdata.size(); data.resize(tmpdata.size()); diff --git a/core/containers/packed_data_container.h b/core/containers/packed_data_container.h index a187e4779..6f8f09725 100644 --- a/core/containers/packed_data_container.h +++ b/core/containers/packed_data_container.h @@ -49,7 +49,7 @@ class PackedDataContainer : public Resource { PoolVector data; int datalen; - uint32_t _pack(const Variant &p_data, Vector &tmpdata, Map &string_cache); + uint32_t _pack(const Variant &p_data, Vector &tmpdata, RBMap &string_cache); Variant _iter_init_ofs(const Array &p_iter, uint32_t p_offset); Variant _iter_next_ofs(const Array &p_iter, uint32_t p_offset); diff --git a/core/containers/rb_map.h b/core/containers/rb_map.h index a2c6c59b6..0a7621d71 100644 --- a/core/containers/rb_map.h +++ b/core/containers/rb_map.h @@ -1,5 +1,8 @@ +#ifndef RB_MAP_H +#define RB_MAP_H + /*************************************************************************/ -/* rb_map.h */ +/* map.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,15 +31,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef RB_MAP_H -#define RB_MAP_H - #include "core/error/error_macros.h" #include "core/os/memory.h" -#include "core/containers/pair.h" // based on the very nice implementation of rb-trees by: -// https://web.archive.org/web/20120507164830/https://web.mit.edu/~emin/www/source_code/red_black_tree/index.html +// https://web.archive.org/web/20120507164830/http://web.mit.edu/~emin/www/source_code/red_black_tree/index.html template , class A = DefaultAllocator> class RBMap { @@ -50,18 +49,17 @@ public: class Element { private: friend class RBMap; - int color = RED; - Element *right = nullptr; - Element *left = nullptr; - Element *parent = nullptr; - Element *_next = nullptr; - Element *_prev = nullptr; - KeyValue _data; + int color; + Element *right; + Element *left; + Element *parent; + Element *_next; + Element *_prev; + K _key; + V _value; + //_Data *data; public: - KeyValue &key_value() { return _data; } - const KeyValue &key_value() const { return _data; } - const Element *next() const { return _next; } @@ -75,115 +73,35 @@ public: return _prev; } const K &key() const { - return _data.key; - } + return _key; + }; V &value() { - return _data.value; - } + return _value; + }; const V &value() const { - return _data.value; - } + return _value; + }; V &get() { - return _data.value; - } + return _value; + }; const V &get() const { - return _data.value; - } - Element(const KeyValue &p_data) : - _data(p_data) {} + return _value; + }; + Element() { + color = RED; + right = nullptr; + left = nullptr; + parent = nullptr; + _next = nullptr; + _prev = nullptr; + }; }; - typedef KeyValue ValueType; - - struct Iterator { - _FORCE_INLINE_ KeyValue &operator*() const { - return E->key_value(); - } - _FORCE_INLINE_ KeyValue *operator->() const { return &E->key_value(); } - _FORCE_INLINE_ Iterator &operator++() { - E = E->next(); - return *this; - } - _FORCE_INLINE_ Iterator &operator--() { - E = E->prev(); - return *this; - } - - _FORCE_INLINE_ bool operator==(const Iterator &b) const { return E == b.E; } - _FORCE_INLINE_ bool operator!=(const Iterator &b) const { return E != b.E; } - explicit operator bool() const { - return E != nullptr; - } - Iterator(Element *p_E) { E = p_E; } - Iterator() {} - Iterator(const Iterator &p_it) { E = p_it.E; } - - private: - Element *E = nullptr; - }; - - struct ConstIterator { - _FORCE_INLINE_ const KeyValue &operator*() const { - return E->key_value(); - } - _FORCE_INLINE_ const KeyValue *operator->() const { return &E->key_value(); } - _FORCE_INLINE_ ConstIterator &operator++() { - E = E->next(); - return *this; - } - _FORCE_INLINE_ ConstIterator &operator--() { - E = E->prev(); - return *this; - } - - _FORCE_INLINE_ bool operator==(const ConstIterator &b) const { return E == b.E; } - _FORCE_INLINE_ bool operator!=(const ConstIterator &b) const { return E != b.E; } - explicit operator bool() const { - return E != nullptr; - } - ConstIterator(const Element *p_E) { E = p_E; } - ConstIterator() {} - ConstIterator(const ConstIterator &p_it) { E = p_it.E; } - - private: - const Element *E = nullptr; - }; - - _FORCE_INLINE_ Iterator begin() { - return Iterator(front()); - } - _FORCE_INLINE_ Iterator end() { - return Iterator(nullptr); - } - -#if 0 - //to use when replacing find() - _FORCE_INLINE_ Iterator find(const K &p_key) { - return Iterator(find(p_key)); - } -#endif - _FORCE_INLINE_ void remove(const Iterator &p_iter) { - return erase(p_iter.E); - } - - _FORCE_INLINE_ ConstIterator begin() const { - return ConstIterator(front()); - } - _FORCE_INLINE_ ConstIterator end() const { - return ConstIterator(nullptr); - } - -#if 0 - //to use when replacing find() - _FORCE_INLINE_ ConstIterator find(const K &p_key) const { - return ConstIterator(find(p_key)); - } -#endif private: struct _Data { - Element *_root = nullptr; - Element *_nil = nullptr; - int size_cache = 0; + Element *_root; + Element *_nil; + int size_cache; _FORCE_INLINE_ _Data() { #ifdef GLOBALNIL_DISABLED @@ -193,10 +111,12 @@ private: #else _nil = (Element *)&_GlobalNilClass::_nil; #endif + _root = nullptr; + size_cache = 0; } void _create_root() { - _root = memnew_allocator(Element(KeyValue(K(), V())), A); + _root = memnew_allocator(Element, A); _root->parent = _root->left = _root->right = _nil; _root->color = BLACK; } @@ -305,9 +225,9 @@ private: C less; while (node != _data._nil) { - if (less(p_key, node->_data.key)) { + if (less(p_key, node->_key)) { node = node->left; - } else if (less(node->_data.key, p_key)) { + } else if (less(node->_key, p_key)) { node = node->right; } else { return node; // found @@ -325,9 +245,9 @@ private: while (node != _data._nil) { prev = node; - if (less(p_key, node->_data.key)) { + if (less(p_key, node->_key)) { node = node->left; - } else if (less(node->_data.key, p_key)) { + } else if (less(node->_key, p_key)) { node = node->right; } else { return node; // found @@ -338,7 +258,7 @@ private: return nullptr; // tree empty } - if (less(p_key, prev->_data.key)) { + if (less(p_key, prev->_key)) { prev = prev->_prev; } @@ -348,7 +268,7 @@ private: void _insert_rb_fix(Element *p_new_node) { Element *node = p_new_node; Element *nparent = node->parent; - Element *ngrand_parent = nullptr; + Element *ngrand_parent; while (nparent->color == RED) { ngrand_parent = nparent->parent; @@ -401,25 +321,25 @@ private: while (node != _data._nil) { new_parent = node; - if (less(p_key, node->_data.key)) { + if (less(p_key, node->_key)) { node = node->left; - } else if (less(node->_data.key, p_key)) { + } else if (less(node->_key, p_key)) { node = node->right; } else { - node->_data.value = p_value; + node->_value = p_value; return node; // Return existing node with new value } } - typedef KeyValue KV; - Element *new_node = memnew_allocator(Element(KV(p_key, p_value)), A); + Element *new_node = memnew_allocator(Element, A); new_node->parent = new_parent; new_node->right = _data._nil; new_node->left = _data._nil; - + new_node->_key = p_key; + new_node->_value = p_value; //new_node->data=_data; - if (new_parent == _data._root || less(p_key, new_parent->_data.key)) { + if (new_parent == _data._root || less(p_key, new_parent->_key)) { new_parent->left = new_node; } else { new_parent->right = new_node; @@ -504,7 +424,7 @@ private: Element *rp = ((p_node->left == _data._nil) || (p_node->right == _data._nil)) ? p_node : p_node->_next; Element *node = (rp->left == _data._nil) ? rp->right : rp->left; - Element *sibling = nullptr; + Element *sibling; if (rp == rp->parent->left) { rp->parent->left = node; sibling = rp->parent->right; @@ -605,7 +525,7 @@ public: const Element *find_closest(const K &p_key) const { if (!_data._root) { - return nullptr; + return NULL; } const Element *res = _find_closest(p_key); @@ -664,7 +584,7 @@ public: CRASH_COND(!_data._root); const Element *e = find(p_key); CRASH_COND(!e); - return e->_data.value; + return e->_value; } V &operator[](const K &p_key) { @@ -677,7 +597,7 @@ public: e = insert(p_key, V()); } - return e->_data.value; + return e->_value; } Element *front() const { @@ -714,12 +634,8 @@ public: return e; } - inline bool is_empty() const { - return _data.size_cache == 0; - } - inline int size() const { - return _data.size_cache; - } + inline bool empty() const { return _data.size_cache == 0; } + inline int size() const { return _data.size_cache; } int calculate_depth() const { // used for debug mostly @@ -751,11 +667,12 @@ public: _copy_from(p_map); } - _FORCE_INLINE_ RBMap() {} + _FORCE_INLINE_ RBMap() { + } ~RBMap() { clear(); } }; -#endif // RB_MAP_H +#endif diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index ba736ccc7..1acee4fbe 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -118,7 +118,7 @@ List InputMap::get_actions() const { return actions; } - for (Map::Element *E = input_map.front(); E; E = E->next()) { + for (RBMap::Element *E = input_map.front(); E; E = E->next()) { actions.push_back(E->key()); } @@ -209,7 +209,7 @@ Array InputMap::_get_action_list(const StringName &p_action) { } const List> *InputMap::get_action_list(const StringName &p_action) { - const Map::Element *E = input_map.find(p_action); + const RBMap::Element *E = input_map.find(p_action); if (!E) { return nullptr; } @@ -222,7 +222,7 @@ bool InputMap::event_is_action(const Ref &p_event, const StringName } bool InputMap::event_get_action_status(const Ref &p_event, const StringName &p_action, bool p_exact_match, bool *p_pressed, float *p_strength, float *p_raw_strength) const { - Map::Element *E = input_map.find(p_action); + RBMap::Element *E = input_map.find(p_action); ERR_FAIL_COND_V_MSG(!E, false, suggest_actions(p_action)); Ref input_event_action = p_event; @@ -257,7 +257,7 @@ bool InputMap::event_get_action_status(const Ref &p_event, const Str } } -const Map &InputMap::get_action_map() const { +const RBMap &InputMap::get_action_map() const { return input_map; } diff --git a/core/input/input_map.h b/core/input/input_map.h index ce5b7408f..091e12e8f 100644 --- a/core/input/input_map.h +++ b/core/input/input_map.h @@ -51,7 +51,7 @@ public: private: static InputMap *singleton; - mutable Map input_map; + mutable RBMap input_map; List>::Element *_find_event(Action &p_action, const Ref &p_event, bool p_exact_match = false, bool *p_pressed = nullptr, float *p_strength = nullptr, float *p_raw_strength = nullptr) const; @@ -80,7 +80,7 @@ public: bool event_is_action(const Ref &p_event, const StringName &p_action, bool p_exact_match = false) const; bool event_get_action_status(const Ref &p_event, const StringName &p_action, bool p_exact_match = false, bool *p_pressed = nullptr, float *p_strength = nullptr, float *p_raw_strength = nullptr) const; - const Map &get_action_map() const; + const RBMap &get_action_map() const; void load_from_globals(); void load_default(); diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index 7a9fcaf07..446e0cf8d 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -30,15 +30,15 @@ #include "file_access_memory.h" -#include "core/containers/map.h" +#include "core/containers/rb_map.h" #include "core/os/dir_access.h" #include "core/config/project_settings.h" -static Map> *files = nullptr; +static RBMap> *files = nullptr; void FileAccessMemory::register_file(String p_name, Vector p_data) { if (!files) { - files = memnew((Map>)); + files = memnew((RBMap>)); } String name; @@ -84,7 +84,7 @@ Error FileAccessMemory::_open(const String &p_path, int p_mode_flags) { String name = fix_path(p_path); //name = DirAccess::normalize_path(name); - Map>::Element *E = files->find(name); + RBMap>::Element *E = files->find(name); ERR_FAIL_COND_V_MSG(!E, ERR_FILE_NOT_FOUND, "Can't find file '" + p_path + "'."); data = E->get().ptrw(); diff --git a/core/io/file_access_network.h b/core/io/file_access_network.h index 720dbf4ab..7b93e4a56 100644 --- a/core/io/file_access_network.h +++ b/core/io/file_access_network.h @@ -51,7 +51,7 @@ class FileAccessNetworkClient { bool quit; Mutex mutex; Mutex blockrequest_mutex; - Map accesses; + RBMap accesses; Ref client; int32_t last_id; diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index ea496b569..d65546de7 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -110,7 +110,7 @@ PackedData::PackedData() { } void PackedData::_free_packed_dirs(PackedDir *p_dir) { - for (Map::Element *E = p_dir->subdirs.front(); E; E = E->next()) { + for (RBMap::Element *E = p_dir->subdirs.front(); E; E = E->next()) { _free_packed_dirs(E->get()); } memdelete(p_dir); @@ -378,7 +378,7 @@ Error DirAccessPack::list_dir_begin() { list_dirs.clear(); list_files.clear(); - for (Map::Element *E = current->subdirs.front(); E; E = E->next()) { + for (RBMap::Element *E = current->subdirs.front(); E; E = E->next()) { list_dirs.push_back(E->key()); } diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 0625c8994..e9004605d 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -31,7 +31,7 @@ /*************************************************************************/ #include "core/containers/list.h" -#include "core/containers/map.h" +#include "core/containers/rb_map.h" #include "core/os/dir_access.h" #include "core/os/file_access.h" #include "core/string/print_string.h" @@ -63,7 +63,7 @@ private: struct PackedDir { PackedDir *parent; String name; - Map subdirs; + RBMap subdirs; Set files; }; @@ -97,7 +97,7 @@ private: }; }; - Map files; + RBMap files; Vector sources; @@ -185,7 +185,7 @@ public: FileAccess *PackedData::try_open_path(const String &p_path) { PathMD5 pmd5(p_path.md5_buffer()); - Map::Element *E = files.find(pmd5); + RBMap::Element *E = files.find(pmd5); if (!E) { return nullptr; //not found } diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h index de2883572..d188dd43a 100644 --- a/core/io/file_access_zip.h +++ b/core/io/file_access_zip.h @@ -33,7 +33,7 @@ #ifdef MINIZIP_ENABLED #include "core/io/file_access_pack.h" -#include "core/containers/map.h" +#include "core/containers/rb_map.h" #include "thirdparty/minizip/unzip.h" @@ -56,7 +56,7 @@ private: }; Vector packages; - Map files; + RBMap files; static ZipArchive *instance; diff --git a/core/io/ip.cpp b/core/io/ip.cpp index a52b64953..89ca06561 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -267,9 +267,9 @@ Array IP::_get_local_addresses() const { Array IP::_get_local_interfaces() const { Array results; - Map interfaces; + RBMap interfaces; get_local_interfaces(&interfaces); - for (Map::Element *E = interfaces.front(); E; E = E->next()) { + for (RBMap::Element *E = interfaces.front(); E; E = E->next()) { Interface_Info &c = E->get(); Dictionary rc; rc["name"] = c.name; @@ -289,9 +289,9 @@ Array IP::_get_local_interfaces() const { } void IP::get_local_addresses(List *r_addresses) const { - Map interfaces; + RBMap interfaces; get_local_interfaces(&interfaces); - for (Map::Element *E = interfaces.front(); E; E = E->next()) { + for (RBMap::Element *E = interfaces.front(); E; E = E->next()) { for (const List::Element *F = E->get().ip_addresses.front(); F; F = F->next()) { r_addresses->push_front(F->get()); } diff --git a/core/io/ip.h b/core/io/ip.h index 1445a1b74..dd8280ca9 100644 --- a/core/io/ip.h +++ b/core/io/ip.h @@ -93,7 +93,7 @@ public: virtual void _resolve_hostname(List &r_addresses, const String &p_hostname, Type p_type = TYPE_ANY) const = 0; Array get_resolve_item_addresses(ResolverID p_id) const; - virtual void get_local_interfaces(Map *r_interfaces) const = 0; + virtual void get_local_interfaces(RBMap *r_interfaces) const = 0; void erase_resolve_item(ResolverID p_id); void clear_cache(const String &p_hostname = ""); diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp index e9e5daf0a..eea5d8e76 100644 --- a/core/io/multiplayer_api.cpp +++ b/core/io/multiplayer_api.cpp @@ -246,10 +246,10 @@ Node *MultiplayerAPI::_process_get_node(int p_from, const uint8_t *p_packet, int // Use cached path. int id = target; - Map::Element *E = path_get_cache.find(p_from); + RBMap::Element *E = path_get_cache.find(p_from); ERR_FAIL_COND_V_MSG(!E, nullptr, "Invalid packet received. Requests invalid peer cache."); - Map::Element *F = E->get().nodes.find(id); + RBMap::Element *F = E->get().nodes.find(id); ERR_FAIL_COND_V_MSG(!F, nullptr, "Invalid packet received. Unabled to find requested cached node."); PathGetCache::NodeInfo *ni = &F->get(); @@ -267,7 +267,7 @@ void MultiplayerAPI::_process_rpc(Node *p_node, const StringName &p_name, int p_ // Check that remote can call the RPC on this node. RPCMode rpc_mode = RPC_MODE_DISABLED; - const Map::Element *E = p_node->get_node_rpc_mode(p_name); + const RBMap::Element *E = p_node->get_node_rpc_mode(p_name); if (E) { rpc_mode = E->get(); } @@ -357,7 +357,7 @@ void MultiplayerAPI::_process_confirm_path(int p_from, const uint8_t *p_packet, PathSentCache *psc = path_send_cache.getptr(path); ERR_FAIL_COND_MSG(!psc, "Invalid packet received. Tries to confirm a path which was not found in cache."); - Map::Element *E = psc->confirmed_peers.find(p_from); + RBMap::Element *E = psc->confirmed_peers.find(p_from); ERR_FAIL_COND_MSG(!E, "Invalid packet received. Source peer was not found in cache for the given path."); E->get() = true; } @@ -375,7 +375,7 @@ bool MultiplayerAPI::_send_confirm_path(NodePath p_path, PathSentCache *psc, int continue; // Continue, not for this peer. } - Map::Element *F = psc->confirmed_peers.find(E->get()); + RBMap::Element *F = psc->confirmed_peers.find(E->get()); if (!F || !F->get()) { // Path was not cached, or was cached but is unconfirmed. @@ -512,7 +512,7 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, const continue; // Continue, not for this peer. } - Map::Element *F = psc->confirmed_peers.find(E->get()); + RBMap::Element *F = psc->confirmed_peers.find(E->get()); ERR_CONTINUE(!F); // Should never happen. network_peer->set_target_peer(E->get()); // To this one specifically. @@ -576,7 +576,7 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const if (p_peer_id == 0 || p_peer_id == node_id || (p_peer_id < 0 && p_peer_id != -node_id)) { // Check that send mode can use local call. - const Map::Element *E = p_node->get_node_rpc_mode(p_method); + const RBMap::Element *E = p_node->get_node_rpc_mode(p_method); if (E) { call_local = _should_call_local(E->get(), is_master, skip_rpc); } @@ -708,7 +708,7 @@ void MultiplayerAPI::profiling_end() { int MultiplayerAPI::get_profiling_frame(ProfilingInfo *r_info) { int i = 0; #ifdef DEBUG_ENABLED - for (Map::Element *E = profiler_frame_data.front(); E; E = E->next()) { + for (RBMap::Element *E = profiler_frame_data.front(); E; E = E->next()) { r_info[i] = E->get(); ++i; } diff --git a/core/io/multiplayer_api.h b/core/io/multiplayer_api.h index 48b6b77da..e357a5819 100644 --- a/core/io/multiplayer_api.h +++ b/core/io/multiplayer_api.h @@ -49,7 +49,7 @@ public: private: //path sent caches struct PathSentCache { - Map confirmed_peers; + RBMap confirmed_peers; int id; }; @@ -60,7 +60,7 @@ private: ObjectID instance; }; - Map nodes; + RBMap nodes; }; #ifdef DEBUG_ENABLED @@ -73,7 +73,7 @@ private: Vector bandwidth_incoming_data; int bandwidth_outgoing_pointer; Vector bandwidth_outgoing_data; - Map profiler_frame_data; + RBMap profiler_frame_data; bool profiling; void _init_node_profile(ObjectID p_node); @@ -84,7 +84,7 @@ private: int rpc_sender_id; Set connected_peers; HashMap path_send_cache; - Map path_get_cache; + RBMap path_get_cache; int last_send_cache_id; Vector packet_cache; Node *root_node; diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 4d8706cb2..4310218ae 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1093,7 +1093,7 @@ void ResourceFormatLoaderBinary::get_dependencies(const String &p_path, Listget_dependencies(f, p_dependencies, p_add_types); } -Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, const Map &p_map) { +Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, const RBMap &p_map) { //Error error=OK; FileAccess *f = FileAccess::open(p_path, FileAccess::READ); @@ -1325,7 +1325,7 @@ void ResourceFormatSaverBinaryInstance::_write_variant(const Variant &p_property write_variant(f, p_property, resource_set, external_resources, string_map, p_hint); } -void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Variant &p_property, Set &resource_set, Map &external_resources, Map &string_map, const PropertyInfo &p_hint) { +void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Variant &p_property, Set &resource_set, RBMap &external_resources, RBMap &string_map, const PropertyInfo &p_hint) { switch (p_property.get_type()) { case Variant::NIL: { f->store_32(VARIANT_NIL); @@ -1986,7 +1986,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p Vector save_order; save_order.resize(external_resources.size()); - for (Map::Element *E = external_resources.front(); E; E = E->next()) { + for (RBMap::Element *E = external_resources.front(); E; E = E->next()) { save_order.write[E->get()] = E->key(); } diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index 6bc046892..524490a6f 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -49,7 +49,7 @@ class ResourceInteractiveLoaderBinary : public ResourceInteractiveLoader { Vector str_buf; List resource_cache; - //Map string_map; + //RBMap string_map; Vector string_map; StringName _get_string(); @@ -71,7 +71,7 @@ class ResourceInteractiveLoaderBinary : public ResourceInteractiveLoader { String get_unicode_string(); void _advance_padding(uint32_t p_len); - Map remaps; + RBMap remaps; Error error; int stage; @@ -88,7 +88,7 @@ public: virtual int get_stage_count() const; virtual void set_translation_remapped(bool p_remapped); - void set_remaps(const Map &p_remaps) { remaps = p_remaps; } + void set_remaps(const RBMap &p_remaps) { remaps = p_remaps; } void open(FileAccess *p_f); String recognize(FileAccess *p_f); void get_dependencies(FileAccess *p_f, List *p_dependencies, bool p_add_types); @@ -105,7 +105,7 @@ public: virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; virtual void get_dependencies(const String &p_path, List *p_dependencies, bool p_add_types = false); - virtual Error rename_dependencies(const String &p_path, const Map &p_map); + virtual Error rename_dependencies(const String &p_path, const RBMap &p_map); }; class ResourceFormatSaverBinaryInstance { @@ -127,11 +127,11 @@ class ResourceFormatSaverBinaryInstance { bool operator<(const NonPersistentKey &p_key) const { return base == p_key.base ? property < p_key.property : base < p_key.base; } }; - Map non_persistent_map; - Map string_map; + RBMap non_persistent_map; + RBMap string_map; Vector strings; - Map external_resources; + RBMap external_resources; List saved_resources; struct Property { @@ -153,7 +153,7 @@ class ResourceFormatSaverBinaryInstance { public: Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0); - static void write_variant(FileAccess *f, const Variant &p_property, Set &resource_set, Map &external_resources, Map &string_map, const PropertyInfo &p_hint = PropertyInfo()); + static void write_variant(FileAccess *f, const Variant &p_property, Set &resource_set, RBMap &external_resources, RBMap &string_map, const PropertyInfo &p_hint = PropertyInfo()); }; class ResourceFormatSaverBinary : public ResourceFormatSaver { diff --git a/core/io/resource_importer.h b/core/io/resource_importer.h index 6662b24bb..7cd6990be 100644 --- a/core/io/resource_importer.h +++ b/core/io/resource_importer.h @@ -126,12 +126,12 @@ public: virtual String get_preset_name(int p_idx) const { return String(); } virtual void get_import_options(List *r_options, int p_preset = 0) const = 0; - virtual bool get_option_visibility(const String &p_option, const Map &p_options) const = 0; + virtual bool get_option_visibility(const String &p_option, const RBMap &p_options) const = 0; virtual String get_option_group_file() const { return String(); } - virtual Error import(const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files = nullptr, Variant *r_metadata = nullptr) = 0; + virtual Error import(const String &p_source_file, const String &p_save_path, const RBMap &p_options, List *r_platform_variants, List *r_gen_files = nullptr, Variant *r_metadata = nullptr) = 0; - virtual Error import_group_file(const String &p_group_file, const Map> &p_source_file_options, const Map &p_base_paths) { return ERR_UNAVAILABLE; } + virtual Error import_group_file(const String &p_group_file, const RBMap> &p_source_file_options, const RBMap &p_base_paths) { return ERR_UNAVAILABLE; } virtual bool are_import_settings_valid(const String &p_path) const { return true; } virtual String get_import_settings_string() const { return String(); } }; diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index c625b2921..c0cc5775a 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -219,10 +219,10 @@ void ResourceFormatLoader::get_dependencies(const String &p_path, List * } } -Error ResourceFormatLoader::rename_dependencies(const String &p_path, const Map &p_map) { +Error ResourceFormatLoader::rename_dependencies(const String &p_path, const RBMap &p_map) { if (get_script_instance() && get_script_instance()->has_method("rename_dependencies")) { Dictionary deps_dict; - for (Map::Element *E = p_map.front(); E; E = E->next()) { + for (RBMap::Element *E = p_map.front(); E; E = E->next()) { deps_dict[E->key()] = E->value(); } @@ -668,7 +668,7 @@ void ResourceLoader::get_dependencies(const String &p_path, List *p_depe } } -Error ResourceLoader::rename_dependencies(const String &p_path, const Map &p_map) { +Error ResourceLoader::rename_dependencies(const String &p_path, const RBMap &p_map) { String path = _path_remap(p_path); String local_path; diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index 73d771306..af6540180 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -71,7 +71,7 @@ public: virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; virtual void get_dependencies(const String &p_path, List *p_dependencies, bool p_add_types = false); - virtual Error rename_dependencies(const String &p_path, const Map &p_map); + virtual Error rename_dependencies(const String &p_path, const RBMap &p_map); virtual bool is_import_valid(const String &p_path) const { return true; } virtual bool is_imported(const String &p_path) const { return false; } virtual int get_import_order(const String &p_path) const { return 0; } @@ -146,7 +146,7 @@ public: static void remove_resource_format_loader(Ref p_format_loader); static String get_resource_type(const String &p_path); static void get_dependencies(const String &p_path, List *p_dependencies, bool p_add_types = false); - static Error rename_dependencies(const String &p_path, const Map &p_map); + static Error rename_dependencies(const String &p_path, const RBMap &p_map); static bool is_import_valid(const String &p_path); static String get_import_group_file(const String &p_path); static bool is_imported(const String &p_path); diff --git a/core/math/color.cpp b/core/math/color.cpp index f83cd9064..97d599037 100644 --- a/core/math/color.cpp +++ b/core/math/color.cpp @@ -31,7 +31,7 @@ #include "color.h" #include "core/math/color_names.inc" -#include "core/containers/map.h" +#include "core/containers/rb_map.h" #include "core/math/math_funcs.h" #include "core/string/print_string.h" @@ -412,7 +412,7 @@ Color Color::named(const String &p_name) { name = name.replace(".", ""); name = name.to_lower(); - const Map::Element *color = _named_colors.find(name); + const RBMap::Element *color = _named_colors.find(name); ERR_FAIL_NULL_V_MSG(color, Color(), "Invalid color name: " + p_name + "."); return color->value(); } diff --git a/core/math/color_names.inc b/core/math/color_names.inc index 5e6e431a6..bee1ed5c8 100644 --- a/core/math/color_names.inc +++ b/core/math/color_names.inc @@ -1,7 +1,7 @@ // Names from https://en.wikipedia.org/wiki/X11_color_names -#include "core/containers/map.h" +#include "core/containers/rb_map.h" -static Map _named_colors; +static RBMap _named_colors; static void _populate_named_colors() { if (!_named_colors.empty()) { return; diff --git a/core/math/disjoint_set.h b/core/math/disjoint_set.h index f469ac938..a32a9d538 100644 --- a/core/math/disjoint_set.h +++ b/core/math/disjoint_set.h @@ -30,7 +30,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "core/containers/map.h" +#include "core/containers/rb_map.h" #include "core/containers/vector.h" /** @@ -46,7 +46,7 @@ class DisjointSet { int rank = 0; }; - typedef Map MapT; + typedef RBMap MapT; MapT elements; diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp index 4a92c6637..2d32088ed 100644 --- a/core/math/geometry.cpp +++ b/core/math/geometry.cpp @@ -157,7 +157,7 @@ void Geometry::MeshData::clear() { } void Geometry::MeshData::optimize_vertices() { - Map vtx_remap; + RBMap vtx_remap; for (int i = 0; i < faces.size(); i++) { for (int j = 0; j < faces[i].indices.size(); j++) { diff --git a/core/math/octree_definition.inc b/core/math/octree_definition.inc index 26faef7ce..9392a24ef 100644 --- a/core/math/octree_definition.inc +++ b/core/math/octree_definition.inc @@ -33,7 +33,7 @@ #include "core/containers/list.h" #include "core/containers/local_vector.h" -#include "core/containers/map.h" +#include "core/containers/rb_map.h" #include "core/math/aabb.h" #include "core/math/geometry.h" #include "core/math/vector3.h" @@ -258,8 +258,8 @@ private: typename List::Element *eA, *eB; }; - typedef Map, AL> ElementMap; - typedef Map, AL> PairMap; + typedef RBMap, AL> ElementMap; + typedef RBMap, AL> PairMap; ElementMap element_map; PairMap pair_map; diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp index 344bb83ef..4f9972082 100644 --- a/core/math/quick_hull.cpp +++ b/core/math/quick_hull.cpp @@ -30,7 +30,7 @@ #include "quick_hull.h" -#include "core/containers/map.h" +#include "core/containers/rb_map.h" uint32_t QuickHull::debug_stop_after = 0xFFFFFFFF; bool QuickHull::_flag_warnings = true; @@ -232,7 +232,7 @@ Error QuickHull::build(const Vector &p_points, Geometry::MeshData &r_me //find lit faces and lit edges List::Element *> lit_faces; //lit face is a death sentence - Map lit_edges; //create this on the flight, should not be that bad for performance and simplifies code a lot + RBMap lit_edges; //create this on the flight, should not be that bad for performance and simplifies code a lot for (List::Element *E = faces.front(); E; E = E->next()) { if (E->get().plane.distance_to(v) > 0) { @@ -243,7 +243,7 @@ Error QuickHull::build(const Vector &p_points, Geometry::MeshData &r_me uint32_t b = E->get().vertices[(i + 1) % 3]; Edge e(a, b); - Map::Element *F = lit_edges.find(e); + RBMap::Element *F = lit_edges.find(e); if (!F) { F = lit_edges.insert(e, FaceConnect()); } @@ -260,7 +260,7 @@ Error QuickHull::build(const Vector &p_points, Geometry::MeshData &r_me //create new faces from horizon edges List::Element *> new_faces; //new faces - for (Map::Element *E = lit_edges.front(); E; E = E->next()) { + for (RBMap::Element *E = lit_edges.front(); E; E = E->next()) { FaceConnect &fc = E->get(); if (fc.left && fc.right) { continue; //edge is uninteresting, not on horizont @@ -328,7 +328,7 @@ Error QuickHull::build(const Vector &p_points, Geometry::MeshData &r_me /* CREATE MESHDATA */ //make a map of edges again - Map ret_edges; + RBMap ret_edges; List ret_faces; for (List::Element *E = faces.front(); E; E = E->next()) { @@ -346,7 +346,7 @@ Error QuickHull::build(const Vector &p_points, Geometry::MeshData &r_me uint32_t b = E->get().vertices[(i + 1) % 3]; Edge e(a, b); - Map::Element *G = ret_edges.find(e); + RBMap::Element *G = ret_edges.find(e); if (!G) { G = ret_edges.insert(e, RetFaceConnect()); } @@ -374,7 +374,7 @@ Error QuickHull::build(const Vector &p_points, Geometry::MeshData &r_me int b = E->get().indices[(i + 1) % f.indices.size()]; Edge e(a, b); - Map::Element *F = ret_edges.find(e); + RBMap::Element *F = ret_edges.find(e); if (unlikely(!F)) { warning_f = true; @@ -411,7 +411,7 @@ Error QuickHull::build(const Vector &p_points, Geometry::MeshData &r_me } Edge e2(idx, idxn); - Map::Element *F2 = ret_edges.find(e2); + RBMap::Element *F2 = ret_edges.find(e2); if (unlikely(!F2)) { warning_not_f2 = true; @@ -431,7 +431,7 @@ Error QuickHull::build(const Vector &p_points, Geometry::MeshData &r_me } // remove all edge connections to this face - for (Map::Element *G = ret_edges.front(); G; G = G->next()) { + for (RBMap::Element *G = ret_edges.front(); G; G = G->next()) { if (G->get().left == O) { G->get().left = nullptr; } @@ -472,7 +472,7 @@ Error QuickHull::build(const Vector &p_points, Geometry::MeshData &r_me } r_mesh.edges.resize(ret_edges.size()); idx = 0; - for (Map::Element *E = ret_edges.front(); E; E = E->next()) { + for (RBMap::Element *E = ret_edges.front(); E; E = E->next()) { Geometry::MeshData::Edge e; e.a = E->key().vertices[0]; e.b = E->key().vertices[1]; diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp index 36726ad4f..75a4382c4 100644 --- a/core/math/triangle_mesh.cpp +++ b/core/math/triangle_mesh.cpp @@ -122,7 +122,7 @@ void TriangleMesh::create(const PoolVector &p_faces) { PoolVector::Read r = p_faces.read(); PoolVector::Write w = triangles.write(); - Map db; + RBMap db; for (int i = 0; i < fc; i++) { Triangle &f = w[i]; @@ -131,7 +131,7 @@ void TriangleMesh::create(const PoolVector &p_faces) { for (int j = 0; j < 3; j++) { int vidx = -1; Vector3 vs = v[j].snapped(Vector3(0.0001, 0.0001, 0.0001)); - Map::Element *E = db.find(vs); + RBMap::Element *E = db.find(vs); if (E) { vidx = E->get(); } else { @@ -157,7 +157,7 @@ void TriangleMesh::create(const PoolVector &p_faces) { vertices.resize(db.size()); PoolVector::Write vw = vertices.write(); - for (Map::Element *E = db.front(); E; E = E->next()) { + for (RBMap::Element *E = db.front(); E; E = E->next()) { vw[E->get()] = E->key(); } } diff --git a/core/object/message_queue.cpp b/core/object/message_queue.cpp index dd6b0032f..c573d7d0a 100644 --- a/core/object/message_queue.cpp +++ b/core/object/message_queue.cpp @@ -156,9 +156,9 @@ Error MessageQueue::push_set(Object *p_object, const StringName &p_prop, const V } void MessageQueue::statistics() { - Map set_count; - Map notify_count; - Map call_count; + RBMap set_count; + RBMap notify_count; + RBMap call_count; int null_count = 0; uint32_t read_pos = 0; @@ -211,15 +211,15 @@ void MessageQueue::statistics() { print_line("TOTAL BYTES: " + itos(buffer_end)); print_line("NULL count: " + itos(null_count)); - for (Map::Element *E = set_count.front(); E; E = E->next()) { + for (RBMap::Element *E = set_count.front(); E; E = E->next()) { print_line("SET " + E->key() + ": " + itos(E->get())); } - for (Map::Element *E = call_count.front(); E; E = E->next()) { + for (RBMap::Element *E = call_count.front(); E; E = E->next()) { print_line("CALL " + E->key() + ": " + itos(E->get())); } - for (Map::Element *E = notify_count.front(); E; E = E->next()) { + for (RBMap::Element *E = notify_count.front(); E; E = E->next()) { print_line("NOTIFY " + itos(E->key()) + ": " + itos(E->get())); } } diff --git a/core/object/object.cpp b/core/object/object.cpp index 23959eb97..3de749b70 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -1518,7 +1518,7 @@ bool Object::is_connected(const StringName &p_signal, Object *p_to_object, const Signal::Target target(p_to_object->get_instance_id(), p_to_method); return s->slot_map.has(target); - //const Map::Element *E = s->slot_map.find(target); + //const RBMap::Element *E = s->slot_map.find(target); //return (E!=NULL); } diff --git a/core/object/object.h b/core/object/object.h index 821c96c5a..63c18094b 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -32,7 +32,7 @@ #include "core/containers/hash_map.h" #include "core/containers/list.h" -#include "core/containers/map.h" +#include "core/containers/rb_map.h" #include "core/object/object_id.h" #include "core/os/rw_lock.h" #include "core/os/safe_refcount.h" diff --git a/core/object/resource.cpp b/core/object/resource.cpp index af4d7002f..8a620040b 100644 --- a/core/object/resource.cpp +++ b/core/object/resource.cpp @@ -142,7 +142,7 @@ void Resource::reload_from_file() { } } -Ref Resource::duplicate_for_local_scene(Node *p_for_scene, Map, Ref> &remap_cache) { +Ref Resource::duplicate_for_local_scene(Node *p_for_scene, RBMap, Ref> &remap_cache) { List plist; get_property_list(&plist); @@ -177,7 +177,7 @@ Ref Resource::duplicate_for_local_scene(Node *p_for_scene, Map, Ref> &remap_cache) { +void Resource::configure_for_local_scene(Node *p_for_scene, RBMap, Ref> &remap_cache) { List plist; get_property_list(&plist); @@ -473,7 +473,7 @@ void ResourceCache::dump(const char *p_file, bool p_short) { #ifdef DEBUG_ENABLED lock.read_lock(); - Map type_count; + RBMap type_count; FileAccess *f = nullptr; if (p_file) { @@ -498,7 +498,7 @@ void ResourceCache::dump(const char *p_file, bool p_short) { } } - for (Map::Element *E = type_count.front(); E; E = E->next()) { + for (RBMap::Element *E = type_count.front(); E; E = E->next()) { if (f) { f->store_line(E->key() + " count: " + itos(E->get())); } diff --git a/core/object/resource.h b/core/object/resource.h index 2098a70cb..65daee34f 100644 --- a/core/object/resource.h +++ b/core/object/resource.h @@ -100,8 +100,8 @@ public: int get_subindex() const; virtual Ref duplicate(bool p_subresources = false) const; - Ref duplicate_for_local_scene(Node *p_for_scene, Map, Ref> &remap_cache); - void configure_for_local_scene(Node *p_for_scene, Map, Ref> &remap_cache); + Ref duplicate_for_local_scene(Node *p_for_scene, RBMap, Ref> &remap_cache); + void configure_for_local_scene(Node *p_for_scene, RBMap, Ref> &remap_cache); void set_local_to_scene(bool p_enable); bool is_local_to_scene() const; diff --git a/core/object/script_debugger_local.cpp b/core/object/script_debugger_local.cpp index b76c85d52..d9b900a88 100644 --- a/core/object/script_debugger_local.cpp +++ b/core/object/script_debugger_local.cpp @@ -83,7 +83,7 @@ void ScriptDebuggerLocal::debug(ScriptLanguage *p_script, bool p_can_continue, b } else if (line.begins_with("set")) { if (line.get_slice_count(" ") == 1) { - for (Map::Element *E = options.front(); E; E = E->next()) { + for (RBMap::Element *E = options.front(); E; E = E->next()) { print_line("\t" + E->key() + "=" + E->value()); } @@ -159,14 +159,14 @@ void ScriptDebuggerLocal::debug(ScriptLanguage *p_script, bool p_can_continue, b } else if (line.begins_with("br") || line.begins_with("break")) { if (line.get_slice_count(" ") <= 1) { - const Map> &breakpoints = get_breakpoints(); + const RBMap> &breakpoints = get_breakpoints(); if (breakpoints.size() == 0) { print_line("No Breakpoints."); continue; } print_line("Breakpoint(s): " + itos(breakpoints.size())); - for (Map>::Element *E = breakpoints.front(); E; E = E->next()) { + for (RBMap>::Element *E = breakpoints.front(); E; E = E->next()) { print_line("\t" + String(E->value().front()->get()) + ":" + itos(E->key())); } diff --git a/core/object/script_debugger_local.h b/core/object/script_debugger_local.h index ab8667cee..cc5ff0e55 100644 --- a/core/object/script_debugger_local.h +++ b/core/object/script_debugger_local.h @@ -38,7 +38,7 @@ class ScriptDebuggerLocal : public ScriptDebugger { float frame_time, process_time, physics_time, physics_frame_time; uint64_t idle_accum; String target_function; - Map options; + RBMap options; Vector pinfo; diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index 6cadffe6e..13bf6b058 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -87,9 +87,9 @@ Array Script::_get_script_signal_list() { Dictionary Script::_get_script_constant_map() { Dictionary ret; - Map map; + RBMap map; get_constants(&map); - for (Map::Element *E = map.front(); E; E = E->next()) { + for (RBMap::Element *E = map.front(); E; E = E->next()) { ret[E->key()] = E->value(); } return ret; @@ -538,7 +538,7 @@ bool PlaceHolderScriptInstance::has_method(const StringName &p_method) const { return false; } -void PlaceHolderScriptInstance::update(const List &p_properties, const Map &p_values) { +void PlaceHolderScriptInstance::update(const List &p_properties, const RBMap &p_values) { Set new_values; for (const List::Element *E = p_properties.front(); E; E = E->next()) { StringName n = E->get().name; @@ -554,7 +554,7 @@ void PlaceHolderScriptInstance::update(const List &p_properties, c properties = p_properties; List to_remove; - for (Map::Element *E = values.front(); E; E = E->next()) { + for (RBMap::Element *E = values.front(); E; E = E->next()) { if (!new_values.has(E->key())) { to_remove.push_back(E->key()); } @@ -584,7 +584,7 @@ void PlaceHolderScriptInstance::update(const List &p_properties, c void PlaceHolderScriptInstance::property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid) { if (script->is_placeholder_fallback_enabled()) { - Map::Element *E = values.find(p_name); + RBMap::Element *E = values.find(p_name); if (E) { E->value() = p_value; @@ -611,7 +611,7 @@ void PlaceHolderScriptInstance::property_set_fallback(const StringName &p_name, Variant PlaceHolderScriptInstance::property_get_fallback(const StringName &p_name, bool *r_valid) { if (script->is_placeholder_fallback_enabled()) { - const Map::Element *E = values.find(p_name); + const RBMap::Element *E = values.find(p_name); if (E) { if (r_valid) { diff --git a/core/object/script_language.h b/core/object/script_language.h index fba2cb00d..bc63ed953 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -31,7 +31,7 @@ /*************************************************************************/ #include "core/io/multiplayer_api.h" -#include "core/containers/map.h" +#include "core/containers/rb_map.h" #include "core/containers/pair.h" #include "core/object/resource.h" @@ -149,7 +149,7 @@ public: virtual int get_member_line(const StringName &p_member) const { return -1; } - virtual void get_constants(Map *p_constants) {} + virtual void get_constants(RBMap *p_constants) {} virtual void get_members(Set *p_constants) {} virtual bool is_placeholder_fallback_enabled() const { return false; } @@ -372,8 +372,8 @@ extern uint8_t script_encryption_key[32]; class PlaceHolderScriptInstance : public ScriptInstance { Object *owner; List properties; - Map values; - Map constants; + RBMap values; + RBMap constants; ScriptLanguage *language; Ref