{"id":8466,"date":"2023-07-10T13:56:31","date_gmt":"2023-07-10T11:56:31","guid":{"rendered":"https:\/\/store.algosyntax.com\/?post_type=asx-lms-tutorial-cpt&#038;p=8466"},"modified":"2026-03-09T11:26:21","modified_gmt":"2026-03-09T09:26:21","slug":"gettypehash-in-unreal-engine-5-for-tmap-or-tset","status":"publish","type":"asx-lms-tutorial-cpt","link":"https:\/\/store.algosyntax.com\/tutorials\/unreal-engine\/gettypehash-in-unreal-engine-5-for-tmap-or-tset\/","title":{"rendered":"GetTypeHash in Unreal Engine 5: For TMap or TSet"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"8466\" class=\"elementor elementor-8466\" data-elementor-post-type=\"asx-lms-tutorial-cpt\">\n\t\t\t\t<div class=\"elementor-element elementor-element-84931e1 e-flex e-con-boxed e-con e-parent\" data-id=\"84931e1\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-ae8f943 elementor-widget elementor-widget-text-editor\" data-id=\"ae8f943\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>In the realm of Unreal Engine 5 (UE5), working with data structures such as TMaps and TSets often requires a sound understanding of hashing and its associated functions. One such function, GetTypeHash, plays a significant role in managing these data structures, particularly when dealing with custom types. In this guide, we&#8217;ll delve into the world of GetTypeHash, demystifying its purpose, its importance in UE5, and how to properly utilize it in your projects.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-39ab1a7 elementor-widget elementor-widget-heading\" data-id=\"39ab1a7\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Understanding Hashing in UE5\n<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b3a202a elementor-widget elementor-widget-text-editor\" data-id=\"b3a202a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>Before we dive into GetTypeHash, let&#8217;s briefly explain the concept of hashing. A hash function takes an input (or &#8216;message&#8217;) and returns a fixed-size string of bytes, which typically appears random. The output, known as the hash value or simply the hash, represents the original data.<br \/><br \/><\/p><p>Hashing is essential for data structures like TMap and TSet, where it enables fast and efficient access to elements. UE5 needs to know how to hash every key in a TMap or TSet, and that&#8217;s where GetTypeHash comes in.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3812de5 elementor-widget elementor-widget-heading\" data-id=\"3812de5\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">What is GetTypeHash?\n<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-85a7085 elementor-widget elementor-widget-text-editor\" data-id=\"85a7085\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>GetTypeHash is a global UE5 function that returns the hash value of its input. It&#8217;s typically used with simple data types (e.g., integers, floats, strings), but UE5 also allows developers to define custom GetTypeHash functions for their own types. This is crucial when using a custom struct or class as a key in a TMap or TSet.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-86ceec4 elementor-widget elementor-widget-heading\" data-id=\"86ceec4\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Implementing GetTypeHash for Custom Types\n<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-53ad735 elementor-widget elementor-widget-text-editor\" data-id=\"53ad735\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>When creating a custom type that you plan to use as a key in a TMap or TSet, you need to define a GetTypeHash function for that type. Here&#8217;s a basic example of how to do this:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7aaf97d elementor-widget elementor-widget-code-highlight\" data-id=\"7aaf97d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-cpp line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-cpp\">\n\t\t\t\t\t<xmp>USTRUCT(BlueprintType)\r\nstruct FPlayerInfo\r\n{\r\n    GENERATED_BODY()\r\n\r\n    UPROPERTY(BlueprintReadWrite, Category = \"Player Info\")\r\n    FString Name;\r\n\r\n    UPROPERTY(BlueprintReadWrite, Category = \"Player Info\")\r\n    int32 Score;\r\n\r\n    friend uint32 GetTypeHash(const FPlayerInfo& PlayerInfo)\r\n    {\r\n        return HashCombine(GetTypeHash(PlayerInfo.Name), PlayerInfo.Score);\r\n    }\r\n};\r\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-cb3875c elementor-widget elementor-widget-heading\" data-id=\"cb3875c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Why is GetTypeHash Important?\n<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-44ff5aa elementor-widget elementor-widget-text-editor\" data-id=\"44ff5aa\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>GetTypeHash is important for two main reasons:<br \/><br \/><\/p><p><strong>1. Efficiency:<\/strong> Hashing allows TMaps and TSets to quickly find and access elements. Without hashing, these data structures would need to compare each element to the target element to find a match, which could be slow for large datasets.<br \/><br \/><\/p><p><strong>2. Flexibility:<\/strong> By allowing custom GetTypeHash implementations, UE5 lets you use almost any type as a key in a TMap or TSet. This flexibility can simplify your code and make your data structures more intuitive.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b90d697 elementor-widget elementor-widget-heading\" data-id=\"b90d697\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Conclusion<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b16523b elementor-widget elementor-widget-text-editor\" data-id=\"b16523b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>Understanding GetTypeHash and hashing in general is key to leveraging the full power of UE5&#8217;s data structures. By knowing how to implement custom GetTypeHash functions, you can create more flexible and efficient TMaps and TSets, leading to cleaner code and potentially better performance. As you continue to explore UE5, consider how GetTypeHash and hashing can contribute to your game development toolkit.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-3413065b e-flex e-con-boxed e-con e-parent\" data-id=\"3413065b\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t<div class=\"elementor-element elementor-element-478eb570 e-con-full e-flex e-con e-parent\" data-id=\"478eb570\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-7509b54 elementor-widget elementor-widget-heading\" data-id=\"7509b54\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<p class=\"elementor-heading-title elementor-size-default\">Nifty UE5 Plugin<\/p>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2c99960c elementor-widget elementor-widget-image\" data-id=\"2c99960c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"https:\/\/www.unrealengine.com\/marketplace\/en-US\/product\/umg-cinematics\" target=\"_blank\" rel=\"noopener\">\n\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"600\" height=\"600\" src=\"https:\/\/store.algosyntax.com\/wp-content\/uploads\/marketplace\/unreal-engine\/umg-cinematics.jpg\" class=\"attachment-full size-full wp-image-6160\" alt=\"UE5 Add Widgets To Sequencer\" \/>\t\t\t\t\t\t\t\t<\/a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-7d9cc6b0 e-con-full e-flex e-con e-parent\" data-id=\"7d9cc6b0\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-55b35684 elementor-widget elementor-widget-heading\" data-id=\"55b35684\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<p class=\"elementor-heading-title elementor-size-default\">Add UMG Widgets To Level Sequences!<\/p>\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-34f3fc06 e-con-full e-flex e-con e-parent\" data-id=\"34f3fc06\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-5de8ca88 elementor-widget__width-auto elementor-widget elementor-widget-heading\" data-id=\"5de8ca88\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<p class=\"elementor-heading-title elementor-size-default\"><a href=\"https:\/\/www.unrealengine.com\/marketplace\/en-US\/product\/umg-cinematics\" target=\"_blank\" rel=\"noopener\">&lt;b<strong><s><\/s> $49!<\/strong><\/a><\/p>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6d6d114c elementor-widget elementor-widget-button\" data-id=\"6d6d114c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"button.default\">\n\t\t\t\t\t\t\t\t\t\t<a class=\"elementor-button elementor-button-link elementor-size-sm\" href=\"https:\/\/www.unrealengine.com\/marketplace\/en-US\/product\/umg-cinematics\" target=\"_blank\" rel=\"noopener\">\n\t\t\t\t\t\t<span class=\"elementor-button-content-wrapper\">\n\t\t\t\t\t\t\t\t\t<span class=\"elementor-button-text\">Get UMG Cinematics<\/span>\n\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/a>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-aae8af7 elementor-widget elementor-widget-text-editor\" data-id=\"aae8af7\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>Did you Know?<\/p><p>You can add UMG Widgets to Sequencer for runtime text and shape layers. Suitable for QTE!<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"featured_media":0,"template":"","asx-lms-tutorial-categories":[45,58],"asx-lms-tutorial-tags":[46],"class_list":["post-8466","asx-lms-tutorial-cpt","type-asx-lms-tutorial-cpt","status-publish","hentry","asx-lms-tutorial-categories-unreal-engine","asx-lms-tutorial-categories-unreal-c-api","asx-lms-tutorial-tags-cpp","entry"],"acf":[],"_links":{"self":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-cpt\/8466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-cpt"}],"about":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/types\/asx-lms-tutorial-cpt"}],"version-history":[{"count":0,"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-cpt\/8466\/revisions"}],"wp:attachment":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/media?parent=8466"}],"wp:term":[{"taxonomy":"asx-lms-tutorial-categories","embeddable":true,"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-categories?post=8466"},{"taxonomy":"asx-lms-tutorial-tags","embeddable":true,"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-tags?post=8466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}