• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ HashString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中HashString函数的典型用法代码示例。如果您正苦于以下问题:C++ HashString函数的具体用法?C++ HashString怎么用?C++ HashString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了HashString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: fopen

void JStringServer::ExtractStrings()
{
    FILE* fp = fopen( "strings.txt", "wt" );
    if (!fp)
    {
        return;
    }
    m_Dictionary.clear();

    //  extract text strings
    JObjectIterator it( JCore::s_pInstance );
    JString val, hash;
    while (it)
    {
        JObject* pObj = *it;
        if (pObj->HasName( "system" ))
        {
            it.breadth_next();
            continue;
        }
        ++it;
        bool bRes = pObj->GetProperty( "text", val );
        if (!bRes || val.size() == 0 || val[0] == '#')
        {
            continue;
        }
        if (!HasCyrillics( val.c_str() ))
        {
            continue;
        }
        HashString( val.c_str(), hash );
        JStringDictionary::iterator location = m_Dictionary.find( hash );

        JString taggedHash = "#";
        taggedHash += hash;
        pObj->SetProperty( "text", taggedHash.c_str() );

        if (location != m_Dictionary.end())
        {
            if (val == (*location).second)
            {
                continue;
            }
            assert( false );
        }
        fprintf( fp, "%s %s\n", hash.c_str(), val.c_str() );
        m_Dictionary[hash] = val;
    }
    fclose( fp );

    //  save scripts
    g_pPersistServer->SaveScripts();
}
开发者ID:skopp,项目名称:rush,代码行数:53,代码来源:jstringserver.cpp


示例2: HashString

// Static function
uint CElement::GetTypeHashFromString ( const SString& strTypeName )
{
    // Standard types use unique index upto EElementType::UNKNOWN
    EElementType elementType;
    if ( StringToEnum ( strTypeName, elementType ) )
        return elementType;

    // Custom types use name hash.  TODO: Make it use a unique index instead
    uint uiTypeHash = HashString ( strTypeName );
    uiTypeHash = ( uiTypeHash % 0xFFFFFF00 ) + CElement::UNKNOWN + 1;
    return uiTypeHash;
}
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:13,代码来源:CElement.cpp


示例3: Translate_Dump

//*****************************************************************************
//
//*****************************************************************************
void Translate_Dump(const char *string, bool dump)
{
	if(dump)
	{
		FILE * fh = fopen( "hash.txt", "a" );
		if(fh)
		{
			fprintf( fh,  "%08x,%s\n", HashString(string), string );
			fclose(fh);
		}
	}
}
开发者ID:ThePhoenixRises,项目名称:daedalus,代码行数:15,代码来源:Translate.cpp


示例4: fCookieJar

BUrlContext::BUrlContext()
	: 
	fCookieJar(),
	fAuthenticationMap(NULL)
{
	fAuthenticationMap = new(std::nothrow) BHttpAuthenticationMap();

	// This is the default authentication, used when nothing else is found.
	// The empty string used as a key will match all the domain strings, once
	// we have removed all components.
	fAuthenticationMap->Put(HashString("", 0), new BHttpAuthentication());
}
开发者ID:RAZVOR,项目名称:haiku,代码行数:12,代码来源:UrlContext.cpp


示例5: RebuildLiteralTable

static void
RebuildLiteralTable(
    register LiteralTable *tablePtr)
				/* Local or global table to enlarge. */
{
    LiteralEntry **oldBuckets;
    register LiteralEntry **oldChainPtr, **newChainPtr;
    register LiteralEntry *entryPtr;
    LiteralEntry **bucketPtr;
    const char *bytes;
    int oldSize, count, index, length;

    oldSize = tablePtr->numBuckets;
    oldBuckets = tablePtr->buckets;

    /*
     * Allocate and initialize the new bucket array, and set up hashing
     * constants for new array size.
     */

    tablePtr->numBuckets *= 4;
    tablePtr->buckets = ckalloc(tablePtr->numBuckets * sizeof(LiteralEntry*));
    for (count=tablePtr->numBuckets, newChainPtr=tablePtr->buckets;
	    count>0 ; count--, newChainPtr++) {
	*newChainPtr = NULL;
    }
    tablePtr->rebuildSize *= 4;
    tablePtr->mask = (tablePtr->mask << 2) + 3;

    /*
     * Rehash all of the existing entries into the new bucket array.
     */

    for (oldChainPtr=oldBuckets ; oldSize>0 ; oldSize--,oldChainPtr++) {
	for (entryPtr=*oldChainPtr ; entryPtr!=NULL ; entryPtr=*oldChainPtr) {
	    bytes = TclGetStringFromObj(entryPtr->objPtr, &length);
	    index = (HashString(bytes, length) & tablePtr->mask);

	    *oldChainPtr = entryPtr->nextPtr;
	    bucketPtr = &tablePtr->buckets[index];
	    entryPtr->nextPtr = *bucketPtr;
	    *bucketPtr = entryPtr;
	}
    }

    /*
     * Free up the old bucket array, if it was dynamically allocated.
     */

    if (oldBuckets != tablePtr->staticBuckets) {
	ckfree(oldBuckets);
    }
}
开发者ID:afmayer,项目名称:tcl-tk,代码行数:53,代码来源:tclLiteral.c


