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


C++ boost::unordered_map类代码示例

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


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

示例1: set

void IndexingVariables::set(
    boost::unordered_map<std::string, boost::shared_ptr<ArrayStorage> > as,
    int offset) {
  hm.clear();
  hm.insert(as.begin(), as.end());
  this->offset = offset;
}
开发者ID:celaoforever,项目名称:SHEsisPlus,代码行数:7,代码来源:IndexingVariables.cpp

示例2: slotObjectsSelected

void IfcTreeWidget::slotObjectsSelected( boost::unordered_map<int, shared_ptr<IfcPPEntity> >& map )
{
	if( m_block_selection_signals )
	{
		return;
	}

	if( map.size() < 1 )
	{
		return;
	}

	// take the first object from map and highlight it
	shared_ptr<IfcPPEntity> object = (*(map.begin())).second;
	int selected_id = object->m_id;

	for( int i=0; i<topLevelItemCount(); ++i )
	{
		QTreeWidgetItem* toplevel_item = topLevelItem( i );
		QTreeWidgetItem* selected_item = ViewerUtil::findItemByIfcId( toplevel_item, selected_id );
		if( selected_item != 0 )
		{
			blockSignals(true);
			m_block_selection_signals = true;
			setCurrentItem( selected_item, 1, QItemSelectionModel::SelectCurrent );
			blockSignals(false);
			m_block_selection_signals = false;
			break;
		}
	}
}
开发者ID:IfcGitHub,项目名称:ifcplusplus,代码行数:31,代码来源:IfcTreeWidget.cpp

示例3: name

wcs Symbol::name() const {
    boost::unordered_map<sym, wcs>::const_iterator
    iter = names.find(this);
    if (iter != names.end())
        return iter->second;
    return 0;
}
开发者ID:hyln9,项目名称:nV,代码行数:7,代码来源:var.cpp

示例4: switch

std::string RippleAddress::humanAccountID () const
{
    switch (nVersion)
    {
    case VER_NONE:
        throw std::runtime_error ("unset source - humanAccountID");

    case VER_ACCOUNT_ID:
    {
        boost::mutex::scoped_lock sl (rncLock);
        boost::unordered_map< Blob , std::string >::iterator it = rncMap.find (vchData);

        if (it != rncMap.end ())
            return it->second;

        if (rncMap.size () > 10000)
            rncMap.clear ();

        return rncMap[vchData] = ToString ();
    }

    case VER_ACCOUNT_PUBLIC:
    {
        RippleAddress   accountID;

        (void) accountID.setAccountID (getAccountID ());

        return accountID.ToString ();
    }

    default:
        throw std::runtime_error (str (boost::format ("bad source: %d") % int (nVersion)));
    }
}
开发者ID:justmoon,项目名称:rippled,代码行数:34,代码来源:ripple_RippleAddress.cpp

示例5: dumpLegendrePolynomialCacheData

//! Dump Legendre polynomial cache data to stream (table and history).
void dumpLegendrePolynomialCacheData( std::ostream& outputStream,
                                      boost::unordered_map< Point, double > cacheTable,
                                      boost::circular_buffer< Point > cacheHistory )
{
    outputStream << "Table:\n";

    for ( boost::unordered_map< Point, double >::iterator iteratorCacheTable = cacheTable.begin( );
          iteratorCacheTable != cacheTable.end( ); iteratorCacheTable++ )
    {
        outputStream << "\t" << writeLegendrePolynomialStructureToString(
                            iteratorCacheTable->first ).c_str( ) << " => "
                     << iteratorCacheTable->second << std::endl;
    }

    outputStream << "History:\n";

    for ( boost::circular_buffer< Point >::iterator iteratorCacheHistory = cacheHistory.begin( );
          iteratorCacheHistory != cacheHistory.end( ); iteratorCacheHistory++ )
    {
        outputStream << "\t"
                     << writeLegendrePolynomialStructureToString( *iteratorCacheHistory ).c_str( )
                     << ", ";
    }

    outputStream << std::endl;
}
开发者ID:kartikkumar,项目名称:tudat-svn-mirror,代码行数:27,代码来源:legendrePolynomials.cpp

