本文整理汇总了C++中boost::unordered_map::end方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_map::end方法的具体用法?C++ unordered_map::end怎么用?C++ unordered_map::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::unordered_map
的用法示例。
在下文中一共展示了unordered_map::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read
void Graph::read(const char * fn) {
std::ifstream inf (fn);
std::string line;
int n;
node_number = 0;
std::vector<int> tmp;
while (std::getline(inf, line)) {
read_line(line, &tmp);
if ( tmp.size() == 2 ) {
if( node_order.find(tmp.at(0)) == node_order.end() ) {
node_order[tmp.at(0)] = node_number;
node_number++;
};
if( node_order.find(tmp.at(1)) == node_order.end() ) {
node_order[tmp.at(1)] = node_number;
node_number++;
};
};
tmp.clear();
};
nodes.resize(node_number);
times.resize(node_number);
visited.insert(visited.begin(), node_number, false);
inf.clear();
inf.seekg(0);
while (std::getline(inf, line)) {
read_line(line, &tmp);
if ( tmp.size() == 2 ) {
nodes.at(node_order[tmp.at(1)]).add_reverse_edge(node_order[tmp.at(0)]);
nodes.at(node_order[tmp.at(0)]).add_edge(node_order[tmp.at(1)]);
};
tmp.clear();
};
node_order.clear();
};
示例2: processPickups
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();
}
}
示例3: if
static double
score2(const boost::unordered_map<int, double> &m0,
const boost::unordered_map<int, double> &m1)
{
int tmp = 0;
auto i0 = m0.begin();
auto i1 = m1.begin();
while (i0 != m0.end() && i1 != m1.end()) {
if (i0->first < i1->first) ++i0;
else if (i0->first > i1->first) ++i1;
else ++tmp, ++i0, ++i1;
}
return m0.size() + m1.size() - tmp;
}
示例4: count
size_t count(std::string const& x) const {
auto iter = counts.find(x);
if (iter != counts.end()) {
return iter->second;
}
return 0;
}
示例5: find_sum
bool TwoSum::find_sum(long int target) {
long int bucket;
for( auto it = numbers_to_check.begin(); it != numbers_to_check.end(); it++ ) {
if( numbers.find((*it) - target) == numbers.end() ) { continue; };
bucket = numbers.bucket( (*it) - target );
for(auto it_local = numbers.begin(bucket); it_local != numbers.end(bucket); ++it_local) {
if ( ( it_local->first + target ) != (*it) ) { continue; };
if ( it_local->first != target || (it_local->first == target && multi_numbers.find(target) != multi_numbers.end()) ) {
std::cout << target << " + " << it_local->first << " = " << (*it) << " ( " << target + it_local->first << std::endl;
numbers_to_check.erase(it);
return true;
};
};
};
return false;
};
示例6: humanAccountID
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)));
}
}
示例7: 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;
}
示例8: 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;
}
示例9: dataPropertyFromMessage
DataProperty MessageConversions::dataPropertyFromMessage(const
semantic_map_msgs::DataProperty& message, boost::unordered_map<
std::string, Entity>& entities) const {
boost::unordered_map<std::string, Entity>::iterator it = entities.
find(message.subject);
if ((it == entities.end()) || !it->second.isValid())
throw ConversionFailed("Entity with identifier ["+
message.subject+"] is undefined.");
if (message.value_type == semantic_map_msgs::DataProperty::
VALUE_TYPE_STRING)
return it->second.addProperty(message.id, message.value);
else if (message.value_type == semantic_map_msgs::DataProperty::
VALUE_TYPE_BOOL)
return it->second.addProperty(message.id, boost::lexical_cast<bool>(
message.value));
else if (message.value_type == semantic_map_msgs::DataProperty::
VALUE_TYPE_FLOAT)
return it->second.addProperty(message.id, boost::lexical_cast<double>(
message.value));
else if (message.value_type == semantic_map_msgs::DataProperty::
VALUE_TYPE_INT)
return it->second.addProperty(message.id, boost::lexical_cast<int>(
message.value));
else
return DataProperty();
}
示例10: 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;
}
示例11: 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;
}
示例12: operator
bool operator()(boost::any & x) {
boost::unordered_map<boost::reference_wrapper<std::type_info const>, boost::function<void(boost::any&)>, type_info_hash, equal_ref>::iterator it = fs.find(boost::ref(x.type()));
if (it != fs.end()) {
it->second(x);
return true;
} else {
return false;
}
}
示例13: 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;
}
示例14: 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;
}
示例15: objectPropertyFromMessage
ObjectProperty MessageConversions::objectPropertyFromMessage(const
semantic_map_msgs::ObjectProperty& message, boost::unordered_map<
std::string, Entity>& entities) const {
boost::unordered_map<std::string, Entity>::iterator it = entities.
find(message.subject);
if ((it == entities.end()) || !it->second.isValid())
throw ConversionFailed("Entity with identifier ["+
message.subject+"] is undefined.");
boost::unordered_map<std::string, Entity>::iterator jt = entities.
find(message.object);
if ((jt == entities.end()) || !jt->second.isValid())
throw ConversionFailed("Entity with identifier ["+
message.object+"] is undefined.");
return it->second.addProperty(message.id, jt->second);
}