本文整理汇总了C++中map::put方法的典型用法代码示例。如果您正苦于以下问题:C++ map::put方法的具体用法?C++ map::put怎么用?C++ map::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map
的用法示例。
在下文中一共展示了map::put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pthread_create
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void*), void *arg)
{
init();
printf("Thread Creation no %d \n",THREAD_COUNT);
THREAD_COUNT++;
struct Thread_Arg th_arg;
th_arg.start_routine=start_routine;
th_arg.arg=arg;
int ret = original_pthread_create(thread, attr, closure_wrapper, (void*)&th_arg);
struct thread_data* new_thread = MALLOC(struct thread_data);
new_thread->thread_id=*thread;
new_thread->local_thread_id=THREAD_COUNT;
new_thread->state=PTHREAD_ACTIVE_THREAD;
all_thread.put(*thread,new_thread);
//Set next thread to newly created thread
//Execute newly created thread instantenously
next_thread=*thread;
sched();
// TODO
return ret;
}
示例2: pthread_mutex_lock
int pthread_mutex_lock(pthread_mutex_t *mutex) {
// init();
//This is a non deterministic point . Capture non-determinism here
findnextthreadtoschedule(NULL);
// Call scheduler and wait for your turn
sched();
//I am not worthy of this lock
while(!mutex_lock_validity(mutex)) {
findnextthreadtoschedule(pthread_self());
sched();
}
logChoice(all_thread.indexnum(pthread_self()),getActiveThreadNum());
incrementLevel();
PRINT("ACQUIRING LOCK %lx \n",mutex);
lock_map.put(mutex,(pthread_self()));
return original_pthread_mutex_lock(mutex);
// TODO
}
示例3: initTracer
void
init(void) {
if(!initialized) {
initTracer();
original_pthread_create=( int(*)(pthread_t*, const pthread_attr_t*, void* (*)(void*), void*) )dlsym(RTLD_NEXT,"pthread_create");
original_pthread_mutex_lock =(int (*)(pthread_mutex_t*))dlsym(RTLD_NEXT, "pthread_mutex_lock");
original_pthread_mutex_unlock =(int (*)(pthread_mutex_t*))dlsym(RTLD_NEXT, "pthread_mutex_unlock");
original_pthread_join = (int (*)(pthread_t, void**))dlsym(RTLD_NEXT, "pthread_join");
initialized=true;
THREAD_COUNT++;
//insert main thread in the list
struct thread_data* main_thread=MALLOC(struct thread_data);
main_thread->thread_id=pthread_self();
main_thread->state=PTHREAD_ACTIVE_THREAD;
main_thread->local_thread_id=THREAD_COUNT;
all_thread.comparator=pthread_equal;
all_thread.put(pthread_self(),main_thread);
original_pthread_mutex_lock(&SCHED_LOCK);
}
示例4: run
void run(std::istream& in)
{
vector<string> tokens;
string line;
int chromCol=0;
int posCol=1;
int idCol=2;
int refCol=3;
int altCol=4;
int sampleCol=-1;
while(getline(in,line,'\n'))
{
if(AbstractApplication::stopping()) break;
if(line.empty() || line[0]=='#') continue;
tokenizer.split(line,tokens);
string chrom=tokens[chromCol];
chat *p2;
int pos=(int)strtol(tokens[posCol].c_str(),&p2,10);
string id=tokens[idCol];
string ref=tokens[refCol];
string alt=tokens[altCol];
string sampleName=tokens[sampleCol];
Row* therow=NULL;
if(!rows.empty() &&
rows.back()->pos->chrom.compare(chrom)==0 &&
rows.back()->pos->pos==pos &&
rows.back()->ref.compare(ref)==0 &&
rows.back()->alt.compare(alt)==0
)
{
therow=rows.back();
}
else
{
therow=new Row;
therow->pos=new ChromPosition(chrom,pos);
therow->id.assign(id);
therow->ref.assign(ref);
therow->alt.assign(alt);
rows.push_back(therow);
}
int index_sample=0;
if(sampleCol==-1)
{
if(sample2col.empty())
{
Sample* sample=new Sample;
sample->name.assign("Sample");
sample->column_index=0;
samples.push_back(sample);
}
index_sample=0;
}
else
{
map<string,Sample*>::iterator r= sample2col.find(sampleName);
if(r==sample2col.end())
{
Sample* sample=new Sample;
sample->name.assign(sampleName);
sample->column_index=sample2col.size();
index_sample=sample->column_index;
samples.push_back(sample);
sample2col.put(sample->name,sample);
}
else
{
index_sample=r->second->column_index;
}
}
if(index_sample>=therow->data.size())
{
therow->data.resize(index_sample+1);
}
Data* data=new Data;
therow->data.assign(index_sample,data);
}
}