示例6: init_pool

	bool dbconn_pool::init_pool(boost::unordered_map<std::string, std::string>& cfg)
	{
		std::vector<std::string> keys;
		{
			keys.push_back("host");
			keys.push_back("userid");
			keys.push_back("passwd");
			keys.push_back("database");
			keys.push_back("port");
			keys.push_back("charset");
			keys.push_back("pool_size");
			keys.push_back("wait_timeout_sec");
		}

		boost::unordered_map<std::string, std::string>::iterator found;
		for (std::size_t i = 0; i < keys.size(); ++i)
		{
			found = cfg.find(keys[i]);
			if (found == cfg.end())
			{
				return false;
			}

			if (keys[i] == "host")
			{
				host = found->second;
			}
			else if (keys[i] == "userid")
			{
				userid = found->second;
			}
			else if (keys[i] == "passwd")
			{
				passwd = found->second;
			}
			else if (keys[i] == "database")
			{
				database = found->second;
			}
			else if (keys[i] == "port")
			{
				port = boost::lexical_cast<unsigned int>(found->second);
			}
			else if (keys[i] == "charset")
			{
				charset = found->second;
			}
			else if (keys[i] == "pool_size")
			{
				pool_size = boost::lexical_cast<std::size_t>(found->second);
			}
			else if (keys[i] == "wait_timeout_sec")
			{
				wait_timeout_sec = boost::lexical_cast<double>(found->second);
			}
		}

		return true;
	}
开发者ID:mnpk,项目名称:waspp,代码行数:59,代码来源:dbconn_pool.cpp

示例7: gini

///Calculates the Gini impurity of a node. The impurity is defined as
///1-sum_j p(j|t)^2
///i.e the 1 minus the sum of the squared probability of observing class j in node t
double CARTTrainer::gini(boost::unordered_map<std::size_t, std::size_t>& countMatrix, std::size_t n){
	double res = 0;
	boost::unordered_map<std::size_t, std::size_t>::iterator it;
	double denominator = n;
	for ( it=countMatrix.begin() ; it != countMatrix.end(); it++ ){
		res += sqr(it->second/denominator);
	}
	return 1-res;
}
开发者ID:jakobht,项目名称:Shark,代码行数:12,代码来源:CARTTrainer.cpp

示例8: buildNameLookupTable

bool buildNameLookupTable(Kompex::SQLiteStatement * stmt,
                          boost::unordered_map<std::string,int32_t> &table_names)
{
    std::string stmt_insert = "INSERT INTO name_lookup";
    stmt_insert += "(name_id,name_lookup) VALUES(@name_id,@name_lookup);";

    try   {
        stmt->BeginTransaction();
        stmt->Sql(stmt_insert);
    }
    catch(Kompex::SQLiteException &exception)   {
        qDebug() << "ERROR: SQLite exception with insert statement:"
                 << QString::fromStdString(exception.GetString());
        return false;
    }

    // keep track of the number of transactions and
    // commit after a certain limit
    size_t transaction_limit=5000;
    size_t transaction_count=0;

    // write name lookup info the database
    boost::unordered_map<std::string,int32_t>::iterator it;
    for(it  = table_names.begin(); it != table_names.end(); ++it)   {
        // prepare sql
        try   {
            //[name_id, name_lookup]
            stmt->BindInt(1,it->second);
            stmt->BindString(2,it->first);
            stmt->Execute();
            stmt->Reset();

            if(transaction_count > transaction_limit)   {
                stmt->FreeQuery();
                stmt->CommitTransaction();

                stmt->BeginTransaction();
                stmt->Sql(stmt_insert);
                transaction_count=0;
            }
            transaction_count++;
        }
        catch(Kompex::SQLiteException &exception)   {
            qDebug() << "ERROR: SQLite exception writing tile data:"
                     << QString::fromStdString(exception.GetString());
            qDebug() << "ERROR: name_id:" << it->second;
            qDebug() << "ERROR: name_lookup:" << QString::fromStdString(it->first);
            return false;
        }
    }

    stmt->FreeQuery();
    stmt->CommitTransaction();

    return true;
}
开发者ID:lanixXx,项目名称:scratch,代码行数:56,代码来源:searchdb_build.cpp

示例9: get_promise

    // finds a promise by ID, returns and unregisters the promise
    inline boost::promise<message_reply*>* get_promise(uint64_t promise_id) {
      boost::unordered_map<uint64_t, boost::promise<message_reply*>* >
          ::iterator iter = promises.find(promise_id);
      if (iter == promises.end()) return NULL;
      else {
        boost::promise<message_reply*>* ret = iter->second;
        promises.erase(iter);
        return ret;
      }

    }
开发者ID:Hannah1999,项目名称:Dato-Core,代码行数:12,代码来源:async_request_socket.hpp

示例10: serialize

		static void serialize(storage_type& s, const boost::unordered_map<T1, T2>& o)
			{
			uint32_t sz = o.size();
			s.serialize(sz);

			for (typename boost::unordered_map<T1,T2>::const_iterator it = o.begin(), it_end = o.end(); it != it_end; ++it)
				{
				s.serialize(it->first);
				s.serialize(it->second);
				}
			}
