7 #ifndef __MUN_GEN_UID_HPP__ 8 #define __MUN_GEN_UID_HPP__ 25 static uint64
GetUid64( std::string host, uint16 port ) {
28 ::snprintf( str,
sizeof(str),
"%s:%d", host.c_str(), port );
29 uint32 len = strlen(str);
32 uint64 base64 = 14695981039346656037U;
34 uint64 prime64 = 1099511628211ULL;
36 uint64 prime64 = 1099511628211LLU;
39 for( uint32 i = 0; i < len; i++ ) {
40 hash = (prime64 * hash) ^ (str[i]);
52 static uint32
GetUid32( std::string host, uint16 port ) {
55 ::snprintf( str,
sizeof(str),
"%s:%d", host.c_str(), port );
56 uint32 len = strlen(str);
59 uint32 base32 = 2166136261U;
60 uint32 prime32 = 16777619U;
62 for( uint32 i = 0; i < len; i++ ) {
63 hash = (prime32 * hash) ^ (str[i]);
static uint64 GetUid64(std::string host, uint16 port)
「ホスト名:ポート番号」の文字列情報から、64bitのハッシュ値を生成する.
Definition: MunGenUid.hpp:25
ユニークIDの生成.
Definition: MunGenUid.hpp:16
static uint32 GetUid32(std::string host, uint16 port)
「ホスト名:ポート番号」の文字列情報から、32bitのハッシュ値を生成する.
Definition: MunGenUid.hpp:52