示例6: _

//---------------------------- PRIVATE          -----------------------------//
void *wxServerConnectionThread::Entry()
{
	bool valid = true;

	// It's ok to block this thread waiting for data.
	mSocket->SetFlags(wxSOCKET_WAITALL);

	try
	{
		// If we pass the check, but return false, it means we got hit by the
		// site requesting a host check.

		if(false == Cities3DCheck())
		{
            static const wxString stReceivedAHostCheck = _("Received a host check from the site.");
    
			wxRuleEvent event(shNetworkRuleSystemMessage, 
				DataObject(stReceivedAHostCheck, wxDateTime::Now()));
			mHandler->AddPendingEvent(event);

			valid = false;
			goto error;
		}
		VersionCheck();

		ReceiveSpectator();

		SendSpectators();
		SendGame();
		SendRNG();
	}
	catch(const std::exception &e)
	{
		valid = false;

		wxLogDebug(HashString(e.what()).wx_str());
	}

error:
	if(true == valid)
	{
		// This socket is complete and ready for data.
		mSocket->mIsComplete = true;
	}
	else
	{
		mSocket->Destroy();
		mSocket = NULL;
	}

	return NULL;
}
开发者ID:Dangr8,项目名称:Cities3D,代码行数:53,代码来源:ServerConnectionThread.cpp


示例7: ConvertGameRulesToHash

	const uint32 ConvertGameRulesToHash(const char* gameRules)
	{
		if (gameRules && (strlen(gameRules) < 32))
		{
			char lowerRulesName[32];
			NameCRCHelper::MakeLowercase(lowerRulesName, gameRules);
			return HashString(lowerRulesName);
		}
		else
		{
			return 0;
		}
	}
开发者ID:richmondx,项目名称:bare-minimum-cryengine3,代码行数:13,代码来源:GameLobbyData.cpp


示例8: HashString

unsigned long StringHash::Hashed(string lpszString)
{ 
	//不同的字符串三次hash还会碰撞的几率无限接近于不可能
	unsigned long nHash = HashString(lpszString, HASH_OFFSET); 
	unsigned long nHashA = HashString(lpszString, HASH_A); 
	unsigned long nHashB = HashString(lpszString, HASH_B); 
	unsigned long nHashStart = nHash % m_tablelength, 
	nHashPos = nHashStart;

	while ( m_HashIndexTable[nHashPos].bExists) 
	{ 
	if (m_HashIndexTable[nHashPos].nHashA == nHashA && m_HashIndexTable[nHashPos].nHashB == nHashB)
		return nHashPos; 
	else 
		nHashPos = (nHashPos + 1) % m_tablelength;

	if (nHashPos == nHashStart) 
		break; 
	}

	return -1; //没有找到 
}
开发者ID:idovelemon,项目名称:OpenProfiler,代码行数:22,代码来源:StringHash.cpp


示例9: ConvertMapToHash

	const uint32 ConvertMapToHash(const char* mapName)
	{
		if (mapName && (strlen(mapName) < 128))
		{
			char lowerMapName[128];
			NameCRCHelper::MakeLowercase(lowerMapName, mapName);
			return HashString(lowerMapName);
		}
		else
		{
			return 0;
		}
	}
开发者ID:richmondx,项目名称:bare-minimum-cryengine3,代码行数:13,代码来源:GameLobbyData.cpp


示例10: ParseName

