From 45af29da8095af16729955117a165d23e77cd740 Mon Sep 17 00:00:00 2001 From: reduz Date: Thu, 19 May 2022 17:00:06 +0200 Subject: Add a new HashSet template * Intended to replace RBSet in most cases. * Optimized for iteration speed --- scene/gui/graph_edit.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'scene/gui/graph_edit.h') diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h index 9e34d5528f..5484a2317c 100644 --- a/scene/gui/graph_edit.h +++ b/scene/gui/graph_edit.h @@ -218,8 +218,11 @@ private: uint64_t key = 0; }; - bool operator<(const ConnType &p_type) const { - return key < p_type.key; + static uint32_t hash(const ConnType &p_conn) { + return hash_one_uint64(p_conn.key); + } + bool operator==(const ConnType &p_type) const { + return key == p_type.key; } ConnType(uint32_t a = 0, uint32_t b = 0) { @@ -228,9 +231,9 @@ private: } }; - RBSet valid_connection_types; - RBSet valid_left_disconnect_types; - RBSet valid_right_disconnect_types; + HashSet valid_connection_types; + HashSet valid_left_disconnect_types; + HashSet valid_right_disconnect_types; HashMap> comment_enclosed_nodes; void _update_comment_enclosed_nodes_list(GraphNode *p_node, HashMap> &p_comment_enclosed_nodes); @@ -258,12 +261,12 @@ private: UNION, }; - int _set_operations(SET_OPERATIONS p_operation, RBSet &r_u, const RBSet &r_v); - HashMap> _layering(const RBSet &r_selected_nodes, const HashMap> &r_upper_neighbours); + int _set_operations(SET_OPERATIONS p_operation, HashSet &r_u, const HashSet &r_v); + HashMap> _layering(const HashSet &r_selected_nodes, const HashMap> &r_upper_neighbours); Vector _split(const Vector &r_layer, const HashMap &r_crossings); - void _horizontal_alignment(Dictionary &r_root, Dictionary &r_align, const HashMap> &r_layers, const HashMap> &r_upper_neighbours, const RBSet &r_selected_nodes); - void _crossing_minimisation(HashMap> &r_layers, const HashMap> &r_upper_neighbours); - void _calculate_inner_shifts(Dictionary &r_inner_shifts, const Dictionary &r_root, const Dictionary &r_node_names, const Dictionary &r_align, const RBSet &r_block_heads, const HashMap> &r_port_info); + void _horizontal_alignment(Dictionary &r_root, Dictionary &r_align, const HashMap> &r_layers, const HashMap> &r_upper_neighbours, const HashSet &r_selected_nodes); + void _crossing_minimisation(HashMap> &r_layers, const HashMap> &r_upper_neighbours); + void _calculate_inner_shifts(Dictionary &r_inner_shifts, const Dictionary &r_root, const Dictionary &r_node_names, const Dictionary &r_align, const HashSet &r_block_heads, const HashMap> &r_port_info); float _calculate_threshold(StringName p_v, StringName p_w, const Dictionary &r_node_names, const HashMap> &r_layers, const Dictionary &r_root, const Dictionary &r_align, const Dictionary &r_inner_shift, real_t p_current_threshold, const HashMap &r_node_positions); void _place_block(StringName p_v, float p_delta, const HashMap> &r_layers, const Dictionary &r_root, const Dictionary &r_align, const Dictionary &r_node_name, const Dictionary &r_inner_shift, Dictionary &r_sink, Dictionary &r_shift, HashMap &r_node_positions); -- cgit v1.2.3