Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::NameDictionary Class Referencefinal

#include <NameDictionary.h>

Public Member Functions

 AZ_CLASS_ALLOCATOR (NameDictionary, AZ::OSAllocator)
 
 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 ()
 

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)
explicit

Constructs a NameDictionary with a fixed amount of hash slots

Parameters
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.

Parameters
hashThe key by which to search for the name.
Returns
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.

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

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