当前位置: 首页>>代码示例>>C++>>正文


C++ Hashtable类代码示例

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


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

示例1: LOG

void EventSource::connect()
{

    LOG(TRACE) + "Connecting EventSource: " + m_url;

    ASSERT(m_state == CONNECTING);
    ASSERT(m_pNetRequest == 0);

    Hashtable<String,String> headers;

    headers.put("Accept","text/event-stream");
    headers.put("Cache-Control", "no-cache");
    if (!m_lastEventId.empty())
        headers.put("Last-Event-ID", m_lastEventId);

    {    
      common::CMutexLock lock(m_mxReqAccess);
    
      m_pNetRequest = new net::CAsyncNetRequest();
   
      m_pNetRequest->setMethod("GET");
      m_pNetRequest->setUrl(m_url);
      m_pNetRequest->setHeaders(headers);
      m_pNetRequest->setCallback(this);

      new common::CRhoCallInThread<net::CAsyncNetRequest>( m_pNetRequest );
  }

}
开发者ID:Gaurav2728,项目名称:rhodes,代码行数:29,代码来源:EventSource.cpp

示例2: db_insert_into_table

void db_insert_into_table( db::CDBAdapter& db, const String& table, Hashtable<String, String>& hashObject, const char* excludes = null)
{
    String cols = "";
    String quests = "";
    Vector<String> vals;

    for ( Hashtable<String,String>::iterator it = hashObject.begin();  it != hashObject.end(); ++it )
    {
        String key = it->first;
        String val  = it->second;

        if ( excludes && key.compare(excludes) == 0 )
            continue;

        if (cols.length() > 0)
        {
            cols += ',';
            quests += ',';
        }
    
        cols += key;
        quests += '?';
        vals.addElement( val );
    }

    String query = "insert into " + table + "(" + cols + ") values (" + quests + ")";

    db.executeSQLEx(query.c_str(), vals);
}
开发者ID:svnee,项目名称:rhodes,代码行数:29,代码来源:SyncClient.cpp

示例3: roomProps

		OperationRequestParameters Peer::opCreateRoomImplementation(const JString& gameID, bool isVisible, bool isOpen, nByte maxPlayers, const Hashtable& customRoomProperties, const Hashtable& customLocalPlayerProperties, const JVector<JString>& propsListedInLobby)
		{
			OperationRequestParameters op;
			if(gameID.length())
				op.put(ParameterCode::ROOM_NAME, ValueObject<JString>(gameID));

			Hashtable roomProps(Utils::stripToCustomProperties(customRoomProperties));
			if(!isOpen)
				roomProps.put(Properties::Room::IS_OPEN, isOpen);
			if(!isVisible)
				roomProps.put(Properties::Room::IS_VISIBLE, isVisible);
			if(maxPlayers)
				roomProps.put(Properties::Room::MAX_PLAYERS, maxPlayers);
			JString* propsListedInLobbyArr = allocateArray<JString>(propsListedInLobby.getSize());
			for(unsigned int i=0; i<propsListedInLobby.getSize(); ++i)
				propsListedInLobbyArr[i] = propsListedInLobby[i];
			roomProps.put(Properties::Room::PROPS_LISTED_IN_LOBBY, propsListedInLobbyArr, propsListedInLobby.getSize());
			deallocateArray(propsListedInLobbyArr);
			op.put(ParameterCode::ROOM_PROPERTIES, ValueObject<Hashtable>(roomProps));

			Hashtable playerProperties = Utils::stripToCustomProperties(customLocalPlayerProperties);
			if(playerProperties.getSize())
				op.put(ParameterCode::PLAYER_PROPERTIES, ValueObject<Hashtable>(playerProperties));
			op.put(ParameterCode::BROADCAST, ValueObject<bool>(true));
			op.put(ParameterCode::CLEANUP_CACHE_ON_LEAVE, ValueObject<bool>(true));
			return op;
		}
开发者ID:kaznog,项目名称:t09,代码行数:27,代码来源:Peer.cpp

示例4: while

