本文整理汇总了C++中boost::unordered_map类的典型用法代码示例。如果您正苦于以下问题:C++ unordered_map类的具体用法?C++ unordered_map怎么用?C++ unordered_map使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了unordered_map类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: save
void save(Archive & ar, const boost::unordered_map<T,U> & t, unsigned int version)
{
// write the size
// TODO: should we handle bucket size as well?
typedef typename boost::unordered_map<T, U>::size_type size_type;
typedef typename boost::unordered_map<T,U>::const_iterator const_iterator;
size_type size = t.size();
ar & BOOST_SERIALIZATION_NVP(size);
unsigned int count = 0;
for (const_iterator it = t.begin(); it != t.end(); it++) {
ar & boost::serialization::make_nvp("pair" + count, *it);
count++;
}
}
开发者ID:selmanj,项目名称:repel,代码行数:14,代码来源:boost_serialize_unordered_map.hpp
示例16: img_out
void Task::drawKeypoints(const base::samples::frame::Frame &frame2,
const std::vector<cv::KeyPoint> &keypoints1,
const std::vector<cv::KeyPoint> &keypoints2,
const std::vector<cv::DMatch> &matches,
const boost::unordered_map<boost::uuids::uuid, StereoFeature> &hash)
{
/** Convert Images to opencv **/
cv::Mat img2 = frameHelperLeft.convertToCvMat(frame2);
::cv::Mat img_out(img2);
cv::drawKeypoints (img2, keypoints1, img_out, cv::Scalar(0, 255, 0));//green previous
for (std::vector<cv::DMatch>::const_iterator it= matches.begin(); it!= matches.end(); ++it)
{
cv::Point point1 = keypoints1[it->queryIdx].pt;
cv::Point point2 = keypoints2[it->trainIdx].pt;
//cv::circle(img_out, point1, 3, cv::Scalar(0, 255, 0), 1);// green previous
cv::circle(img_out, point2, 3, cv::Scalar(255, 0, 0), 1);// blue current
cv::line (img_out, point1, point2, cv::Scalar(0, 0, 255)); // red line
}
if (_draw_hash_uuid_features.value())
{
/** Draw hash features **/
for (boost::unordered_map<boost::uuids::uuid, StereoFeature>::const_iterator
it = hash.begin(); it != hash.end(); ++it)
{
/** Only current features but with the hash id and the image frame index in the label **/
if (it->second.img_idx == this->fcurrent_left.img_idx)
{
float red = 255.0 - (255.0/(this->frame_window_hash_size)*(this->ffinal_left.img_idx-it->second.img_idx));
cv::circle(img_out, it->second.keypoint_left.pt, 5, cv::Scalar(0, 0, red), 2);
std::vector<std::string> uuid_tokens = this->split(boost::lexical_cast<std::string>(it->first), '-');
cv::putText(img_out, uuid_tokens[uuid_tokens.size()-1]+"["+boost::lexical_cast<std::string>(it->second.img_idx)+"]",
it->second.keypoint_left.pt, cv::FONT_HERSHEY_COMPLEX_SMALL, 1.0, cv::Scalar(0,0,0), 2.5);
}
}
}
::base::samples::frame::Frame *frame_ptr = this->inter_frame_out.write_access();
frameHelperLeft.copyMatToFrame(img_out, *frame_ptr);
frame_ptr->time = this->frame_pair.time;
this->inter_frame_out.reset(frame_ptr);
_inter_frame_samples_out.write(this->inter_frame_out);
return;
}
开发者ID:jhidalgocarrio,项目名称:perception-orogen-visual_stereo,代码行数:50,代码来源:Task.cpp
示例17: normedHistogram
RealVector CARTTrainer::hist(boost::unordered_map<std::size_t, std::size_t> countMatrix){
//create a normed histogram
std::size_t totalElements = 0;
RealVector normedHistogram(m_maxLabel+1);
normedHistogram.clear();
boost::unordered_map<std::size_t, std::size_t>::iterator it;
for ( it=countMatrix.begin() ; it != countMatrix.end(); it++ ){
normedHistogram(it->first) = it->second;
totalElements += it->second;
}
normedHistogram /= totalElements;
return normedHistogram;
}
开发者ID:jakobht,项目名称:Shark,代码行数:14,代码来源:CARTTrainer.cpp
示例18: hit
static std::pair<int, int>
hit(const boost::unordered_map<int, double> &real,
const boost::unordered_map<int, double> &fake,
double thres = 0.0)
{
int a = 0, b = 0;
for (auto it = fake.cbegin(); it != fake.cend(); ++it) {
if (it->second >= thres) {
++b;
if (real.end() != real.find(it->first))
++a;
}
}
return std::make_pair(a, b);
}
开发者ID:FormatMemory,项目名称:QuerySimulation,代码行数:15,代码来源:main.cpp
示例19: histogram
RealVector RFTrainer::hist(boost::unordered_map<std::size_t, std::size_t> countMatrix){
RealVector histogram(m_maxLabel+1,0.0);
std::size_t totalElements = 0;
boost::unordered_map<std::size_t, std::size_t>::iterator it;
for ( it=countMatrix.begin() ; it != countMatrix.end(); it++ ){
histogram(it->first) = (double)it->second;
totalElements += it->second;
}
histogram /= totalElements;
return histogram;
}
开发者ID:EQ94,项目名称:Shark,代码行数:15,代码来源:RFTrainer.cpp
示例20: buildGraph
void PropertyExpressionEngine::buildGraph(const ExpressionMap & exprs,
boost::unordered_map<int, ObjectIdentifier> & revNodes, DiGraph & g) const
{
boost::unordered_map<ObjectIdentifier, int> nodes;
std::vector<Edge> edges;
// Build data structure for graph
for (ExpressionMap::const_iterator it = exprs.begin(); it != exprs.end(); ++it)
buildGraphStructures(it->first, it->second.expression, nodes, revNodes, edges);
// Create graph
g = DiGraph(revNodes.size());
// Add edges to graph
for (std::vector<Edge>::const_iterator i = edges.begin(); i != edges.end(); ++i)
add_edge(i->first, i->second, g);
// Check for cycles
bool has_cycle = false;
int src = -1;
cycle_detector vis(has_cycle, src);
depth_first_search(g, visitor(vis));
if (has_cycle) {
std::string s = revNodes[src].toString() + " reference creates a cyclic dependency.";
throw Base::Exception(s.c_str());
}
}
开发者ID:Jonham,项目名称:FreeCAD,代码行数:29,代码来源:PropertyExpressionEngine.cpp
注:本文中的boost::unordered_map类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论