本文整理汇总了C++中boost::unordered_map::find方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_map::find方法的具体用法?C++ unordered_map::find怎么用?C++ unordered_map::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::unordered_map
的用法示例。
在下文中一共展示了unordered_map::find方法的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:
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;
}
示例4:
bool LLNetMap::mmenableunmark::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{
LLNetMap *self = mPtr;
BOOL enabled = mPtr->mClosestAgentAtLastRightClick.notNull() && mm_MarkerColors.find(mPtr->mClosestAgentAtLastRightClick) != mm_MarkerColors.end();
self->findControl(userdata["control"].asString())->setValue(enabled);
return true;
}
示例5: 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;
}
示例6: count
size_t count(std::string const& x) const {
auto iter = counts.find(x);
if (iter != counts.end()) {
return iter->second;
}
return 0;
}
示例7: ins_rec
inline bool lru_cache_cab::ins_rec(const bucket * buck, const double & curT, bool newFlow)
{
const container_T::left_iterator iter = cache.left.find(buck);
if (iter == cache.left.end()) // cache miss
{
insert(buck, curT);
if (newFlow)
{
++delay_rec[20];
}
++cache_miss;
return true;
}
else // cache hit
{
cache.right.relocate(cache.right.end(),
cache.project_right(iter));
iter->second = curT;
double delay = curT-buffer_check.find(buck)->second;
if (newFlow)
{
++reuse_count;
if(delay < rtt)
{
assert (delay >= 0);
++delay_rec[int(20*(rtt-delay)/rtt)];
}
}
return false;
}
}
示例8: 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)));
}
}
示例9: 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;
};
示例10: 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;
}
示例11: getIcon
Cairo::RefPtr<Cairo::ImageSurface> getIcon(string path)
{
auto it = stored.find(path);
if (it != stored.end())
return (*it).second;
Cairo::RefPtr<Cairo::ImageSurface> image = Cairo::ImageSurface::create_from_png(path);
stored[path] = image;
return image;
}
示例12: getImage
cairo_surface_t* getImage(string path)
{
auto it = images.find(path);
if (it != images.end())
return (*it).second;
cairo_surface_t* image = cairo_image_surface_create_from_png(path.c_str());
images.insert(std::make_pair(path, image));
return image;
}
示例13: 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;
}
示例14:
// 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;
}
}
示例15: is_legal
// Makes sure that no three points all on an original tile edge
// are triangulated.
bool is_legal(const Point_3& a, const Point_3& b, const Point_3& c,
const boost::unordered_map<Point_3, boost::unordered_set<Segment_3_undirected> >& point2edges)
{
static log4cplus::Logger logger = log4cplus::Logger::getInstance("polygon_utils.is_legal");
LOG4CPLUS_TRACE(logger, "is_legal: " << pp(a) << " " << pp(b) << " " << pp(c));
if (point2edges.find(a) == point2edges.end())
return true;
if (point2edges.find(b) == point2edges.end())
return true;
if (point2edges.find(c) == point2edges.end())
return true;
const boost::unordered_set<Segment_3_undirected>& edgesa = point2edges.find(a)->second;
const boost::unordered_set<Segment_3_undirected>& edgesb = point2edges.find(b)->second;
const boost::unordered_set<Segment_3_undirected>& edgesc = point2edges.find(c)->second;
boost::unordered_set<Segment_3_undirected> edges(set_intersection(edgesa, set_intersection(edgesb, edgesc)));
return edges.empty();
}