DWORD FusionBind::Hash()
{
    DWORD hash = 0;

    // Normalize representation
    if (!m_fParsed)
        ParseName();


    // Hash fields.

    if (m_pAssemblyName)
        hash ^= HashStringA(m_pAssemblyName);
    hash = _rotl(hash, 4);

    hash ^= HashBytes(m_pbPublicKeyOrToken, m_cbPublicKeyOrToken);
    hash = _rotl(hash, 4);
        
    hash ^= m_dwFlags;
    hash = _rotl(hash, 4);

    if (m_CodeInfo.m_pszCodeBase)
        hash ^= HashString(m_CodeInfo.m_pszCodeBase);
    hash = _rotl(hash, 4);

    hash ^= m_context.usMajorVersion;
    hash = _rotl(hash, 8);

    if (m_context.usMajorVersion != (USHORT) -1) {
        hash ^= m_context.usMinorVersion;
        hash = _rotl(hash, 8);
        
        if (m_context.usMinorVersion != (USHORT) -1) {
            hash ^= m_context.usBuildNumber;
            hash = _rotl(hash, 8);
        
            if (m_context.usBuildNumber != (USHORT) -1) {
                hash ^= m_context.usRevisionNumber;
                hash = _rotl(hash, 8);
            }
        }
    }

    if (m_context.szLocale)
        hash ^= HashStringA(m_context.szLocale);
    hash = _rotl(hash, 4);

    hash ^= m_CodeInfo.m_fLoadFromParent;

    return hash;
}
开发者ID:ArildF,项目名称:masters,代码行数:51,代码来源:fusionbind.cpp


示例11: HashString

bool StringHash::Hash(string lpszString)
{  
	const unsigned long HASH_OFFSET = 0, HASH_A = 1, HASH_B = 2;  
	unsigned long nHash = HashString(lpszString, HASH_OFFSET);  
	unsigned long nHashA = HashString(lpszString, HASH_A);  
	unsigned long nHashB = HashString(lpszString, HASH_B);  
	unsigned long nHashStart = nHash % m_tablelength, 
		nHashPos = nHashStart;  

	while ( m_HashIndexTable[nHashPos].bExists)  
	{   
		nHashPos = (nHashPos + 1) % m_tablelength;  
		if (nHashPos == nHashStart)  
		{  
			return false;   
		}  
	}  
	m_HashIndexTable[nHashPos].bExists = true;  
	m_HashIndexTable[nHashPos].nHashA = nHashA;  
	m_HashIndexTable[nHashPos].nHashB = nHashB;  

	return true;  
}  
开发者ID:JakeJesi,项目名称:BloomFilter,代码行数:23,代码来源:StringHash.cpp


示例12: HashString

uint32 Block::fileKey(const string &fileName, const BlockTableEntry &blockTableEntry)
{
	if (fileName.empty())
		throw std::logic_error(_("Never try to get file keys of empty filenames."));

	// Hash the name to get the base key
	uint32 nFileKey = HashString(Mpq::cryptTable(), fileName.c_str(), HashType::FileKey);

	// Offset-adjust the key if necessary
	if (blockTableEntry.flags & Flags::UsesEncryptionKey)
		nFileKey = (nFileKey + blockTableEntry.blockOffset) ^ blockTableEntry.fileSize;

	return nFileKey;
}
开发者ID:CruzR,项目名称:wc3lib,代码行数:14,代码来源:block.cpp


示例13: TESTANDRETURN

HRESULT CeeSectionString::getEmittedStringRef(__in_z LPWSTR target, StringRef *ref)
{
    TESTANDRETURN(ref!=NULL, E_POINTER);
    ULONG hashId = HashString(target) % MaxVirtualEntries;
    ULONG bucketIndex = hashId / MaxRealEntries;

    StringTableEntry *entry;
    entry = findStringInsert(stringTable[bucketIndex], target, hashId);

    if (! entry)
        return E_OUTOFMEMORY;
    *ref = entry->m_offset;
    return S_OK;
}
开发者ID:0-wiz-0,项目名称:coreclr,代码行数:14,代码来源:ceesectionstring.cpp


示例14: resolveTypePrototypes