开发者ID:WantonSoup,项目名称:ufora,代码行数:11,代码来源:BoostContainerSerializers.hpp

示例11: gini

///Calculates the Gini impurity of a node. The impurity is defined as
///1-sum_j p(j|t)^2
///i.e the 1 minus the sum of the squared probability of observing class j in node t
double RFTrainer::gini(boost::unordered_map<std::size_t, std::size_t> & countMatrix, std::size_t n){
	double res = 0;
	boost::unordered_map<std::size_t, std::size_t>::iterator it;
	if(n){
		n = n*n;
		for ( it=countMatrix.begin() ; it != countMatrix.end(); it++ ){
			res += sqr(it->second)/(double)n;
		}
	}
	return 1-res;
}
开发者ID:EQ94,项目名称:Shark,代码行数:14,代码来源:RFTrainer.cpp

示例12: get

var Symbol::get(wcs x) const {
    boost::unordered_map<sym, Context>::const_iterator
    iter = contexts.find(this);
    if (iter != contexts.end()) {
        Context::const_iterator
        iter2 = iter->second.find(reinterpret_cast<uint>(x));
        if (iter2 != iter->second.end())
            return iter2->second;
    }
    return null;
}
开发者ID:hyln9,项目名称:nV,代码行数:11,代码来源:var.cpp

示例13: while

void Streamer::processPickups(Player &player, const std::vector<SharedCell> &cells)
{
	static boost::unordered_map<int, Item::SharedPickup> discoveredPickups;
	for (std::vector<SharedCell>::const_iterator c = cells.begin(); c != cells.end(); ++c)
	{
		for (boost::unordered_map<int, Item::SharedPickup>::const_iterator p = (*c)->pickups.begin(); p != (*c)->pickups.end(); ++p)
		{
			boost::unordered_map<int, Item::SharedPickup>::iterator d = discoveredPickups.find(p->first);
			if (d == discoveredPickups.end())
			{
				if (checkPlayer(p->second->players, player.playerID, p->second->interiors, player.interiorID, p->second->worlds, player.worldID))
				{
					if (boost::geometry::comparable_distance(player.position, p->second->position) <= p->second->streamDistance)
					{
						boost::unordered_map<int, int>::iterator i = internalPickups.find(p->first);
						if (i == internalPickups.end())
						{
							p->second->worldID = !p->second->worlds.empty() ? player.worldID : -1;
						}
						discoveredPickups.insert(*p);
					}
				}
			}
		}
	}
	if (processingFinalPlayer)
	{
		boost::unordered_map<int, int>::iterator i = internalPickups.begin();
		while (i != internalPickups.end())
		{
			boost::unordered_map<int, Item::SharedPickup>::iterator d = discoveredPickups.find(i->first);
			if (d == discoveredPickups.end())
			{
				DestroyPickup(i->second);
				i = internalPickups.erase(i);
			}
			else
			{
				discoveredPickups.erase(d);
				++i;
			}
		}
		for (boost::unordered_map<int, Item::SharedPickup>::iterator d = discoveredPickups.begin(); d != discoveredPickups.end(); ++d)
		{
			if (internalPickups.size() == visiblePickups)
			{
				break;
			}
			int internalID = CreatePickup(d->second->modelID, d->second->type, d->second->position[0], d->second->position[1], d->second->position[2], d->second->worldID);
			if (internalID == INVALID_ALTERNATE_ID)
			{
				break;
			}
			internalPickups.insert(std::make_pair(d->second->pickupID, internalID));
		}
		discoveredPickups.clear();
	}
}
开发者ID:NightHammer1000,项目名称:samp-streamer-plugin,代码行数:58,代码来源:streamer.cpp

示例14: find_label

inline
uint32_t
find_label(uint32_t label, boost::unordered_map<uint32_t, label_info> &labels)
{
        boost::unordered_map<uint32_t, label_info>::iterator it;

        for (it = labels.find(label); label != it->second.m_alias;) {
                label = it->second.m_alias;
                it = labels.find(label);
        }

        return label;
}
开发者ID:ytakano,项目名称:tatsunokuchi-dnn,代码行数:13,代码来源:ccv.cpp

示例15: count

 size_t count(std::string const& x) const {
     auto iter = counts.find(x);
     if (iter != counts.end()) {
         return iter->second;
     }
     return 0;
 }
开发者ID:genome,项目名称:joinx,代码行数:7,代码来源:RefStats.hpp


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