本文整理汇总了C++中std::tr1::unordered_map::end方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_map::end方法的具体用法?C++ unordered_map::end怎么用?C++ unordered_map::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::tr1::unordered_map
的用法示例。
在下文中一共展示了unordered_map::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Problem
Problem
Data::
select(const std::tr1::unordered_map<std::string,int>& pn_map) const
{
uint n=0;
for (uint i=0; i!=labels_.size(); ++i) {
std::tr1::unordered_map<std::string,int>::const_iterator f;
f=pn_map.find(labels_[i]);
if (f!=pn_map.end() && f->second!=0) {
n++;
}
}
if (n==0) return Problem();
std::vector<node_ary> x(n);
std::vector<double> y(n);
n=0;
for (uint i=0; i!=labels_.size(); ++i) {
std::tr1::unordered_map<std::string,int>::const_iterator f;
f=pn_map.find(labels_[i]);
if (f!=pn_map.end()) {
if (f->second>0) {
y[n] = +1;
x[n] = vec_[i];
n++;
} else if (f->second<0) {
y[n] = -1;
x[n] = vec_[i];
n++;
}
}
}
return Problem(x, y);
}
示例2: ReadListGraphEdges
void ReadListGraphEdges(ListGraph &g,int nedges,ifstream & ifile,
#if __cplusplus >= 201103L
std::unordered_map<string,Node> & string2node,
#else
std::tr1::unordered_map<string,Node> & string2node,
#endif
EdgeValueMap &weight)
{
Node u,v;
Edge a;
string nomeu,nomev;
double peso;
for (int i=0;i<nedges;i++) {
// format: <node_u> <node_v> <edge_weight>
ifile >> nomeu; ifile >> nomev; ifile >> peso;
if (ifile.eof())
{cout << "Reached unexpected end of file.\n"; exit(0);}
auto test = string2node.find(nomeu);
if (test == string2node.end()) {cout<<"ERROR: Unknown node: "<<nomeu<<endl;exit(0);}
else u = string2node[nomeu];
test = string2node.find(nomev);
if (test == string2node.end()) {cout<<"ERROR: Unknown node: "<<nomev<<endl;exit(0);}
else v = string2node[nomev];
a = g.addEdge(u,v);
weight[a] = peso;
}
}
示例3: max_distance
uint max_distance(TreeNode* root)
{
if (root == NULL) {
return 0;
}
static std::tr1::unordered_map<void*, uint> cache;
typeof(cache.begin()) it = cache.find(root);
if (it != cache.end()) {
return it->second;
}
uint leftCost = max_distance(root->left);
uint rightCost = max_distance(root->right);
uint leftHeight = height(root->left);
uint rightHeight = height(root->right);
uint childCost = leftCost > rightCost ? leftCost : rightCost;
uint throughRoot = leftHeight + rightHeight + root->cost;
uint ret = childCost > throughRoot ? childCost : throughRoot;
cache.insert(std::make_pair(root, ret));
return ret;
}
示例4: ReadListGraphNodes
// To read list of nodes in the format: <node_name> <double1> <double2>
void ReadListGraphNodes(ListGraph &g,int nnodes,ifstream & ifile,
#if __cplusplus >= 201103L
std::unordered_map<string,Node> & string2node,
#else
std::tr1::unordered_map<string,Node> & string2node,
#endif
NodeStringMap &vname,
NodePosMap &posx,
NodePosMap &posy)
{ string STR; Node u,v; string token;
for (int i=0;i<nnodes;i++) {
getline(ifile,STR);
if (ifile.eof()) {cout<<"Reached unexpected end of file.\n";exit(0);}
while (STR=="") getline(ifile,STR);
{ istringstream ins; // Declare an input string stream.
ins.str(STR); // Specify string to read.
for (int p=0; getline(ins, token, ' ') ; p++) {
if (p==0) { // For example, to read: node_name posx posy
auto test = string2node.find(token);
if (test!=string2node.end()){cout<<"ERROR: Repeated node: "<<token<<endl;exit(0);}
v = g.addNode(); string2node[token] = v; vname[v] = token;
posx[v]=DBL_MAX; posy[v]=DBL_MAX; }
else if (p==1) { posx[v] = atof(token.c_str());}
else if (p==2) { posy[v] = atof(token.c_str());}
}}
}
}
示例5: hookDCCMessage
bool m_dccchat::hookDCCMessage(std::string modName, std::string hookMsg) {
if (moduleTriggers.find(hookMsg) == moduleTriggers.end()) {
moduleTriggers.insert(std::pair<std::string, std::string> (hookMsg, modName));
return true;
}
return false;
}
示例6: get
int get(int key) {
if(key2node.find(key) == key2node.end())
return -1;
// node to front
Node2front(key);
return key2node[key]->value;
}
示例7: onNickChange
void m_dccchat::onNickChange(std::string server, std::string oldNick, std::string newNick) {
std::tr1::unordered_map<std::string, Socket*>::iterator dccIter = activeConnections.find(server + "/" + oldNick);
if (dccIter != activeConnections.end()) {
Socket* thisSocket = dccIter->second;
activeConnections.erase(dccIter);
activeConnections.insert(std::pair<std::string, Socket*> (server + "/" + newNick, thisSocket));
}
}
示例8: unhookDCCSession
void m_dccchat::unhookDCCSession(std::string modName, std::string dccid) {
std::tr1::unordered_map<std::string, std::vector<std::string> >::iterator reportingModIter = reportingModules.find(dccid);
if (reportingModIter == reportingModules.end())
return;
for (unsigned int i = 0; i < reportingModIter->second.size(); i++) {
if (reportingModIter->second[i] == modName)
reportingModIter->second.erase(reportingModIter->second.begin()+i);
}
}
示例9: onUserCTCP
void m_dccchat::onUserCTCP(std::string server, std::string nick, std::string message) {
std::vector<std::string> messageParts = splitBySpace(message);
if (messageParts[0] == "DCC" && messageParts[1] == "CHAT" && messageParts[2] == "chat") {
if (activeConnections.find(server + "/" + nick) == activeConnections.end())
dccConnect(server, nick, messageParts[3], messageParts[4]);
else
sendNotice(server, nick, "You already have an active DCC chat session!");
}
}
示例10: operator
//a[index]=n
//计算a[]的以a[index]为结尾的最长不重复子数组的长度
int operator()(int n,int index){
std::tr1::unordered_map<int,int>::iterator iter=all.find(n);
if(iter==all.end()){
//n没有出现过
all[n]=index;
} else{
start=std::max(start,iter->second);
iter->second=index;
}
return index-start;
}
示例11: set
void set(int key, int value) {
if(key2node.find(key) != key2node.end())
{
// node to front
Node2front(key);
head->value = value;
}
else{
Node * n = new Node(key, value);
key2node[key] = n;
n->next = head;
n->pre = NULL;
if(head != NULL)
head->pre = n;
else
tail = n;
head = n;
// Node * p = head;
// cout << ":";
// while(p!= NULL){
// cout << p->key << " ";
// p = p->next;
// }cout<< " taiL:" << tail->key /*<< " tpre:" << tail->pre->key */<< endl;
// if(key2node.size() > 1)
// cout << "tpre:" << tail->pre->key << endl;
// delete last node
if(key2node.size() > capa)
{
int k = tail->key;
if(tail->pre != NULL){
// cout << "tail pre:" << tail->pre->key << endl;
tail->pre->next = NULL;
tail = tail->pre;
// cout << "tail:" << tail->key << endl;
}
else {
head = tail = NULL;
}
key2node.erase(k);
}
// cout << head->key << head->value << " " <<tail->key << tail->value << endl;
// p = head;
// cout << ":";
// while(p!= NULL){
// cout << p->key << " ";
// p = p->next;
// }cout << endl;
}
}
示例12: suisto_get_since
bool suisto_get_since( std::string stream_name, uint64_t ts, std::vector<entry_t*>& out ){
std::tr1::unordered_map< std::string, Stream >::iterator it;
it = streams.find( stream_name );
if( it == streams.end() ){
return false;
}
out = (it->second).since( ts );
return true;
}
示例13: dotproduct
float dotproduct(const fv_t& fv) {
float m = 0.0;
size_t fv_size = fv.size();
for (size_t i = 0; i < fv_size; i++) {
int key = fv[i].first;
float x_i = fv[i].second;
std::tr1::unordered_map<int, float>::iterator wit = w.find(key);
if (wit != w.end()) {
m += x_i * wit->second;
}
}
return m;
};
示例14: suisto_get_latest
bool suisto_get_latest( std::string stream_name, size_t max_entries, std::vector<entry_t*>& out ){
std::tr1::unordered_map< std::string, Stream >::iterator it;
it = streams.find( stream_name );
if( it == streams.end() ){
return false;
}
out = (it->second).latest( max_entries );
return true;
}
示例15: muladd
void muladd(const fv_t &fv, const int y, float scale) {
for (size_t i = 0; i < fv.size(); i++) {
int key = fv[i].first;
float x_i = fv[i].second;
std::tr1::unordered_map<int, float>::iterator wit = w.find(key);
if (wit != w.end()) {
wit->second += y * x_i * scale;
} else {
w[key] = y * x_i * scale;
}
}
};