static void resolveTypePrototypes( void ) {
/*****************************************/

/* adds required protoypes to the protoype section */

    statement   *finger;
    statement   *rc;
    long        len;
    char        *name;
    char        *libname;

    if( !SRU.type_sec ) {
        return;
    }

    finger = SRU.forward_prots;

    /* loop through the chain of prototypes and add them if necessary */
    while( finger ) {
        name = finger->data.sp.name;
        len = strlen( name );

        /* check in hash table for function name */
        if( !FindHashEntry(SRU.type_prots, HashString(name, len), name, len) ) {

            /* add to prototype section */
            rc = insertTypePrototype( finger, SRU.type_sec );
            rc->link = SRU.cpp_prots;
            SRU.cpp_prots = rc;
            rc->keep = TRUE;
            InsertHashValue( SRU.type_prots, rc->data.sp.name,
                             strlen( rc->data.sp.name ), rc );
        }
        finger = finger->link;
    }

    /* generate constructors and destructor prototypes if necessary */
    libname = GetLibName();
    len = max( sizeof( DES_DECL_TEMPLATE ) + strlen( SRU.des_name ),
               sizeof( CONS_DECL_TEMPLATE ) + strlen( SRU.con_name ) );
    name = alloca( len + strlen( libname ) + 1 );
    if( !( SRU.flags & DESTRUCTOR_DEFINED ) ) {
        sprintf( name, DES_DECL_TEMPLATE, SRU.des_name, libname );
        insertStatement( SRU.type_sec, name );
    }
    if( !( SRU.flags & CONSTRUCTOR_DEFINED ) ) {
        sprintf( name, CONS_DECL_TEMPLATE, SRU.con_name, libname );
        insertStatement( SRU.type_sec, name );
    }
}
开发者ID:jossk,项目名称:open-watcom-v2,代码行数:50,代码来源:srusuprt.c


示例15: Ins3Hashmg

///////////////////////////////////////////////////////////
//function: 插入新的元素进入hash表
//parameter:
//author: wuxiaoqi
//time: 2016-3-23
///////////////////////////////////////////////////////////
int Ins3Hashmg(hashtable * HashMg, const char *pmkey, const char * pidkey, int fqv)
{
	int ln;
	const unsigned long HASH_OFFSET = 0, HASH_A = 1, HASH_B = 2;
	unsigned long nHash = HashString(pmkey, HASH_OFFSET);
	unsigned long nHashA = HashString(pmkey, HASH_A);
	unsigned long nHashB = HashString(pmkey, HASH_B);
	unsigned long nHashStart = nHash%DCHASH_SIZE, nHashPos = nHashStart;
	while(((*HashMg)+nHashPos)->bExists)
	{
		nHashPos = (nHashPos + 1)%DCHASH_SIZE;
		if (nHashPos == nHashStart)
			return 0;
	}

	((*HashMg)+nHashPos)->bExists = 1;
	((*HashMg)+nHashPos)->nHashA = nHashA;
	((*HashMg)+nHashPos)->nHashB = nHashB;

    if(pmkey != NULL && *pmkey != 0)
	{
		ln = strlen(pmkey);
		((*HashMg)+nHashPos)->pentityname = (char *)malloc(ln+1);
		strncpy(((*HashMg)+nHashPos)->pentityname, pmkey, ln);
		*(((*HashMg)+nHashPos)->pentityname + ln) = 0;	 
	}
	((*HashMg)+nHashPos)->fqval = fqv;
    ((*HashMg)+nHashPos)->score = 0.0001;
	if(pidkey != NULL && *pidkey != 0)
	{
		ln = strlen(pidkey);
		((*HashMg)+nHashPos)->pidcode = (char *)malloc(ln+1);
		strncpy(((*HashMg)+nHashPos)->pidcode, pidkey, ln);
		*(((*HashMg)+nHashPos)->pidcode + ln) = 0;	 
	}
	return 1;
}
开发者ID:jhz-dongyanan,项目名称:jhz,代码行数:43,代码来源:EntityRecog.cpp


示例16: HashString

    uint64_t BSA::CalcHash(std::string path, std::string ext) {
        uint64_t hash1 = 0;
        uint32_t hash2 = 0;
        uint32_t hash3 = 0;
        const size_t len = path.length();

        if (!path.empty()) {
            hash1 = (uint64_t)(
                    ((uint8_t)path[len - 1])
                    + (len << 16)
                    + ((uint8_t)path[0] << 24)
                );

            if (len > 2) {
                hash1 += ((uint8_t)path[len - 2] << 8);
                if (len > 3)
                    hash2 = HashString(path.substr(1, len - 3));
            }
        }

        if (!ext.empty()) {
            if (ext == ".kf")
                hash1 += 0x80;
            else if (ext == ".nif")
                hash1 += 0x8000;
            else if (ext == ".dds")
                hash1 += 0x8080;
            else if (ext == ".wav")
                hash1 += 0x80000000;

            hash3 = HashString(ext);
        }

        hash2 = hash2 + hash3;
        return ((uint64_t)hash2 << 32) + hash1;
    }
