本文整理汇总了C++中hash_map::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ hash_map::begin方法的具体用法?C++ hash_map::begin怎么用?C++ hash_map::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hash_map
的用法示例。
在下文中一共展示了hash_map::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void init(){
string ff;
hash_map<int, string> user;
ifstream fin("in");
int k = 0;
while (true){
if (fin.eof())break;
fin >> ff;
vector<string> tmp;
split(ff, ",", tmp);
hash_map<string, vector<Node>*>::iterator it = mylog.find(tmp[0]);
if (it == mylog.end()){
vector<Node>* newVector = new vector<Node>();
mylog[tmp[0]] = newVector;
user[k++] = tmp[0];
}
mylog[tmp[0]]->push_back(Node(tmp[0], tmp[1], tmp[2], tmp[3]));
}
fin.close();
hash_map<string, vector<Node>*>::iterator it;
for (it = mylog.begin(); it != mylog.end(); it++){
vector<string> v;
net[it->first] = v;
for (int i = 0; i < 5; i++){
int ran = rand() % 9999;
net[it->first].push_back(user[ran]);
}
}
}
示例2: merge_recommended_queries
void query_recommender::merge_recommended_queries(std::multimap<double,std::string,std::less<double> > &related_queries,
hash_map<const char*,double,hash<const char*>,eqstr> &update)
{
hash_map<const char*,double,hash<const char*>,eqstr>::iterator hit;
std::multimap<double,std::string,std::less<double> >::iterator mit
= related_queries.begin();
while(mit!=related_queries.end())
{
std::string rquery = (*mit).second;
if ((hit = update.find(rquery.c_str()))!=update.end())
{
(*hit).second = std::min((*mit).first,(*hit).second);
std::multimap<double,std::string,std::less<double> >::iterator mit2 = mit;
++mit;
related_queries.erase(mit2);
}
else ++mit;
}
hit = update.begin();
hash_map<const char*,double,hash<const char*>,eqstr>::iterator chit;
while(hit!=update.end())
{
related_queries.insert(std::pair<double,std::string>((*hit).second,std::string((*hit).first)));
chit = hit;
++hit;
free_const((*chit).first);
}
}
示例3: replace
void replace(string user){
double min = 1000;
int minI = -1;
for (int i = 0; i < net[user].size(); i++){
double tmp = sim(user, net[user][i]);
if (min > tmp){
min = tmp;
minI = i;
}
}
double max = -10000;
string kk;
hash_map<string, vector<Node>*>::iterator it;
for (it = mylog.begin(); it != mylog.end(); it++){
if (in(it->first, net[user])){
continue;
}
double tmp = sim(user, it->first);
if (max < tmp){
max = tmp;
kk = it->first;
}
}
if (min < max){
net[user][minI] = kk;
}
}
示例4: DumpDOT
void DumpDOT(
char *Filename,
multimap <OperandPosition,OperandPosition,OperandPositionCompareTrait> &InstructionMap,
hash_map <ea_t,insn_t> &InstructionHash
)
{
HANDLE hFile=OpenLogFile(Filename);
//InstructionMap
//InstructionHash
WriteToLogFile(hFile,"digraph g {\r\n\
graph [\r\n\
rankdir = \"TB\"\r\n\
];\r\n\
node [\r\n\
fontsize = \"12\"\r\n\
];\r\n\
edge [\r\n\
];\r\n");
//shape = \"ellipse\"\r\n\
hash_map <ea_t,insn_t>::iterator InstructionHashIter;
//Write Node Data
for(InstructionHashIter=InstructionHash.begin();InstructionHashIter!=InstructionHash.end();InstructionHashIter++)
{
ea_t address=InstructionHashIter->first;
char op_buffer[100]={0,};
ua_mnem(address,op_buffer,sizeof(op_buffer));
WriteToLogFile(hFile,"\"%X\" [\r\n\tlabel=\"%s",address,op_buffer);
for(int i=0;i<UA_MAXOP;i++)
{
if(InstructionHashIter->second.Operands[i].type>0)
{
char operand_str[MAXSTR]={0,};
ua_outop(address,operand_str,sizeof(operand_str)-1,i);
tag_remove(operand_str,operand_str,0);
char *escaped_operand_str=EscapeString(operand_str);
if(escaped_operand_str)
{
WriteToLogFile(hFile,"|<f%u>%s",i,escaped_operand_str);
free(escaped_operand_str);
}
}
}
WriteToLogFile(hFile,"\"\r\n\tshape=\"record\"\r\n];\r\n\r\n");
}
multimap <OperandPosition,OperandPosition,OperandPositionCompareTrait>::iterator InstructionMapIter;
for(InstructionMapIter=InstructionMap.begin();InstructionMapIter!=InstructionMap.end();InstructionMapIter++)
{
WriteToLogFile(hFile,"\"%X\":f%u -> \"%X\":f%u\r\n",
InstructionMapIter->first.Address,
InstructionMapIter->first.Index,
InstructionMapIter->second.Address,
InstructionMapIter->second.Index);
}
CloseLogFile(hFile);
}
示例5: set_replicating_map
void ReplicateInfoMessage::set_replicating_map(const hash_map<uint32_t, ReplBlock*>& src)
{
hash_map<uint32_t, ReplBlock*>::const_iterator it = src.begin();
for (; it != src.end(); ++it)
{
replicating_map_.insert(REPL_BLOCK_MAP::value_type(it->first, *(it->second)));
}
}
示例6: CheckIfHaveCreative
void AdGroupPool::CheckIfHaveCreative(hash_map<Ice::Long, AdGroupPtr> & group_pool) {
for (hash_map<Ice::Long, AdGroupPtr>::iterator git = group_pool.begin(); git != group_pool.end();) {
if (!git->second->HasCreatives()) {
// MCE_DEBUG("AdGroupPool::Init --> because obj->HasCreatives is false so erase it groupid = " << git->first);
group_pool.erase(git++);
} else{
++git;
}
}
}
示例7: enorm
// static.
float oskmeans::enorm(const hash_map<uint32_t,float,id_hash_uint> &p)
{
float enorm = 0.0;
hash_map<uint32_t,float,id_hash_uint>::const_iterator hit = p.begin();
while (hit!=p.end())
{
enorm += (*hit).second*(*hit).second;
++hit;
}
return sqrt(enorm);
}
示例8: mapSave
void mapSave(string fileName, hash_map<int, int> &feature2kernel)
{
ofstream outfile;
outfile.open(fileName);
for (hash_map<int, int>::iterator iter = feature2kernel.begin(); iter != feature2kernel.end(); iter++)
{
outfile << iter->first << " " << iter->second << endl;
}
outfile.close();
}
开发者ID:trantorznh,项目名称:maxPooing_denseSampling_in_fine-grained-classification,代码行数:13,代码来源:supportFunc.cpp
示例9: setSymbolInformation
/***************************************************************************
* Set symbol information
***************************************************************************/
bool CCilVm::setSymbolInformation( hash_map<wstring, CG_SYMBOL_INFORMATION>& symbolinfo)
{
if( m_status != VM_EXECUTE_INITIALIZING ) return false;
hash_map<wstring, CG_SYMBOL_INFORMATION>::iterator it = symbolinfo.begin();
pair<wstring, CG_SYMBOL_INFORMATION> pair;
for( ; it != symbolinfo.end(); ++it)
{
pair = *it;
m_SymbolInfoPool[ pair.first ] = pair.second;
}
return true;
}
示例10: free
/*************************************************
* Function: * check_connect_timeout
* Description: * 检测长时间没反应的网络连接,并关闭删除
* Input: *
* Output: *
* Others: *
*************************************************/
void *check_connect_timeout(void* para)
{
hash_map<int, sockStruct>::iterator it_find;
for(it_find = sock_map.begin(); it_find!=sock_map.end(); ++it_find){
if( time((time_t*)0) - (it_find->second).time > 120){ //时间更改
free((it_find->second).recvBuf);
sock_map.erase(it_find);
close(it_find->first);
}
}
}
示例11: main
int main(int argc, char *argv[]){
for( int i = 1; i < argc; i++){
fprintf(stderr,"[[[[[%s]]]]]",argv[i]);
}
char *fname;
pthread_rwlock_init(&histoLock,NULL);
for( int i = 2; i < argc; i++){
files.push_back(string(argv[i]));
}
deserializeFromFile( argv[1] );
//cerr << "Size is: " << files.size() << endl;
pthread_t threads[NUM_THREADS];
for(int i = 0; i < NUM_THREADS; i++){
pthread_create(&(threads[i]), NULL, runner, (void *)i);
}
for(int i = 0; i < NUM_THREADS; i++){
pthread_join(threads[i], NULL);
}
for( hash_map<string, hash_map<string, vector<unsigned long> > >::iterator it = histo.begin();
it != histo.end(); it++ ){
for(hash_map<string, vector<unsigned long> >::iterator it2 = it->second.begin();
it2 != it->second.end(); it2++){
cout << it->first << " " << it2->first << " ";
for(vector<unsigned long>::iterator vi = it2->second.begin();
vi != it2->second.end(); vi++ ){
cout << *vi << " ";
}
cout << endl;
}
}
}
示例12: createPermutation
void createPermutation(hash_map<int,int> hm,vector<int> cur,vector<vector<int> >& res){
if(hm.size()){
for(hash_map<int,int>::iterator it=hm.begin();it!=hm.end();it++){
vector<int> tVec(cur);
hash_map<int,int> tMap(hm);
tVec.push_back(it->first);
if(tMap[it->first]==1)
tMap.erase(it->first);
else
tMap[it->first]--;
createPermutation(tMap,tVec,res);
}
}
else
res.push_back(cur);
}
示例13: distance_normed_points
float oskmeans::distance_normed_points(const hash_map<uint32_t,float,id_hash_uint> &p1,
const hash_map<uint32_t,float,id_hash_uint> &p2)
{
float dist = 0.0;
hash_map<uint32_t,float,id_hash_uint>::const_iterator hit = p1.begin();
hash_map<uint32_t,float,id_hash_uint>::const_iterator hit2;
while (hit!=p1.end())
{
if ((hit2=p2.find((*hit).first))!=p2.end())
{
dist += (*hit).second * (*hit2).second;
}
++hit;
}
return dist;
}
示例14:
void
sat_solver::generate_evidence(hash_map<int, bool> vMap)
{
int size = _path.size();
for(int i = 0; i < size; i++)
{
string s = set_to_string(_path[i]);
_evidence += s + ", ";
}
string literals = "";
hash_map<int, bool>::iterator it;
for(it = vMap.begin(); it != vMap.end(); it ++)
{
if(it->second)
literals += aalta_formula::get_name(it->first);
else
literals += "!" + aalta_formula::get_name(it->second);
}
_evidence += "(" + literals + ")";
}
示例15: setSymbolInformation
/***************************************************************************
* Set symbol information
***************************************************************************/
void CCilDisasm::setSymbolInformation( hash_map<wstring, CG_SYMBOL_INFORMATION>& symbolinfo)
{
hash_map<wstring, CG_SYMBOL_INFORMATION>::iterator it = symbolinfo.begin();
pair<wstring, CG_SYMBOL_INFORMATION> pair;
for( ; it != symbolinfo.end(); ++it)
{
pair = *it;
m_SymbolInfoPool[ pair.second.rid ] = pair.first;
if( SymbolTypeFromFrag( pair.second.Flags ) == CG_SYMBOL_FLAG_GLOBAL
&& pair.second.ridObject )
{
//Builtin object handling.
//They are stored both in static field and RID
m_SymbolInfoPool[ pair.second.ridObject ] = pair.first;
}
}
}