UnicodeString& TransliteratorRegistry::getAvailableVariant(int32_t index,
                                                           const UnicodeString& source,
                                                           const UnicodeString& target,
                                                           UnicodeString& result) const {
    Hashtable *targets = (Hashtable*) specDAG.get(source);
    if (targets == 0) {
        result.truncate(0); // invalid source
        return result;
    }
    uint32_t varMask = targets->geti(target);
    int32_t varCount = 0;
    int32_t varListIndex = 0;
    while (varMask > 0) {
        if (varMask & 1) {
            if (varCount == index) {
                UnicodeString *v = (UnicodeString*) variantList.elementAt(varListIndex);
                if (v != NULL) {
                    result = *v;
                    return result;
                }
                break;
            }
            varCount++;
        }
        varMask >>= 1;
        varListIndex++;
    }
    result.truncate(0); // invalid target or index
    return result;
}
开发者ID:AlexanderPankiv,项目名称:node,代码行数:30,代码来源:transreg.cpp

示例5: getGroupByPos

bool LoadBalancingListener::setLocalPlayerPos(int x, int y)
{
	if(x >= 0 && x < mGridSize && y >= 0 && y < mGridSize) 
	{
		int prevGroup = getGroupByPos();
		mLocalPlayer.x = x;
		mLocalPlayer.y = y;
		if(prevGroup != getGroupByPos()) 
			updateGroups();
		Hashtable data;
		nByte coords[] = {static_cast<nByte>(mLocalPlayer.x), static_cast<nByte>(mLocalPlayer.y)};
		data.put((nByte)1, coords, 2);

		if(mSendGroup)
			mpLbc->opRaiseEvent(false, data, 2, 0, 0, 0, 0, 0, mSendGroup);
		else
		{
			if(mUseGroups)
				mpLbc->opRaiseEvent(false, data, 2, 0, 0, 0, 0, 0, getGroupByPos());
			else
				mpLbc->opRaiseEvent(false, data, 2);
		}
		mpView->changePlayerPos(mLcalPlayerNr, mLocalPlayer.x, mLocalPlayer.y);
		return true;
	}
	else 
		return false;
}
开发者ID:Dezlan,项目名称:EchoBlade,代码行数:28,代码来源:LoadBalancingListener.cpp

示例6: removeSTV

/**
 * Remove a source-target/variant from the specDAG.
 */
void TransliteratorRegistry::removeSTV(const UnicodeString& source,
                                       const UnicodeString& target,
                                       const UnicodeString& variant) {
    // assert(source.length() > 0);
    // assert(target.length() > 0);
    UErrorCode status = U_ZERO_ERROR;
    Hashtable *targets = (Hashtable*) specDAG.get(source);
    if (targets == NULL) {
        return; // should never happen for valid s-t/v
    }
    uint32_t varMask = targets->geti(target);
    if (varMask == 0) {
        return; // should never happen for valid s-t/v
    }
    int32_t variantListIndex = variantList.indexOf((void*) &variant, 0);
    if (variantListIndex < 0) {
        return; // should never happen for valid s-t/v
    }
    int32_t remMask = 1 << variantListIndex;
    varMask &= (~remMask);
    if (varMask != 0) {
        targets->puti(target, varMask, status);
    } else {
        targets->remove(target); // should delete variants
        if (targets->count() == 0) {
            specDAG.remove(source); // should delete targets
        }
    }
}
开发者ID:AlexanderPankiv,项目名称:node,代码行数:32,代码来源:transreg.cpp

示例7: TEST_Construction

void TEST_Construction() {
  Hashtable h;
  h.resize(26);
  Item a = {"a", 'a'};
  Item b = {"b", 'b'};
  Item c = {"c", 'c'};
  Item abcd1234 = {"abcd1234", 99};
  Item abcdefghijklmnopqrstuv = {"abcdefghijklmnopqrstuv", 101};

  insert(&h, &a);
  ASSERT_EQ(h[simple_hash::hash("a") % h.size()]->value,'a');
  insert(&h, &b);
  ASSERT_EQ(h[simple_hash::hash("b") % h.size()]->value,'b');
  insert(&h, &c);
  ASSERT_EQ(h[simple_hash::hash("c") % h.size()]->value,'c');
  insert(&h, &abcd1234);
  ASSERT_EQ(h[simple_hash::hash("abcd1234") % h.size()]->value, 'a');
  ASSERT_EQ(h[simple_hash::hash("abcd1234") % h.size() + 1]->value, 'b');
  ASSERT_EQ(h[simple_hash::hash("abcd1234") % h.size() + 2]->value, 'c');
  ASSERT_EQ(h[simple_hash::hash("abcd1234") % h.size() + 3]->value, 99);
  insert(&h, &abcdefghijklmnopqrstuv);
  ASSERT_EQ(h[simple_hash::hash("abcd1234") % h.size()]->value, 'a');
  ASSERT_EQ(h[simple_hash::hash("abcd1234") % h.size() + 1]->value, 'b');
  ASSERT_EQ(h[simple_hash::hash("abcd1234") % h.size() + 2]->value, 'c');
  ASSERT_EQ(h[simple_hash::hash("abcd1234") % h.size() + 3]->value, 99);
  ASSERT_EQ(h[simple_hash::hash("abcdefghijklmnopqrstuv") % h.size() + 4]->value, 101);
}
开发者ID:ProgrammingProblems,项目名称:Volume1,代码行数:27,代码来源:main.cpp

示例8: getSupportedIDs

void
LocaleKeyFactory::updateVisibleIDs(Hashtable & result, UErrorCode & status) const
{
	const Hashtable * supported = getSupportedIDs(status);
	if (supported)
	{
		UBool visible = (_coverage & 0x1) == 0;

		const UHashElement * elem = NULL;
		int32_t pos = 0;
		while ((elem = supported->nextElement(pos)) != NULL)
		{
			const UnicodeString & id = *((const UnicodeString *)elem->key.pointer);
			if (!visible)
			{
				result.remove(id);
			}
			else
			{
				result.put(id, (void *)this, status); // this is dummy non-void marker used for set semantics
				if (U_FAILURE(status))
				{
					break;
				}
			}
		}
	}
}
开发者ID:Botyto,项目名称:Core,代码行数:28,代码来源:servlkf.cpp

示例9: curlHeaderCallback

static size_t curlHeaderCallback(void *ptr, size_t size, size_t nmemb, void *opaque)
{
    Hashtable<String,String>* pHeaders = (Hashtable<String,String>*)opaque;
    size_t nBytes = size*nmemb;
    String strHeader((const char *)ptr, nBytes);
    RAWTRACE1("Received header: %s", strHeader.c_str());
    
    int nSep = strHeader.find(':');
    if (nSep > 0 )
    {		
        String strName = String_trim(strHeader.substr(0, nSep));
        String lName;
        std::transform(strName.begin(), strName.end(), std::back_inserter(lName), &::tolower);
        
        String strValue = String_trim(strHeader.substr(nSep+1, strHeader.length() - (nSep+3) ));
        
        if ( pHeaders->containsKey(lName) )
        {
            strValue += ";" + pHeaders->get( lName );
            pHeaders->put( lName, strValue );
        }
        else
            pHeaders->put(lName, strValue);
    }
    
    return nBytes;
}
开发者ID:3runo5ouza,项目名称:rhodes,代码行数:27,代码来源:CURLNetRequest.cpp

示例10: getPluralRules

