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


C++ Hashtable::put方法代码示例

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


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

示例1: connect

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: 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

示例3: Hashtable

const Hashtable*
LocaleUtility::getAvailableLocaleNames(const UnicodeString& bundleID)
{
    // LocaleUtility_cache is a hash-of-hashes.  The top-level keys
    // are path strings ('bundleID') passed to
    // ures_openAvailableLocales.  The top-level values are
    // second-level hashes.  The second-level keys are result strings
    // from ures_openAvailableLocales.  The second-level values are
    // garbage ((void*)1 or other random pointer).

    UErrorCode status = U_ZERO_ERROR;
    umtx_initOnce(LocaleUtilityInitOnce, locale_utility_init, status);
    Hashtable *cache = LocaleUtility_cache;
    if (cache == NULL) {
        // Catastrophic failure.
        return NULL;
    }

    Hashtable* htp;
    umtx_lock(NULL);
    htp = (Hashtable*) cache->get(bundleID);
    umtx_unlock(NULL);

    if (htp == NULL) {
        htp = new Hashtable(status);
        if (htp && U_SUCCESS(status)) {
            CharString cbundleID;
            cbundleID.appendInvariantChars(bundleID, status);
            const char* path = cbundleID.isEmpty() ? NULL : cbundleID.data();
            UEnumeration *uenum = ures_openAvailableLocales(path, &status);
            for (;;) {
                const UChar* id = uenum_unext(uenum, NULL, &status);
                if (id == NULL) {
                    break;
                }
                htp->put(UnicodeString(id), (void*)htp, status);
            }
            uenum_close(uenum);
            if (U_FAILURE(status)) {
                delete htp;
                return NULL;
            }
            umtx_lock(NULL);
            Hashtable *t = static_cast<Hashtable *>(cache->get(bundleID));
            if (t != NULL) {
                // Another thread raced through this code, creating the cache entry first.
                // Discard ours and return theirs.
                umtx_unlock(NULL);
                delete htp;
                htp = t;
            } else {
                cache->put(bundleID, (void*)htp, status);
                umtx_unlock(NULL);
            }
        }
    }
    return htp;
}
开发者ID:AaronNGray,项目名称:texlive-libs,代码行数:58,代码来源:locutil.cpp

示例4: createRoom

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

示例5: getSupportedIDs

    const Hashtable* getSupportedIDs(UErrorCode& status) const 
    {
        if (supportedIDs == NULL) {
            Hashtable* table = new Hashtable();
            table->put(UnicodeString(californio), (void*)table, status);
            table->put(UnicodeString(valley), (void*)table, status);
            table->put(UnicodeString(surfer), (void*)table, status);
            table->put(UnicodeString(geek), (void*)table, status);

            // not necessarily atomic, but this is a test...
            supportedIDs = table;
        }
        return supportedIDs;
    }
开发者ID:ACSOP,项目名称:android_external_icu4c,代码行数:14,代码来源:icusvtst.cpp

示例6: rhom_method_name_isreserved

bool rhom_method_name_isreserved(const String& strName)
{
    static Hashtable<String,int> reserved_names;
    if ( reserved_names.size() == 0 )
    {
        reserved_names.put("object",1);
        reserved_names.put("source_id",1);
        reserved_names.put("update_type",1);
        reserved_names.put("attrib_type",1);
        reserved_names.put("set_notification",1);
        reserved_names.put("clear_notification",1);
    }

    return reserved_names.get(strName) != 0;
}
开发者ID:svnee,项目名称:rhodes,代码行数:15,代码来源:SyncClient.cpp

示例7: updateVisibleIDs

 virtual void updateVisibleIDs(Hashtable& result, UErrorCode& status) const
 {
   if (U_SUCCESS(status)) {
     const UnicodeString& id = fID;
     result.put(id, (void*)this, status);
   }
 }
开发者ID:gitpan,项目名称:ponie,代码行数:7,代码来源:calendar.cpp

示例8: updateVisibleIDs

 void updateVisibleIDs(Hashtable& result, UErrorCode& status) const {
     if (U_SUCCESS(_status)) {
         for (int32_t i = 0; i < _ids.size(); ++i) {
             result.put(*(UnicodeString*)_ids[i], (void*)this, status);
         }
     }
 }
开发者ID:ACSOP,项目名称:android_external_icu4c,代码行数:7,代码来源:icusvtst.cpp

示例9: 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

示例10: setLocalPlayerPos

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

示例11: stateToProps

Hashtable Game::stateToProps(bool turnPass)
{
	const int BUF_SIZE = 20; // 1 int with some prefix
	char buf[BUF_SIZE]; 
	Hashtable props;
	
    for(int i = 0;i < TILE_COUNT;++i)
	{		
		if(tiles[i])
		{
			sprintf(buf, "%d", i);
			props.put(buf, tiles[i]);
		}
	}
	props.put("flips", flippedTiles, 2);
    props.put("pt", nextTurnPlayer);
    props.put("t#", turnNumber);
	sprintf(buf, "pt%d", myActorNr());
	props.put(buf, myPoints); // we always only save "our" points. this will not affect the opponent's score.
	if(abandoned)
		props.put("abandoned", abandoned);
	if(turnPass)
		props.put(PROP_TURN, lbl->getNextPlayer(nextTurnPlayer));
				
	return props;
}
开发者ID:Dezlan,项目名称:EchoBlade,代码行数:26,代码来源:Game.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:

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

示例14: main

int main(void)
{
	Hashtable *x = new Hashtable();
	char *hola = "Hola";
	x->put(hola, 1);
	cout << (*x)[hola];



	return(0);
}
开发者ID:rralcala,项目名称:random-scripts,代码行数:11,代码来源:hashtable.cpp

示例15:

void
SimpleLocaleKeyFactory::updateVisibleIDs(Hashtable& result, UErrorCode& status) const
{
    if (U_SUCCESS(status)) {
        if (_coverage & 0x1) {
            result.remove(_id);
        } else {
            result.put(_id, (void*)this, status);
        }
    }
}
开发者ID:MoonchildProductions,项目名称:Pale-Moon,代码行数:11,代码来源:servslkf.cpp


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