本文整理汇总了C++中ConstString::hash方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstString::hash方法的具体用法?C++ ConstString::hash怎么用?C++ ConstString::hash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstString
的用法示例。
在下文中一共展示了ConstString::hash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeMaterialHash
uint32_t RenderMaterialManager::makeMaterialHash( const ConstString & _materialName, uint32_t _textureCount, const RenderTextureInterfacePtr * _textures ) const
{
uint32_t material_hash = (uint32_t)_materialName.hash();
for( uint32_t i = 0; i != _textureCount; ++i )
{
uint32_t texture_id = _textures[i]->getId();
material_hash += texture_id + i * 3571;
}
return material_hash;
}
示例2: LOGGER_ERROR
ResourceReferencePtr ResourceManager::createResource( const ConstString & _locale, const ConstString& _category, const ConstString& _group, const ConstString& _name, const ConstString& _type )
{
ResourceReferencePtr resource = this->generateResource( _type );
if( resource == nullptr )
{
LOGGER_ERROR( m_serviceProvider )("ResourceManager createResource: invalid generate resource locale '%s' category '%s' group '%s' name '%s' type '%s'"
, _locale.c_str()
, _category.c_str()
, _group.c_str()
, _name.c_str()
, _type.c_str()
);
return nullptr;
}
resource->setLocale( _locale );
resource->setCategory( _category );
resource->setGroup( _group );
resource->setName( _name );
ResourceEntry entry;
entry.resource = resource;
entry.isLocked = false;
ConstString::hash_type hash = _name.hash();
uint32_t table = (uint32_t)hash % MENGINE_RESOURCE_MANAGER_HASH_SIZE;
TMapResource & resources = m_resources[table];
std::pair<TMapResource::iterator, bool> insert_result = resources.insert( std::make_pair( _name, entry ) );
TResourceCacheKey cache_key = std::make_pair( _category, _group );
TMapResourceCache::iterator it_cache_found = m_resourcesCache.find( cache_key );
if( it_cache_found == m_resourcesCache.end() )
{
TVectorResources new_resources;
it_cache_found = m_resourcesCache.insert( it_cache_found, std::make_pair( cache_key, new_resources ) );
}
TVectorResources & cahce_resources = it_cache_found->second;
cahce_resources.push_back( resource );
if( insert_result.second == false )
{
ResourceEntry & insert_entry = insert_result.first->second;
const ConstString & insert_category = insert_entry.resource->getCategory();
const ConstString & insert_group = insert_entry.resource->getGroup();
TResourceCacheKey remove_cache_key = std::make_pair( insert_category, insert_group );
TMapResourceCache::iterator it_remove_cache_found = m_resourcesCache.find( remove_cache_key );
TVectorResources::iterator it_remove_found = std::remove(
it_remove_cache_found->second.begin(),
it_remove_cache_found->second.end(),
insert_entry.resource );
it_remove_cache_found->second.erase( it_remove_found );
resources[_name] = entry;
}
return resource;
}