void
TimeUnitFormat::checkConsistency(UTimeUnitFormatStyle style, const char* key, UErrorCode& err) {
    if (U_FAILURE(err)) {
        return;
    }
    // there should be patterns for each plural rule in each time unit.
    // For each time unit,
    //     for each plural rule, following is unit pattern fall-back rule:
    //         ( for example: "one" hour )
    //         look for its unit pattern in its locale tree.
    //         if pattern is not found in its own locale, such as de_DE,
    //         look for the pattern in its parent, such as de,
    //         keep looking till found or till root.
    //         if the pattern is not found in root either,
    //         fallback to plural count "other",
    //         look for the pattern of "other" in the locale tree:
    //         "de_DE" to "de" to "root".
    //         If not found, fall back to value of
    //         static variable DEFAULT_PATTERN_FOR_xxx, such as "{0} h".
    //
    // Following is consistency check to create pattern for each
    // plural rule in each time unit using above fall-back rule.
    //
    StringEnumeration* keywords = getPluralRules().getKeywords(err);
    if (U_SUCCESS(err)) {
        const UnicodeString* pluralCount;
        while ((pluralCount = keywords->snext(err)) != NULL) {
            if ( U_SUCCESS(err) ) {
                for (int32_t i = 0; i < TimeUnit::UTIMEUNIT_FIELD_COUNT; ++i) {
                    // for each time unit,
                    // get all the patterns for each plural rule in this locale.
                    Hashtable* countToPatterns = fTimeUnitToCountToPatterns[i];
                    if ( countToPatterns == NULL ) {
                        countToPatterns = initHash(err);
                        if (U_FAILURE(err)) {
                            delete countToPatterns;
                            return;
                        }
                        fTimeUnitToCountToPatterns[i] = countToPatterns;
                    }
                    MessageFormat** formatters = (MessageFormat**)countToPatterns->get(*pluralCount);
                    if( formatters == NULL || formatters[style] == NULL ) {
                        // look through parents
                        const char* localeName = getLocaleID(err);
                        CharString pluralCountChars;
                        pluralCountChars.appendInvariantChars(*pluralCount, err);
                        searchInLocaleChain(style, key, localeName,
                                            (TimeUnit::UTimeUnitFields)i,
                                            *pluralCount, pluralCountChars.data(),
                                            countToPatterns, err);
                    }
                }
            }
        }
    }
    delete keywords;
}
开发者ID:GuillaumeSmaha,项目名称:stringi,代码行数:57,代码来源:tmutfmt.cpp

示例11:

void 
SimpleFactory::updateVisibleIDs(Hashtable& result, UErrorCode& status) const 
{
    if (_visible) {
        result.put(_id, (void*)this, status); // cast away const
    } else {
        result.remove(_id);
    }
}
开发者ID:icu-project,项目名称:icu4c,代码行数:9,代码来源:serv.cpp

示例12: setName

		void MutablePlayer::setName(const JString& name)
		{
			if(mName != name)
			{
				Hashtable properties;
				properties.put(static_cast<nByte>(Properties::Player::PLAYERNAME), mName=name);
				mLoadBalancingClient->opSetPropertiesOfPlayer(mNumber, properties);
			}
		}
开发者ID:devromaue4,项目名称:Programming,代码行数:9,代码来源:MutablePlayer.cpp

示例13: sprintf

void LoadBalancingListener::createRoom() 
{
	char name[16];
	sprintf(name, "native-%d",rand() % 100);
	Hashtable props;
	props.put("s", mGridSize);
	props.put("m", mMap);
	mpLbc->opCreateRoom(name, true, true, 0, props);
	mpView->info( "Creating room %s", name );
}
开发者ID:Dezlan,项目名称:EchoBlade,代码行数:10,代码来源:LoadBalancingListener.cpp

示例14: countAvailableVariants

int32_t TransliteratorRegistry::countAvailableVariants(const UnicodeString& source,
                                                       const UnicodeString& target) const {
    Hashtable *targets = (Hashtable*) specDAG.get(source);
    if (targets == 0) {
        return 0;
    }
    UVector *variants = (UVector*) targets->get(target);
    // variants may be 0 if the source/target are invalid
    return (variants == 0) ? 0 : variants->size();
}
开发者ID:GuillaumeSmaha,项目名称:stringi,代码行数:10,代码来源:transreg.cpp

示例15: printGlobalMetadata

void printGlobalMetadata() {
  cout << endl;
  cout << "Reading global metadata" << endl;
  Hashtable meta = reader->getGlobalMetadata();
  StringArray keys = MetadataTools::keys(meta);
  for (int i=0; i<keys.length(); i++) {
    Object value = meta.get(keys[i]);
    cout << keys[i] << ": " << value << endl;
  }
}
开发者ID:CellH5,项目名称:bioformats,代码行数:10,代码来源:showinf.cpp


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