Open 3D Engine AzCore API Reference  22.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
AZ::NameDictionary Class Referencefinal

#include <NameDictionary.h>

Public Member Functions

 AZ_CLASS_ALLOCATOR (NameDictionary, AZ::OSAllocator, 0)
 AZ_TYPE_INFO (NameDictionary, "{6DBF9DEA-1F65-44DB-977C-65BA9047E869}")
Name MakeName (AZStd::string_view name)
Name FindName (Name::Hash hash) const
 NameDictionary (AZ::u64 maxHashSlots)
void LoadDeferredNames (Name *deferredHead)

Static Public Member Functions

static void Create ()
static void Destroy ()
static bool IsReady ()
static NameDictionaryInstance ()


template<typename T , typename... Args>
constexpr friend auto AZStd::construct_at (T *, Args &&... args) -> AZStd::enable_if_t< AZStd::is_void_v< AZStd::void_t< decltype(new(AZStd::declval< void * >()) T(AZStd::forward< Args >(args)...))>>, T * >
template<typename T >
constexpr friend void AZStd::destroy_at (T *)

Detailed Description

Maintains a list of unique strings for Name objects. The main benefit of the Name system is very fast string equality comparison, because every unique name has a unique ID. The NameDictionary's purpose is to guarantee name IDs do not collide. It also saves memory by removing duplicate strings.

Benchmarks have shown that creating a new Name object can be quite slow when the name doesn't already exist in the NameDictionary, but is comparable to creating an AZStd::string for names that already exist.

Constructor & Destructor Documentation

◆ NameDictionary()

AZ::NameDictionary::NameDictionary ( AZ::u64  maxHashSlots)

Constructs a NameDictionary with a fixed amount of hash slots

maxHashSlotsexclusive max for the hashValue that be calculated. Can be used to generate more hash collisoins @precondition maxHashSlots value are [1, 2^64-1)

Member Function Documentation

◆ FindName()

Name AZ::NameDictionary::FindName ( Name::Hash  hash) const

Search for an existing name in the dictionary by hash.

hashThe key by which to search for the name.
A Name instance. If the hash was not found, the Name will be empty.

◆ LoadDeferredNames()

void AZ::NameDictionary::LoadDeferredNames ( Name deferredHead)

Loads a list of names, starting at a given list head, and ensures they're all created and linked into our list of deferred load names.

◆ MakeName()

Name AZ::NameDictionary::MakeName ( AZStd::string_view  name)

Makes a Name from the provided raw string. If an entry already exists in the dictionary, it is shared. Otherwise, it is added to the internal dictionary.

nameThe name to resolve against the dictionary.
A Name instance holding a dictionary entry associated with the provided raw string.

The documentation for this class was generated from the following file: