示例#1
0
static inline void propagate_age_update(Cfg& conf, std::deque<Cfg>& tmpres, std::size_t dst) {
	// here we propagate an age field update to all pointers that are equal
	// and thus experience the update too => only for age updates of next fields

	// split to find truly equal pointers
	auto shape_split = disambiguate(*conf.shape, dst);

	for (Shape* s : shape_split) {
		tmpres.emplace_back(Cfg(conf, s));
		Cfg& config = tmpres.back();

		// pointer equal to dst => experiences age update too
		for (std::size_t i = 0; i < s->size(); i++) {
			if (i == dst) continue;
			if (s->test(i, dst, EQ)) {
				#if CAS_OVERAPPROXIMATE_AGE_PROPAGATION
					// overapproximation: drop age relation of pointers that observe the age assignemnt
					for (std::size_t j = 0; j < s->size(); j++)
						for (bool b : {false, true})
							config.ages->set(j, b, i, true, AgeRel::BOT);
				#else
					mk_next_age_equal(config, i, dst, true);
				#endif
			}
		}
	}

	// the shape/ages from conf may no longer be valid => overwrite the shape/ages
	conf.shape = std::move(tmpres.back().shape);
	conf.ages = std::move(tmpres.back().ages);
	tmpres.pop_back();
}
示例#2
0
 //input functions
 virtual char getc() {
     if(gatep==0)throw "virtual char iologgate::getc() gate adress error";
     if((Log.size()==0) || Log.back().check(1))Log.push_back(iologType(1));
     char tmp=gatep->getc();
     Log.back().log(tmp);
     return tmp;
 }
示例#3
0
std::deque<timestamp_t> interp_timestamps(const std::deque<timestamp_t> &t0,
                                          const std::deque<timestamp_t> &t1) {
  // Determine whether t0 or t1 has a higher rate?
  // Then create interpolation timestamps
  timestamp_t ts_start = 0;
  timestamp_t ts_end = 0;
  std::deque<timestamp_t> base_timestamps;

  if (t0.size() > t1.size()) {
    ts_start = t1.front();
    ts_end = t1.back();
    base_timestamps = t0;
  } else {
    ts_start = t0.front();
    ts_end = t0.back();
    base_timestamps = t1;
  }

  // Form interpolation timestamps
  std::deque<timestamp_t> interp_ts;
  for (const auto ts : base_timestamps) {
    if (ts > ts_start && ts < ts_end) {
      interp_ts.push_back(ts);
    }
  }

  return interp_ts;
}
示例#4
0
bool evaluate_unary_operator(const object& operator_object,bool expand = true)
{
    object result, arg;
    bool eval = true;

    if(optic_stack.size())
    {
        eval = evaluate_top();

        if(eval)
        {
            arg = optic_stack.back();
            optic_stack.pop_back();

            if(arg.type == ARRAY && expand)
            {
                object new_array = mem_alloc(ARRAY);

                for(int i = 0; i < arg.data.array->size(); ++i)
                {
//                    optic_stack.push_back(mem_copy(arg.data.array->at(i)));
                    optic_stack.push_back(arg.data.array->at(i));
                    optic_stack.push_back(operator_object);

                    if(evaluate_top())
                    {
                        new_array.data.array->push_back(mem_copy(optic_stack.back()));
                        optic_stack.pop_back();
                    }

                }

                result = new_array;
            }

            else
            {
                operator_object.data.unary_operator_func(result, arg);
            }

//            mem_free(arg);
            optic_stack.push_back(result);
            return true;
        }
    }

    else
    {
        eval = false;
    }

    if(!eval)
    {
        mem_free(arg);
        out() << "Missing argument for unary operator" << std::endl;
        clear_stack();
        return false;
    }
}
示例#5
0
void sdl_handler::join() {

	// this assert will fire if someone will inadvertedly try to join
	// an event context but might end up in the global context instead.
	assert(&event_contexts.back() != &event_contexts.front());

	join(event_contexts.back());
}
示例#6
0
void raise_process_event()
{
	if(event_contexts.empty() == false) {
		event_contexts.back().add_staging_handlers();
		const handler_list& event_handlers = event_contexts.back().handlers;

		for(auto handler : event_handlers) {
			handler->process_event();
		}
	}
}
 void push(int x) {
   while(!stackB.empty()){
     stackA.push_back(stackB.back());
     stackB.pop_back();
   }
   stackA.push_back(x);
   while(!stackA.empty()){
     stackB.push_back(stackA.back());
     stackA.pop_back();
   }
 }
示例#8
0
void raise_draw_event()
{
	if(event_contexts.empty() == false) {
		event_contexts.back().add_staging_handlers();
		const handler_list& event_handlers = event_contexts.back().handlers;

		//events may cause more event handlers to be added and/or removed,
		//so we must use indexes instead of iterators here.
		for(auto handler : event_handlers) {
			handler->draw();
		}
	}
}
示例#9
0
static void align_back(const std::deque<timestamp_t> &reference,
                       std::deque<timestamp_t> &target,
                       std::deque<vec3_t> &data) {
  const auto back = reference.back();
  while (true) {
    if (target.back() > back) {
      target.pop_back();
      data.pop_back();
    } else {
      break;
    }
  }
}
示例#10
0
void Parser::TagClasses(std::string &cclass, std::string coding, 
                        std::map<std::string, std::string> *values, 
                        std::deque<TokenNode *> &nodes)
{
    int n = addressClasses.size();
    int bytes = (n + 7)/8;
    BYTE *b = new BYTE[bytes];
    memset(b, 0, bytes);
    std::string temp = cclass;
    while (temp.size())
    {
        int npos = temp.find_first_not_of(", \t");
        if (npos == std::string::npos)
            break;
        int npos1 = temp.find_first_of(", \t", npos+1);
        if (npos1 == std::string::npos)
        {
            npos1 = temp.size();
        }
        std::string cclass = temp.substr(npos, npos1-npos);
        temp.replace(0,npos1,"");
        AddressClass *p = addressClasses[cclass];
        if (!p)
        {
            return ;
        }
        b[(p->id-1)/8] |= (1 << ((p->id-1) & 7));
    }
    for (std::deque<TokenNode *>::iterator it = nodes.begin(); it != nodes.end(); ++it)
    {
        (*it)->SetBytes(b, bytes);
    }
    if (nodes.size())
    {
        if (coding != "")
        {
            std::map<std::string, int>::iterator it = codings.find(coding);
            n = codings.size() + 1;
            if (it == codings.end())
                codings[coding] = n;
            else
                n = it->second;
            nodes.back()->coding = n;			
        }
        nodes.back()->eos = 1;
        if (values->size())
            nodes.back()->values = values;
    }
    delete b;
}
示例#11
0
文件: sun.cpp 项目: cjsoft/noip
int main(){
	//freopen("sun.in","r",stdin);
	//freopen("sun.out","w",stdout);
	scanf("%d",&n);
	scanf("%s",s);
	for (int i = 0; i < n; ++i){
		q.push_back(s[i]);
	}
	while(!q.empty()){
		if(q.front()<q.back()){
			putchar(q.front());
			q.pop_front();
		}else if(q.front()>q.back()){
			putchar(q.back());
			q.pop_back();
		}else{
			if(q.size()==1){
				putchar(q.front());
				break;
			}
			while(q.front()==q.back() && q.size()!=1){
				lq.push_back(q.front());
				rq.push_back(q.front());
				if(q.front()>q.back()){
					while(!rq.empty()){
						putchar(rq.front());
						rq.pop_front();
					}
					putchar(q.back());
					q.pop_back();
					while(!lq.empty()){
						q.push_front(lq.back());
						lq.pop_back();
					}
				}else{
					while(!rq.empty()){
						putchar(rq.front());
						rq.pop_front();
					}
					putchar(q.back());
					q.pop_front();
					while(!lq.empty()){
						q.push_back(lq.back());
						lq.pop_back();
					}
				}
			}

			
		}
	}
	putchar('\n');
	return 0;
}
示例#12
0
	void RecordRegion(const char* id, bool isEnter)
	{
		ENSURE(!m_Frames.empty());
		SFrame& frame = m_Frames.back();

		// Must call glEndQuery before calling glGenQueries (via NewQuery),
		// for compatibility with the GL_EXT_timer_query spec (which says
		// GL_INVALID_OPERATION if a query of any target is active; the ARB
		// spec and OpenGL specs don't appear to say that, but the AMD drivers
		// implement that error (see Trac #1033))

		if (!frame.events.empty())
		{
			pglEndQueryARB(GL_TIME_ELAPSED);
			ogl_WarnIfError();
		}

		SEvent event;
		event.id = id;
		event.query = NewQuery();
		event.isEnter = isEnter;

		pglBeginQueryARB(GL_TIME_ELAPSED, event.query);
		ogl_WarnIfError();

		frame.events.push_back(event);
	}
示例#13
0
    MpfrFloatData* allocateMpfrFloatData(bool initToZero)
    {
        if(mFirstFreeNode)
        {
            MpfrFloatData* node = mFirstFreeNode;
            mFirstFreeNode = node->nextFreeNode;
            if(initToZero) mpfr_set_si(node->mFloat, 0, GMP_RNDN);
            ++(node->mRefCount);
            return node;
        }

        mData.push_back(MpfrFloatData());
        mpfr_init2(mData.back().mFloat, mDefaultPrecision);
        if(initToZero) mpfr_set_si(mData.back().mFloat, 0, GMP_RNDN);
        return &mData.back();
    }