开发者ID:Ethatron,项目名称:libbsa,代码行数:36,代码来源:tes4bsa.cpp


示例17: GetHashTablePos_easy

int GetHashTablePos_easy( har *lpszString, SOMESTRUCTURE *lpTable ) 
//lpszString要在Hash表中查找的字符串,lpTable为存储字符串Hash值的Hash表。
{ 
    int nHash = HashString(lpszString);  //调用上述函数二,返回要查找字符串lpszString的Hash值。
    int nHashPos = nHash % nTableSize; 
    if ( lpTable[nHashPos].bExists  &&  !strcmp( lpTable[nHashPos].pString, lpszString ) ) 
		//如果找到的Hash值在表中存在,且要查找的字符串与表中对应位置的字符串相同
    {  
        return nHashPos;    //则返回上述调用函数二后,找到的Hash值
    } 
    else
    {
        return -1;  
    } 
}
开发者ID:Addision,项目名称:Clibrary,代码行数:15,代码来源:hash.c


示例18: AddSymbol

void AddSymbol(char *Name, int Value)
{
	Symbol sym;

	int hash = HashString(Name);

	if (InSymbolList(hash))
		Error("Symbol '%s' already exists", Name);

	sym.Hash = hash;
	sym.Name = Name;
	sym.Value = Value;

	Symbols.push_back(sym);
}
开发者ID:jnewing,项目名称:MyVm,代码行数:15,代码来源:symbol.cpp


示例19: Execute

	virtual void Execute(const DataObject &object)
	{
		// The current player is now in a blocking action.
        RULE.Execute(shRuleBeginBlockingAction, DataObject(current()));

		wxASSERT(1 <= object.numItems());

		//retrieve the text to put in the MessageUI
		DataObject input(0), output;
		
		const HashString& state = gameData<HashString>(shState);
		if(false == DecideHash(state, input, output))
		{
			wxLogError(
				wxString::Format(wxT("Programmer Error: No State %s in ")
				wxT("RuleRequestInitialRoadSeafarers"), state.cwx_str()));

			return;
		}

		wxASSERT(3 == output.numItems());

		wxString text1 = output.read<wxString>();
		wxString text2 = output.read<wxString>(1);
		HashString logic = HashString::Format(shLogicStringFormat.c_str(),
			output.read<HashString>(2).c_str());
		HashString rule = HashString::Format(shRuleStringFormat.c_str(),
			output.read<HashString>(2).c_str());

		//if this involves ships, do some crazy mojo
		if(TRUE == gameData<wxInt32>(shInitialShip))
		{
			text1 = stPlaceAShip;
			text2 = stWaitingPlaceAShip;

			wxInt32 index = logic.find(shRoad);
			wxASSERT(-1 != index);

			logic.replace(index, 4, shShip);
            logic = HashString(logic.c_str());
		}

		RULE.Execute(shRuleUpdateMessageUI, 
			DataObject(text1, text2));		
		
		RULE.Execute(shRuleLocateInitialRoad, DataObject(
			object.read<wxInt32>(), logic, rule));
	}
开发者ID:Dangr8,项目名称:Cities3D,代码行数:48,代码来源:RuleRequestInitialRoadSeafarers.cpp


示例20: HashString

bool PacaReader::GetResource( const std::string& resourcePath, void* outBuffer, uint32_t outBufferSize )
{
    bool result = false;
    uint32_t pathHash = HashString( resourcePath );
    if ( m_HeaderInfo.find( pathHash ) != m_HeaderInfo.end() )
    {
        const ResoureMetaData& resourceMetaData = m_HeaderInfo.at( pathHash );
        if ( resourceMetaData.ByteSize <= outBufferSize )
        {
            m_InStream.seekg( resourceMetaData.StartIndex );
            m_InStream.read( static_cast<char*>( outBuffer ), resourceMetaData.ByteSize );
            result = true;
        }
    }

    return result;
}
开发者ID:MonzUn,项目名称:BTH_Resource_Manager,代码行数:17,代码来源:PacaReader.cpp



注:本文中的HashString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Hash_Fetch函数代码示例发布时间:2022-05-30
下一篇:
C++ Hash函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap