From 2cd4e4d828fe75ef7cbc7f43cb272eac1e6b9258 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 15 Jan 2023 19:42:08 +0100 Subject: [PATCH] Renamed Set to RBSet. --- core/config/project_settings.cpp | 8 +- core/config/project_settings.h | 4 +- core/containers/rb_set.h | 141 +--- core/containers/rid.h | 6 +- core/containers/set.h | 631 ------------------ core/io/file_access_pack.cpp | 2 +- core/io/file_access_pack.h | 4 +- core/io/json.cpp | 4 +- core/io/json.h | 2 +- core/io/logger.cpp | 4 +- core/io/multiplayer_api.cpp | 6 +- core/io/multiplayer_api.h | 2 +- core/io/resource_format_binary.cpp | 4 +- core/io/resource_format_binary.h | 4 +- core/io/resource_importer.cpp | 4 +- core/math/a_star.cpp | 8 +- core/math/a_star.h | 2 +- core/math/quick_hull.cpp | 2 +- core/math/quick_hull.h | 2 +- core/object/class_db.cpp | 2 +- core/object/class_db.h | 4 +- core/object/object.h | 10 +- core/object/resource.cpp | 2 +- core/object/resource.h | 2 +- core/object/script_debugger_local.cpp | 4 +- core/object/script_language.cpp | 4 +- core/object/script_language.h | 8 +- core/string/translation.cpp | 6 +- core/string/translation.h | 2 +- drivers/gles2/rasterizer_scene_gles2.cpp | 2 +- drivers/gles2/rasterizer_scene_gles2.h | 2 +- drivers/gles2/rasterizer_storage_gles2.cpp | 4 +- drivers/gles2/rasterizer_storage_gles2.h | 8 +- drivers/gles2/shader_compiler_gles2.cpp | 8 +- drivers/gles2/shader_compiler_gles2.h | 12 +- drivers/gles2/shader_gles2.cpp | 2 +- drivers/gles2/shader_gles2.h | 2 +- editor/animation_bezier_editor.cpp | 18 +- editor/animation_bezier_editor.h | 4 +- editor/animation_track_editor.cpp | 4 +- editor/create_dialog.cpp | 2 +- editor/create_dialog.h | 4 +- editor/doc/doc_data.cpp | 4 +- editor/editor_data.cpp | 4 +- editor/editor_data.h | 4 +- editor/editor_dir_dialog.h | 4 +- editor/editor_export.cpp | 30 +- editor/editor_export.h | 26 +- editor/editor_file_system.cpp | 8 +- editor/editor_file_system.h | 16 +- editor/editor_folding.cpp | 16 +- editor/editor_folding.h | 8 +- editor/editor_help.cpp | 4 +- editor/editor_inspector.cpp | 2 +- editor/editor_inspector.h | 6 +- editor/editor_node.cpp | 30 +- editor/editor_node.h | 10 +- editor/editor_profiler.cpp | 8 +- editor/editor_profiler.h | 4 +- editor/editor_resource_picker.cpp | 30 +- editor/editor_resource_picker.h | 6 +- editor/editor_settings.cpp | 6 +- editor/editor_themes.cpp | 4 +- editor/export_template_manager.cpp | 8 +- editor/fileserver/editor_file_server.h | 2 +- editor/filesystem_dock.cpp | 2 +- editor/filesystem_dock.h | 4 +- editor/find_in_files.cpp | 6 +- editor/find_in_files.h | 8 +- editor/import/resource_importer_scene.cpp | 18 +- editor/import/resource_importer_scene.h | 6 +- editor/import_dock.cpp | 4 +- editor/inspector_dock.cpp | 4 +- .../animation_blend_tree_editor_plugin.cpp | 10 +- editor/plugins/editor_preview_plugins.cpp | 6 +- .../plugins/mesh_instance_editor_plugin.cpp | 4 +- editor/plugins/root_motion_editor_plugin.cpp | 6 +- editor/plugins/script_editor_plugin.cpp | 4 +- editor/plugins/script_editor_plugin.h | 4 +- editor/plugins/script_text_editor.cpp | 12 +- editor/plugins/spatial_editor_plugin.cpp | 38 +- .../plugins/sprite_frames_editor_plugin.cpp | 4 +- editor/plugins/sprite_frames_editor_plugin.h | 6 +- editor/project_export.cpp | 6 +- editor/project_manager.cpp | 28 +- editor/project_settings_editor.cpp | 6 +- editor/property_editor.cpp | 10 +- editor/reparent_dialog.cpp | 2 +- editor/reparent_dialog.h | 4 +- editor/scene_tree_dock.cpp | 14 +- editor/scene_tree_dock.h | 4 +- editor/scene_tree_editor.cpp | 4 +- editor/scene_tree_editor.h | 6 +- editor/script_editor_debugger.cpp | 4 +- editor/script_editor_debugger.h | 6 +- editor_modules/gltf/gltf_document.cpp | 2 +- editor_modules/gltf/gltf_state.cpp | 4 +- editor_modules/gltf/gltf_state.h | 4 +- editor_modules/gltf/gltf_template_convert.h | 8 +- .../gltf/structures/gltf_skeleton.cpp | 2 +- .../gltf/structures/gltf_skeleton.h | 2 +- main/input_default.h | 6 +- main/main.cpp | 4 +- main/tests/test_math.cpp | 2 +- main/tests/test_shader_lang.cpp | 8 +- modules/cscript/cscript.cpp | 10 +- modules/cscript/cscript.h | 14 +- modules/cscript/cscript_compiler.cpp | 4 +- modules/cscript/cscript_compiler.h | 6 +- modules/cscript/cscript_editor.cpp | 6 +- modules/cscript/cscript_parser.cpp | 4 +- modules/cscript/cscript_parser.h | 4 +- modules/cscript/cscript_tokenizer.h | 10 +- modules/cscript/register_types.cpp | 2 +- modules/gdscript/gdscript.cpp | 10 +- modules/gdscript/gdscript.h | 14 +- modules/gdscript/gdscript_compiler.cpp | 4 +- modules/gdscript/gdscript_compiler.h | 6 +- modules/gdscript/gdscript_editor.cpp | 6 +- modules/gdscript/gdscript_parser.cpp | 4 +- modules/gdscript/gdscript_parser.h | 4 +- modules/gdscript/gdscript_tokenizer.h | 10 +- modules/gdscript/register_types.cpp | 2 +- modules/gridmap/grid_map.cpp | 2 +- modules/gridmap/grid_map.h | 2 +- .../scene_synchronizer.cpp | 2 +- .../network_synchronizer/scene_synchronizer.h | 6 +- .../skeleton_modification_2d_jiggle.cpp | 2 +- modules/skeleton_3d/nodes/skeleton.cpp | 8 +- modules/skeleton_3d/nodes/skeleton.h | 2 +- .../skeleton_modification_3d_jiggle.cpp | 2 +- .../wfc/overlapping_wave_form_collapse.cpp | 2 +- platform/android/export/export_plugin.cpp | 2 +- platform/android/export/export_plugin.h | 2 +- platform/android/java/app/config.gradle | 8 +- .../vending/licensing/APKExpansionPolicy.java | 2 +- .../vending/licensing/LicenseChecker.java | 2 +- .../pandemonium/pandemonium/Dictionary.java | 4 +- .../input/PandemoniumInputHandler.java | 2 +- .../pandemonium/plugin/PandemoniumPlugin.java | 10 +- .../plugin/PandemoniumPluginInfoProvider.java | 4 +- platform/iphone/export/export.cpp | 22 +- platform/iphone/pandemonium_app_delegate.m | 2 +- platform/javascript/export/export.cpp | 2 +- platform/osx/export/export.cpp | 6 +- scene/2d/audio_stream_player_2d.cpp | 2 +- scene/2d/physics_body_2d.cpp | 4 +- scene/2d/physics_body_2d.h | 2 +- scene/2d/ray_cast_2d.h | 2 +- scene/2d/shape_cast_2d.cpp | 2 +- scene/2d/shape_cast_2d.h | 2 +- scene/2d/visibility_notifier_2d.h | 2 +- scene/3d/audio_stream_player_3d.cpp | 2 +- scene/3d/camera.h | 2 +- scene/3d/collision_object.cpp | 2 +- scene/3d/collision_object.h | 2 +- scene/3d/physics_body.cpp | 4 +- scene/3d/physics_body.h | 2 +- scene/3d/ray_cast.h | 2 +- scene/3d/shape_cast.cpp | 2 +- scene/3d/shape_cast.h | 2 +- scene/3d/spring_arm.h | 2 +- scene/3d/vehicle_body.h | 2 +- scene/3d/visibility_notifier.h | 2 +- scene/animation/animation_player.cpp | 2 +- scene/animation/animation_player.h | 2 +- scene/animation/animation_tree.cpp | 2 +- scene/animation/animation_tree.h | 2 +- scene/debugger/script_debugger_remote.cpp | 8 +- scene/gui/base_button.cpp | 8 +- scene/gui/base_button.h | 2 +- scene/gui/graph_edit.h | 6 +- scene/gui/grid_container.cpp | 8 +- scene/gui/range.cpp | 4 +- scene/gui/range.h | 2 +- scene/gui/text_edit.h | 2 +- scene/main/node.cpp | 8 +- scene/main/node.h | 4 +- scene/main/resource_preloader.cpp | 4 +- scene/main/scene_tree.cpp | 42 +- scene/main/scene_tree.h | 4 +- scene/main/viewport.cpp | 16 +- scene/main/viewport.h | 6 +- scene/main/world.cpp | 2 +- scene/main/world.h | 2 +- scene/resources/bit_map.cpp | 4 +- scene/resources/concave_polygon_shape.cpp | 4 +- scene/resources/packed_scene.cpp | 2 +- scene/resources/polygon_path_finder.cpp | 28 +- scene/resources/polygon_path_finder.h | 4 +- scene/resources/resource_format_text.cpp | 4 +- scene/resources/resource_format_text.h | 4 +- scene/resources/theme.cpp | 4 +- servers/audio/audio_stream.cpp | 2 +- servers/audio/audio_stream.h | 4 +- servers/audio_server.cpp | 4 +- servers/audio_server.h | 4 +- servers/physics/area_sw.h | 4 +- servers/physics/physics_server_sw.cpp | 8 +- servers/physics/physics_server_sw.h | 4 +- servers/physics/space_sw.cpp | 16 +- servers/physics/space_sw.h | 18 +- servers/physics/step_sw.cpp | 2 +- servers/physics_2d/area_2d_sw.h | 4 +- servers/physics_2d/physics_2d_server_sw.cpp | 8 +- servers/physics_2d/physics_2d_server_sw.h | 4 +- .../physics_2d/physics_2d_server_wrap_mt.h | 2 +- servers/physics_2d/space_2d_sw.cpp | 20 +- servers/physics_2d/space_2d_sw.h | 22 +- servers/physics_2d/step_2d_sw.cpp | 2 +- servers/physics_2d_server.cpp | 8 +- servers/physics_2d_server.h | 18 +- servers/physics_server.cpp | 8 +- servers/physics_server.h | 16 +- servers/rendering/rendering_server_canvas.cpp | 8 +- servers/rendering/rendering_server_canvas.h | 8 +- .../rendering/rendering_server_viewport.cpp | 4 +- servers/rendering/shader_language.cpp | 24 +- servers/rendering/shader_language.h | 10 +- servers/rendering/shader_types.cpp | 2 +- servers/rendering/shader_types.h | 4 +- thirdparty/misc/triangulator.cpp | 12 +- thirdparty/misc/triangulator.h | 6 +- 223 files changed, 736 insertions(+), 1446 deletions(-) delete mode 100644 core/containers/set.h diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 0da8ccec6..6d0b1ca80 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -233,7 +233,7 @@ struct _VCSort { void ProjectSettings::_get_property_list(List *p_list) const { _THREAD_SAFE_METHOD_ - Set<_VCSort> vclist; + RBSet<_VCSort> vclist; for (RBMap::Element *E = props.front(); E; E = E->next()) { const VariantContainer *v = &E->get(); @@ -258,7 +258,7 @@ void ProjectSettings::_get_property_list(List *p_list) const { vclist.insert(vc); } - for (Set<_VCSort>::Element *E = vclist.front(); E; E = E->next()) { + for (RBSet<_VCSort>::Element *E = vclist.front(); E; E = E->next()) { String prop_info_name = E->get().name; int dot = prop_info_name.find("."); if (dot != -1) { @@ -816,7 +816,7 @@ Error ProjectSettings::_save_custom_bnd(const String &p_file) { // add other par Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_custom, const Vector &p_custom_features, bool p_merge_with_current) { ERR_FAIL_COND_V_MSG(p_path == "", ERR_INVALID_PARAMETER, "Project settings save path cannot be empty."); - Set<_VCSort> vclist; + RBSet<_VCSort> vclist; if (p_merge_with_current) { for (RBMap::Element *G = props.front(); G; G = G->next()) { @@ -857,7 +857,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust RBMap> props; - for (Set<_VCSort>::Element *E = vclist.front(); E; E = E->next()) { + for (RBSet<_VCSort>::Element *E = vclist.front(); E; E = E->next()) { String category = E->get().name; String name = E->get().name; diff --git a/core/config/project_settings.h b/core/config/project_settings.h index 94f4390b4..ee37b27ab 100644 --- a/core/config/project_settings.h +++ b/core/config/project_settings.h @@ -32,7 +32,7 @@ #include "core/object/object.h" #include "core/os/thread_safe.h" -#include "core/containers/set.h" +#include "core/containers/rb_set.h" // Querying ProjectSettings is usually done at startup. // Additionally, in order to keep track of changes to ProjectSettings, @@ -114,7 +114,7 @@ protected: bool using_datapack; List input_presets; - Set custom_features; + RBSet custom_features; String project_data_dir_name; diff --git a/core/containers/rb_set.h b/core/containers/rb_set.h index e87ea544f..436d4e7c4 100644 --- a/core/containers/rb_set.h +++ b/core/containers/rb_set.h @@ -1,5 +1,8 @@ +#ifndef RB_SET_H +#define RB_SET_H + /*************************************************************************/ -/* rb_set.h */ +/* set.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,14 +31,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef RB_SET_H -#define RB_SET_H - #include "core/os/memory.h" #include "core/typedefs.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 RBSet { @@ -49,12 +49,12 @@ public: class Element { private: friend class RBSet; - int color = RED; - Element *right = nullptr; - Element *left = nullptr; - Element *parent = nullptr; - Element *_next = nullptr; - Element *_prev = nullptr; + int color; + Element *right; + Element *left; + Element *parent; + Element *_next; + Element *_prev; T value; //_Data *data; @@ -71,102 +71,24 @@ public: Element *prev() { return _prev; } - T &get() { - return value; - } const T &get() const { return value; }; - Element() {} + Element() { + color = RED; + right = nullptr; + left = nullptr; + parent = nullptr; + _next = nullptr; + _prev = nullptr; + }; }; - typedef T ValueType; - - struct Iterator { - _FORCE_INLINE_ T &operator*() const { - return E->get(); - } - _FORCE_INLINE_ T *operator->() const { return &E->get(); } - _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 T &operator*() const { - return E->get(); - } - _FORCE_INLINE_ const T *operator->() const { return &E->get(); } - _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; } - - _FORCE_INLINE_ ConstIterator(const Element *p_E) { E = p_E; } - _FORCE_INLINE_ ConstIterator() {} - _FORCE_INLINE_ ConstIterator(const ConstIterator &p_it) { E = p_it.E; } - - explicit operator bool() const { return E != nullptr; } - - 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_ 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 @@ -176,6 +98,8 @@ private: #else _nil = (Element *)&_GlobalNilClass::_nil; #endif + _root = nullptr; + size_cache = 0; } void _create_root() { @@ -331,7 +255,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; @@ -485,7 +409,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; @@ -664,12 +588,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 @@ -701,11 +621,12 @@ public: _copy_from(p_set); } - _FORCE_INLINE_ RBSet() {} + _FORCE_INLINE_ RBSet() { + } ~RBSet() { clear(); } }; -#endif // RB_SET_H +#endif diff --git a/core/containers/rid.h b/core/containers/rid.h index 92d938430..d15942578 100644 --- a/core/containers/rid.h +++ b/core/containers/rid.h @@ -34,7 +34,7 @@ #include "core/os/memory.h" #include "core/containers/rid_handle.h" #include "core/os/safe_refcount.h" -#include "core/containers/set.h" +#include "core/containers/rb_set.h" #include "core/typedefs.h" #ifndef RID_HANDLES_ENABLED @@ -120,7 +120,7 @@ template class RID_Owner : public RID_OwnerBase { public: #ifdef DEBUG_ENABLED - mutable Set id_map; + mutable RBSet id_map; #endif public: _FORCE_INLINE_ RID make_rid(T *p_data) { @@ -179,7 +179,7 @@ public: void get_owned_list(List *p_owned) { #ifdef DEBUG_ENABLED - for (typename Set::Element *E = id_map.front(); E; E = E->next()) { + for (typename RBSet::Element *E = id_map.front(); E; E = E->next()) { RID r; _set_data(r, static_cast(E->get())); p_owned->push_back(r); diff --git a/core/containers/set.h b/core/containers/set.h deleted file mode 100644 index b3ff638a4..000000000 --- a/core/containers/set.h +++ /dev/null @@ -1,631 +0,0 @@ -#ifndef SET_H -#define SET_H -/*************************************************************************/ -/* set.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/os/memory.h" -#include "core/typedefs.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 Set { - enum Color { - RED, - BLACK - }; - struct _Data; - -public: - class Element { - private: - friend class Set; - int color; - Element *right; - Element *left; - Element *parent; - Element *_next; - Element *_prev; - T 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 T &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 T &p_value) const { - Element *node = _data._root->left; - C less; - - while (node != _data._nil) { - if (less(p_value, node->value)) { - node = node->left; - } else if (less(node->value, p_value)) { - node = node->right; - } else { - return node; // found - } - } - - return nullptr; - } - - Element *_lower_bound(const T &p_value) const { - Element *node = _data._root->left; - Element *prev = nullptr; - C less; - - while (node != _data._nil) { - prev = node; - - if (less(p_value, node->value)) { - node = node->left; - } else if (less(node->value, p_value)) { - node = node->right; - } else { - return node; // found - } - } - - if (prev == nullptr) { - return nullptr; // tree empty - } - - if (less(prev->value, p_value)) { - prev = prev->_next; - } - - 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 T &p_value) { - Element *new_parent = _data._root; - Element *node = _data._root->left; - C less; - - while (node != _data._nil) { - new_parent = node; - - if (less(p_value, node->value)) { - node = node->left; - } else if (less(node->value, p_value)) { - node = node->right; - } else { - return node; // Return existing node - } - } - - Element *new_node = memnew_allocator(Element, A); - new_node->parent = new_parent; - new_node->right = _data._nil; - new_node->left = _data._nil; - new_node->value = p_value; - //new_node->data=_data; - - if (new_parent == _data._root || less(p_value, new_parent->value)) { - 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 Set &p_set) { - clear(); - // not the fastest way, but safeset to write. - for (Element *I = p_set.front(); I; I = I->next()) { - insert(I->get()); - } - } - -public: - const Element *find(const T &p_value) const { - if (!_data._root) { - return nullptr; - } - - const Element *res = _find(p_value); - return res; - } - - Element *find(const T &p_value) { - if (!_data._root) { - return nullptr; - } - - Element *res = _find(p_value); - return res; - } - - Element *lower_bound(const T &p_value) const { - if (!_data._root) { - return nullptr; - } - return _lower_bound(p_value); - } - - bool has(const T &p_value) const { - return find(p_value) != nullptr; - } - - Element *insert(const T &p_value) { - if (!_data._root) { - _data._create_root(); - } - return _insert(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 T &p_value) { - if (!_data._root) { - return false; - } - - Element *e = find(p_value); - if (!e) { - return false; - } - - _erase(e); - if (_data.size_cache == 0 && _data._root) { - _data._free_root(); - } - return true; - } - - 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 Set &p_set) { - _copy_from(p_set); - } - - Set(const Set &p_set) { - _copy_from(p_set); - } - - _FORCE_INLINE_ Set() { - } - - ~Set() { - clear(); - } -}; - -#endif diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index d65546de7..8e5280a10 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -382,7 +382,7 @@ Error DirAccessPack::list_dir_begin() { list_dirs.push_back(E->key()); } - for (Set::Element *E = current->files.front(); E; E = E->next()) { + for (RBSet::Element *E = current->files.front(); E; E = E->next()) { list_files.push_back(E->get()); } diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index e9004605d..1dc90fff9 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -35,7 +35,7 @@ #include "core/os/dir_access.h" #include "core/os/file_access.h" #include "core/string/print_string.h" -#include "core/containers/set.h" +#include "core/containers/rb_set.h" #include "core/containers/hashfuncs.h" // Pandemonium's packed file magic header ("GDPC" in ASCII). @@ -64,7 +64,7 @@ private: PackedDir *parent; String name; RBMap subdirs; - Set files; + RBSet files; }; struct PathMD5 { diff --git a/core/io/json.cpp b/core/io/json.cpp index 35f2fc649..90e2c54ea 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -55,7 +55,7 @@ static String _make_indent(const String &p_indent, int p_size) { return indent_text; } -String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, Set &p_markers) { +String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, RBSet &p_markers) { String colon = ":"; String end_statement = ""; @@ -130,7 +130,7 @@ String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_ } String JSON::print(const Variant &p_var, const String &p_indent, bool p_sort_keys) { - Set markers; + RBSet markers; return _print_var(p_var, p_indent, 0, p_sort_keys, markers); } diff --git a/core/io/json.h b/core/io/json.h index 5fb48548b..fb4a1b310 100644 --- a/core/io/json.h +++ b/core/io/json.h @@ -62,7 +62,7 @@ class JSON { static const char *tk_name[TK_MAX]; - static String _print_var(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, Set &p_markers); + static String _print_var(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, RBSet &p_markers); static Error _get_token(const CharType *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str); static Error _parse_value(Variant &value, Token &token, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str); diff --git a/core/io/logger.cpp b/core/io/logger.cpp index d5c3a6104..b23aac2b5 100644 --- a/core/io/logger.cpp +++ b/core/io/logger.cpp @@ -144,7 +144,7 @@ void RotatedFileLogger::clear_old_backups() { da->list_dir_begin(); String f = da->get_next(); - Set backups; + RBSet backups; while (f != String()) { if (!da->current_is_dir() && f.begins_with(basename) && f.get_extension() == extension && f != base_path.get_file()) { backups.insert(f); @@ -157,7 +157,7 @@ void RotatedFileLogger::clear_old_backups() { // since backups are appended with timestamp and Set iterates them in sorted order, // first backups are the oldest int to_delete = backups.size() - max_backups; - for (Set::Element *E = backups.front(); E && to_delete > 0; E = E->next(), --to_delete) { + for (RBSet::Element *E = backups.front(); E && to_delete > 0; E = E->next(), --to_delete) { da->remove(E->get()); } } diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp index eea5d8e76..88a14f108 100644 --- a/core/io/multiplayer_api.cpp +++ b/core/io/multiplayer_api.cpp @@ -366,7 +366,7 @@ bool MultiplayerAPI::_send_confirm_path(NodePath p_path, PathSentCache *psc, int bool has_all_peers = true; List peers_to_add; // If one is missing, take note to add it. - for (Set::Element *E = connected_peers.front(); E; E = E->next()) { + for (RBSet::Element *E = connected_peers.front(); E; E = E->next()) { if (p_target < 0 && E->get() == -p_target) { continue; // Continue, excluded. } @@ -503,7 +503,7 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, const MAKE_ROOM(ofs + path_len); encode_cstring(pname.get_data(), &(packet_cache.write[ofs])); - for (Set::Element *E = connected_peers.front(); E; E = E->next()) { + for (RBSet::Element *E = connected_peers.front(); E; E = E->next()) { if (p_to < 0 && E->get() == -p_to) { continue; // Continue, excluded. } @@ -663,7 +663,7 @@ Vector MultiplayerAPI::get_network_connected_peers() const { ERR_FAIL_COND_V_MSG(!network_peer.is_valid(), Vector(), "No network peer is assigned. Assume no peers are connected."); Vector ret; - for (Set::Element *E = connected_peers.front(); E; E = E->next()) { + for (RBSet::Element *E = connected_peers.front(); E; E = E->next()) { ret.push_back(E->get()); } diff --git a/core/io/multiplayer_api.h b/core/io/multiplayer_api.h index e357a5819..c958ff4b0 100644 --- a/core/io/multiplayer_api.h +++ b/core/io/multiplayer_api.h @@ -82,7 +82,7 @@ private: Ref network_peer; int rpc_sender_id; - Set connected_peers; + RBSet connected_peers; HashMap path_send_cache; RBMap path_get_cache; int last_send_cache_id; diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 4310218ae..737f216fa 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -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, RBMap &external_resources, RBMap &string_map, const PropertyInfo &p_hint) { +void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Variant &p_property, RBSet &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); @@ -1999,7 +1999,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p // save internal resource table f->store_32(saved_resources.size()); //amount of internal resources Vector ofs_pos; - Set used_indices; + RBSet used_indices; for (List::Element *E = saved_resources.front(); E; E = E->next()) { RES r = E->get(); diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index 524490a6f..135f3deca 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -119,7 +119,7 @@ class ResourceFormatSaverBinaryInstance { bool takeover_paths; FileAccess *f; String magic; - Set resource_set; + RBSet resource_set; struct NonPersistentKey { //for resource properties generated on the fly RES base; @@ -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, RBMap &external_resources, RBMap &string_map, const PropertyInfo &p_hint = PropertyInfo()); + static void write_variant(FileAccess *f, const Variant &p_property, RBSet &resource_set, RBMap &external_resources, RBMap &string_map, const PropertyInfo &p_hint = PropertyInfo()); }; class ResourceFormatSaverBinary : public ResourceFormatSaver { diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp index ff544edca..c38802814 100644 --- a/core/io/resource_importer.cpp +++ b/core/io/resource_importer.cpp @@ -141,7 +141,7 @@ RES ResourceFormatImporter::load(const String &p_path, const String &p_original_ } void ResourceFormatImporter::get_recognized_extensions(List *p_extensions) const { - Set found; + RBSet found; for (int i = 0; i < importers.size(); i++) { List local_exts; @@ -161,7 +161,7 @@ void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_ return; } - Set found; + RBSet found; for (int i = 0; i < importers.size(); i++) { String res_type = importers[i]->get_resource_type(); diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 7794dee2d..7765faf07 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -152,7 +152,7 @@ void AStar::connect_points(int p_id, int p_with_id, bool bidirectional) { s.direction = Segment::BIDIRECTIONAL; } - Set::Element *element = segments.find(s); + RBSet::Element *element = segments.find(s); if (element != nullptr) { s.direction |= element->get().direction; if (s.direction == Segment::BIDIRECTIONAL) { @@ -178,7 +178,7 @@ void AStar::disconnect_points(int p_id, int p_with_id, bool bidirectional) { Segment s(p_id, p_with_id); int remove_direction = bidirectional ? (int)Segment::BIDIRECTIONAL : s.direction; - Set::Element *element = segments.find(s); + RBSet::Element *element = segments.find(s); if (element != nullptr) { // s is the new segment // Erase the directions to be removed @@ -236,7 +236,7 @@ PoolVector AStar::get_point_connections(int p_id) { bool AStar::are_points_connected(int p_id, int p_with_id, bool bidirectional) const { Segment s(p_id, p_with_id); - const Set::Element *element = segments.find(s); + const RBSet::Element *element = segments.find(s); return element != nullptr && (bidirectional || (element->get().direction & s.direction) == s.direction); @@ -294,7 +294,7 @@ Vector3 AStar::get_closest_position_in_segment(const Vector3 &p_point) const { real_t closest_dist = 1e20; Vector3 closest_point; - for (const Set::Element *E = segments.front(); E; E = E->next()) { + for (const RBSet::Element *E = segments.front(); E; E = E->next()) { Point *from_point = nullptr, *to_point = nullptr; points.lookup(E->get().u, from_point); points.lookup(E->get().v, to_point); diff --git a/core/math/a_star.h b/core/math/a_star.h index 3303c57f2..01bd7ea3e 100644 --- a/core/math/a_star.h +++ b/core/math/a_star.h @@ -115,7 +115,7 @@ class AStar : public Reference { uint64_t pass; OAHashMap points; - Set segments; + RBSet segments; bool _solve(Point *begin_point, Point *end_point); diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp index 4f9972082..5dcaed6a0 100644 --- a/core/math/quick_hull.cpp +++ b/core/math/quick_hull.cpp @@ -47,7 +47,7 @@ Error QuickHull::build(const Vector &p_points, Geometry::MeshData &r_me Vector valid_points; valid_points.resize(p_points.size()); - Set valid_cache; + RBSet valid_cache; for (int i = 0; i < p_points.size(); i++) { Vector3 sp = p_points[i].snapped(Vector3(0.0001, 0.0001, 0.0001)); diff --git a/core/math/quick_hull.h b/core/math/quick_hull.h index 78601e1e5..b01c22cb5 100644 --- a/core/math/quick_hull.h +++ b/core/math/quick_hull.h @@ -33,7 +33,7 @@ #include "core/containers/list.h" #include "core/math/aabb.h" #include "core/math/geometry.h" -#include "core/containers/set.h" +#include "core/containers/rb_set.h" class QuickHull { public: diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index bcb1a9f0f..558caa746 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -1338,7 +1338,7 @@ void ClassDB::get_extensions_for_type(const StringName &p_class, List *p } HashMap> ClassDB::default_values; -Set ClassDB::default_values_cached; +RBSet ClassDB::default_values_cached; Variant ClassDB::class_get_default_property_value(const StringName &p_class, const StringName &p_property, bool *r_valid) { if (!default_values_cached.has(p_class)) { diff --git a/core/object/class_db.h b/core/object/class_db.h index ceea2ac01..e6b30d93c 100644 --- a/core/object/class_db.h +++ b/core/object/class_db.h @@ -119,7 +119,7 @@ public: #ifdef DEBUG_METHODS_ENABLED List constant_order; List method_order; - Set methods_in_properties; + RBSet methods_in_properties; List virtual_methods; StringName category; #endif @@ -155,7 +155,7 @@ public: static void _add_class2(const StringName &p_class, const StringName &p_inherits); static HashMap> default_values; - static Set default_values_cached; + static RBSet default_values_cached; private: // Non-locking variants of get_parent_class and is_parent_class. diff --git a/core/object/object.h b/core/object/object.h index 63c18094b..2b7092ca6 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -36,7 +36,7 @@ #include "core/object/object_id.h" #include "core/os/rw_lock.h" #include "core/os/safe_refcount.h" -#include "core/containers/set.h" +#include "core/containers/rb_set.h" #include "core/variant/variant.h" #include "core/containers/vmap.h" @@ -487,7 +487,7 @@ private: #endif bool _block_signals; int _predelete_ok; - Set change_receptors; + RBSet change_receptors; ObjectID _instance_id; std::atomic _rc; bool _predelete(); @@ -497,7 +497,7 @@ private: #ifdef TOOLS_ENABLED bool _edited; uint32_t _edited_version; - Set editor_section_folding; + RBSet editor_section_folding; #endif ScriptInstance *script_instance; RefPtr script; @@ -601,7 +601,7 @@ public: #ifdef TOOLS_ENABLED _FORCE_INLINE_ void _change_notify(const char *p_property = "") { _edited = true; - for (Set::Element *E = change_receptors.front(); E; E = E->next()) { + for (RBSet::Element *E = change_receptors.front(); E; E = E->next()) { ((Object *)(E->get()))->_changed_callback(this, p_property); } } @@ -792,7 +792,7 @@ public: #ifdef TOOLS_ENABLED void editor_set_section_unfold(const String &p_section, bool p_unfolded); bool editor_is_section_unfolded(const String &p_section); - const Set &editor_get_section_folding() const { + const RBSet &editor_get_section_folding() const { return editor_section_folding; } void editor_clear_section_folding() { diff --git a/core/object/resource.cpp b/core/object/resource.cpp index 8a620040b..37308b695 100644 --- a/core/object/resource.cpp +++ b/core/object/resource.cpp @@ -251,7 +251,7 @@ void Resource::unregister_owner(Object *p_owner) { } void Resource::notify_change_to_owners() { - for (Set::Element *E = owners.front(); E; E = E->next()) { + for (RBSet::Element *E = owners.front(); E; E = E->next()) { Object *obj = ObjectDB::get_instance(E->get()); ERR_CONTINUE_MSG(!obj, "Object was deleted, while still owning a resource."); //wtf //TODO store string diff --git a/core/object/resource.h b/core/object/resource.h index 65daee34f..39e9b5234 100644 --- a/core/object/resource.h +++ b/core/object/resource.h @@ -49,7 +49,7 @@ class Resource : public Reference { OBJ_CATEGORY("Resources"); RES_BASE_EXTENSION("res"); - Set owners; + RBSet owners; friend class ResBase; friend class ResourceCache; diff --git a/core/object/script_debugger_local.cpp b/core/object/script_debugger_local.cpp index d9b900a88..ea28d29ed 100644 --- a/core/object/script_debugger_local.cpp +++ b/core/object/script_debugger_local.cpp @@ -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 RBMap> &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 (RBMap>::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_language.cpp b/core/object/script_language.cpp index 13bf6b058..e232b0801 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -378,7 +378,7 @@ int ScriptDebugger::get_depth() const { void ScriptDebugger::insert_breakpoint(int p_line, const StringName &p_source) { if (!breakpoints.has(p_line)) { - breakpoints[p_line] = Set(); + breakpoints[p_line] = RBSet(); } breakpoints[p_line].insert(p_source); } @@ -539,7 +539,7 @@ bool PlaceHolderScriptInstance::has_method(const StringName &p_method) const { } void PlaceHolderScriptInstance::update(const List &p_properties, const RBMap &p_values) { - Set new_values; + RBSet new_values; for (const List::Element *E = p_properties.front(); E; E = E->next()) { StringName n = E->get().name; new_values.insert(n); diff --git a/core/object/script_language.h b/core/object/script_language.h index bc63ed953..eadbb7322 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -150,7 +150,7 @@ public: virtual int get_member_line(const StringName &p_member) const { return -1; } virtual void get_constants(RBMap *p_constants) {} - virtual void get_members(Set *p_constants) {} + virtual void get_members(RBSet *p_constants) {} virtual bool is_placeholder_fallback_enabled() const { return false; } @@ -269,7 +269,7 @@ public: virtual Ref