示例#14
0
void PruneDeque(std::deque<PresentEvent> &presentHistory, uint64_t perfFreq, uint32_t msTimeDiff, uint32_t maxHistLen) {
    while (!presentHistory.empty() &&
        (presentHistory.size() > maxHistLen ||
           ((double)(presentHistory.back().QpcTime - presentHistory.front().QpcTime) / perfFreq) * 1000 > msTimeDiff)) {
        presentHistory.pop_front();
    }
}
示例#15
0
	inline void complete_async(char const* name)
	{
		mutex::scoped_lock l(_async_ops_mutex);
		async_t& a = _async_ops[name];
		TORRENT_ASSERT(a.refs > 0);
		--a.refs;

		// don't let this grow indefinitely
		if (_wakeups.size() < 100000)
		{
			_wakeups.push_back(wakeup_t());
			wakeup_t& w = _wakeups.back();
			w.timestamp = clock_type::now();
#ifdef __MACH__
			task_events_info teinfo;
			mach_msg_type_number_t t_info_count = task_events_info_count;
			task_info(mach_task_self(), TASK_EVENTS_INFO,
				reinterpret_cast<task_info_t>(&teinfo), &t_info_count);
			w.context_switches = teinfo.csw;
#else
			w.context_switches = 0;
#endif
			w.operation = name;
		}
	}
void dijkstra_LIFO_thread(CSRGraph *g, int *dist, std::deque<int> &deq, int threadNum, int *onstack, std::mutex *dist_locks)
{
    while(!deq.empty())
    {
        queue_lock.lock();

        if(deq.empty()){
            queue_lock.unlock();
            break;
        }

        int u = deq.back();
        deq.pop_back();
	
    printf("Popped\n");
    for(int i=0; i< deq.size();i++){
	printf(" %d", deq[i]);
    }
    printf("\n");
        onstack[u]=0;

        int udist = dist[u];
        queue_lock.unlock();

        std::vector<int> neighbors = CSRGraph_getNeighbors(g, u);
        int neighbor;
        for(neighbor=0;neighbor < neighbors.size(); neighbor++)
        {
            int v = neighbors[neighbor];
            int uvdist = CSRGraph_getDistance(g, u, v);
            int alt = udist + uvdist;

            dist_locks[v].lock();
            if(alt < dist[v])
            {
                dist[v] = alt;
                dist_locks[v].unlock();

                queue_lock.lock();                
                if(onstack[v] == 0) 
                {
                    deq.push_back(v);
		    
    printf("Pushed\n");
    for(int i=0; i< deq.size();i++){
	printf(" %d", deq[i]);
    }
    printf("\n");
                    onstack[v]=1;
                }
                queue_lock.unlock();                    
            }
            else
            {
                dist_locks[v].unlock();
            }
        }
    }
    //printf("Thread %d ended.\n", threadNum);
}
示例#17
0
void Create_Building(void)
{
  unsigned height(0);
  if (LowerBuildings.size() > 0)
  {
    Building lastBuilding = LowerBuildings.back();
    if (lastBuilding.x > (int)(ORIGINAL_WIDTH - (ORIGINAL_WIDTH / 10)))
    {
      // Foremost building is not out of the screen yet, there is no space for a new one
      return;
    }
    // Try to model height around the last building
    height = (rand() % 50 - rand() % 50 + lastBuilding.height) % (unsigned)(ORIGINAL_HEIGHT * 0.65);
    if (height <= 0)
    {
      height = -height + 50;
    }
  }
  else
  {
    height = rand() % (unsigned)(ORIGINAL_HEIGHT * 0.65) + (unsigned)(ORIGINAL_HEIGHT * 0.10);
  }
  Building newBuilding(ORIGINAL_WIDTH, ORIGINAL_HEIGHT - height, height);
  LowerBuildings.push_back(newBuilding);
}
示例#18
0
void CreateTempMap( IqParseNode* pParam, IqParseNode* pArg, std::deque<std::map<std::string, std::string> >& Stack,
                    std::vector<std::vector<SqVarRefTranslator> >& Trans,
                    std::map<std::string, IqVarDef*>& TempVars )
{
	assert( NULL != pParam && NULL != pArg );

	std::map<std::string, std::string> mapTrans;
	Stack.push_back( mapTrans );

	while ( pParam != 0 )
	{
		if ( !pArg->IsVariableRef() )
		{
			IqParseNodeVariable * pLocalVar;
			pLocalVar = static_cast<IqParseNodeVariable*>(pParam->GetInterface( ParseNode_Variable ));
			std::stringstream strTempName;
			strTempName << "_" << Stack.size() << "$" << pLocalVar->strName() << std::ends;
			Stack.back() [ pLocalVar->strName() ] = std::string( strTempName.str() );

			SqVarRef temp( pLocalVar->VarRef() );
			IqVarDef* pVD = pTranslatedVariable( temp, Trans );
			TempVars[ strTempName.str() ] = pVD;
			pVD->IncUseCount();
		}
		pParam = pParam->pNextSibling();
		pArg = pArg->pNextSibling();
	}
}
示例#19
0
JNIEXPORT jchar JNICALL
Java_link_kjr_SimpleTerminal_MainActivity_get_1char__(JNIEnv *env, jclass type) {
    char f=buffer.back();
    buffer.pop_back();
    return (jchar) f;

}
示例#20
0
 int qread() {
   if (m_deq.empty())
     return super_t::read();
   unsigned char c = m_deq.back();
   m_deq.pop_back();
   return c;
 }
示例#21
0
void Color3DTree::Node::mNearestNeighbours(const Vector3<int>& color, unsigned int level,
    unsigned int maxneighbours, std::deque<Neighbour>& nearestNeighbours) const
{
  const int distance = this->color.distance(color);
  const unsigned int component = level % 3;
  const int d = color[component] - this->color.get(component);
  insertSorted(nearestNeighbours, Neighbour(this->color, distance), maxneighbours);
  const int lastDistance = nearestNeighbours.back().getDistance();
  if(d < 0)
  {
    if(below)
    {
      below->mNearestNeighbours(color, level + 1, maxneighbours, nearestNeighbours);
    }
    if(above && (-d) < lastDistance)
    {
      above->mNearestNeighbours(color, level + 1, maxneighbours, nearestNeighbours);
    }
  }
  else
  {
    if(above)
    {
      above->mNearestNeighbours(color, level + 1, maxneighbours, nearestNeighbours);
    }
    if(below && d < lastDistance)
    {
      below->mNearestNeighbours(color, level + 1, maxneighbours, nearestNeighbours);
    }
  }
}
示例#22
0
			value_type dequeBack()
			{
				libmaus2::parallel::ScopePosixSpinLock llock(lock);
				value_type const v = Q.back();
				Q.pop_back();
				return v;
			}
示例#23
0
 // set key and value
 size_t set(const Key& k, const Value&& v) {
   if( data_.count(k) ) return data_.size();
   cache_.push_back(k);
   while (!max_cache_.empty() && max_cache_.back() < k) max_cache_.pop_back();
   max_cache_.push_back(k);
   data_[k] = std::move(v);
   return data_.size();
 }
示例#24
0
std::shared_ptr<std::vector<unsigned char> > getbuffer() {
	if(free_buffers.empty()) return std::make_shared<std::vector<unsigned char> >();
	else {
		std::shared_ptr<std::vector<unsigned char> > buffer = std::move(free_buffers.back());
		free_buffers.pop_back();
		return std::move(buffer);
	}
}
示例#25
0
 static void unwindTokens(std::deque<int>& queue, int tok) {
   assert(!queue.empty() && "Token stack is empty!");
   while (queue.back() != tok) {
     queue.pop_back();
     assert(!queue.empty() && "Token stack is empty!");
   }
   queue.pop_back();
 }
示例#26
0
const CCopasiMessage & CCopasiMessage::peekLastMessage()
{
  if (mMessageDeque.empty())
    CCopasiMessage(CCopasiMessage::RAW,
                   MCCopasiMessage + 1);

  return mMessageDeque.back();
}
示例#27
0
void hier_pop_mat()
{
    if (!matrix_stack.empty())
    {
        current_mat=matrix_stack.back();
        matrix_stack.pop_back();
    }
}
示例#28
0
 // pop element out of the stack and return its value
 T pop () {
     if (c.empty()) {
         throw ReadEmptyStack();
     }
     T elem(c.back());
     c.pop_back();
     return elem;
 }
示例#29
0
void proc_pop_interactive()
{
    ASSERT_IS_MAIN_THREAD();
	int old = is_interactive;
	is_interactive= interactive_stack.back();
    interactive_stack.pop_back();
	if( is_interactive != old )
		signal_set_handlers();
}
示例#30
0
文件: manager.cpp 项目: ds84182/Files
void FinishNow() {
	if (stack.empty()) {
		current = nullptr; // TODO: Exit
	} else {
		current = stack.back();
		stack.pop_back();
		current->showLayers();
	}
}