Esempio n. 1
0
 // Doles out all the work to the reader pool threads and waits for them to complete
 void SyncTail::prefetchOps(const std::deque<BSONObj>& ops) {
     for (std::deque<BSONObj>::const_iterator it = ops.begin();
          it != ops.end();
          ++it) {
         _prefetcherPool.schedule(&prefetchOp, *it);
     }
     _prefetcherPool.join();
 }
Esempio n. 2
0
void MultipolygonProcessor::insertCoordinates(const std::deque<GeoCoordinate>& source, std::vector<GeoCoordinate>& destination, bool isOuter) const
{
    bool isClockwise = utymap::utils::isClockwise(source);
    if ((isOuter && isClockwise) || (!isOuter && !isClockwise))
        destination.insert(destination.end(), source.begin(), source.end());
    else
        destination.insert(destination.end(), source.rbegin(), source.rend());
}
Esempio n. 3
0
///////////////////////////////////////////////////////////////////////////////
//
//	tcat::exception::base::base
//
///////////////////////////////////////////////////////////////////////////////
//
base::base(std::string filename, int line, std::string dbg_msg, std::string usr_msg, std::string name):
	m_filename	(filename), 
	m_name		(name), 
	m_dbg_msg	(dbg_msg), 
	m_usr_msg 	(usr_msg),
	m_line		(line)
{
	//
	// break here to debug all exceptions
	//
	if ((std::find (g_exception_list.begin(), g_exception_list.end(), "*") != g_exception_list.end()) ||
		(std::find (g_exception_list.begin(), g_exception_list.end(), name) != g_exception_list.end()))
		assert_dialog (usr_msg, name+"\n"+dbg_msg,
			m_filename
//			+ "\nline:" + std::string(line)
			);
}
Esempio n. 4
0
	void setup_players(std::deque<player_t *> &tournament_players) {
		tournament_players.assign(this->players.begin(), this->players.end());
		std::random_shuffle(tournament_players.begin(), tournament_players.end());

		/** Define o 1o elemento como "bye", se necessário" */
		if(tournament_players.size() % 2)
			tournament_players.push_front(nullptr);
	}
Esempio n. 5
0
 bool deactive(thread_control_block *tcb){
     threads.erase(std::find(threads.begin(), threads.end(), tcb));
     threads.push_back(tcb);
     sem_post(&service_count);
     int v;
     sem_getvalue(&service_count, &v);
     return true;
 }
 static std::string toString(const std::deque<T>& iVector) {
     typename std::vector<T>::const_iterator it = iVector.begin();
     std::stringstream ss;
     for(;it!=iVector.end();++it) {
         ss << (*it);
     }
     return ss.str();
 }
Esempio n. 7
0
File: main.cpp Progetto: turu/mikro
 std::vector<cv::Point> getTracePoints() {
     std::vector<cv::Point> ret;
     for (std::deque<TraceEntry*>::iterator it = trace.begin(); it != trace.end(); it++) {
         TraceEntry * entry = *it;
         ret.push_back(entry->point);
     }
     return ret;
 }
Esempio n. 8
0
bool contains(std::deque<int>& memory, int i){
	for(auto it=memory.begin(); it!=memory.end();++it){
		if(*it == i){
			return true;
		}
	}
	return false;
}
Esempio n. 9
0
void	load_player(std::deque<G_obj*> &map, std::fstream &my_file)
{
  G_obj	m_object;

  recup_base(&m_object, my_file);
  map.push_back(&m_object);
  for_each(map.begin(), map.end(), test_map);
}
// Print the leaves only (just for the bottom row)
void printLeaves(int indentSpace, int level, int nodesInThisLevel, const std::deque<Node*>& nodesQueue, std::ostream& out) {
    std::deque<Node*>::const_iterator iter = nodesQueue.begin();
    for (int i = 0; i < nodesInThisLevel; i++, iter++) {
        out << ((i == 0) ? std::setw(indentSpace + 2) : std::setw(2 * level + 2)) << ((*iter) ? std::to_string((*iter)->data) : \
            "");
    }
    out << std::endl;
}
Esempio n. 11
0
bool remove(std::deque<RHNode> &vec, RHNode &element)
{
	std::deque<RHNode>::iterator it = std::find(vec.begin(), vec.end(), element);
	if(it == vec.end())
		return true;
	vec.erase(it);
	return true;
}
Esempio n. 12
0
static void translateBlock(std::deque<llvm::MCInst>& block) {
	typedef std::map<std::string, LLVMValueRef>::const_iterator ValRef;

	std::map<std::string, LLVMValueRef> locals;
	std::map<std::string, LLVMValueRef> regs;

	for (InstIter it = block.begin(); it != block.end(); ++it) {
		llvm::MCInst& inst = *it;
		const llvm::MCInstrDesc& id = MII->get(inst.getOpcode());
		llvm::StringRef iname = MII->getName(inst.getOpcode());

		if (iname.startswith("MOV")) {
			LLVMValueRef lhs;
			unsigned iop = 0;

			if (id.OpInfo[0].OperandType == llvm::MCOI::OPERAND_MEMORY) {
				std::string localName = getLocalName(inst, 0);
				ValRef pval = locals.find(localName); 
				if (pval == locals.end()) {
					lhs = LLVMBuildAlloca(llvmBuilder, LLVMInt32Type(), localName.c_str());
					locals[localName] = lhs;
				} else {
					lhs = pval->second;
				}

				if (id.OpInfo[5].OperandType == llvm::MCOI::OPERAND_IMMEDIATE) {
					const llvm::MCOperand& op = inst.getOperand(5);
					LLVMBuildStore(llvmBuilder, lhs, LLVMConstInt(LLVMInt32Type(), op.getImm(), 0));
				}

				if (id.OpInfo[5].OperandType == llvm::MCOI::OPERAND_REGISTER) {
					LLVMBuildStore(llvmBuilder, lhs, regs[getRegName(inst, 5)]);
				}

			} else if (id.OpInfo[0].OperandType == llvm::MCOI::OPERAND_REGISTER) {
				LLVMValueRef rhs;

				printInst(inst);
				
				if (id.OpInfo[1].OperandType == llvm::MCOI::OPERAND_IMMEDIATE) {
					rhs = LLVMConstInt(LLVMInt32Type(), inst.getOperand(1).getImm(), 0);
				} else if (id.OpInfo[1].OperandType == llvm::MCOI::OPERAND_MEMORY) {
					ValRef pval = locals.find(getLocalName(inst, 1));
					if (pval == locals.end()) {
						llvm::outs() << "No such local " << getLocalName(inst, 1) << "\n";
						break;
					}

					rhs = LLVMBuildLoad(llvmBuilder, pval->second, getRegName(inst, 0));
				} else {
					continue;
				}

				regs[getRegName(inst, 0)] = rhs;
			}
		}
	}
}
Esempio n. 13
0
  void OnShow() 
  {
    for( cIter c=children.begin(); c!=children.end(); ++c)
    {
      GDLWidget* w = GetWidget( *c);
      if( w != NULL)
	w->OnShow();
    }
  }
Esempio n. 14
0
float GoalieSystem::computeAverage(std::deque<float> q)
{
    float sum = 0;
    for(std::deque<float>::iterator i = q.begin(); i != q.end(); i++)
    {
        sum += *i;
    }
    return sum / float(q.size());
}
Esempio n. 15
0
/**
* \details	Compute the largest offset from a deque of tasks
* \return 	this offset
*/
int Simulation::maxOffsetOf(std::deque<Task> tasks)
{
	int maxOffset = 0;
	for (deque<Task>::iterator it = tasks.begin(); it != tasks.end(); ++it)
	{
		maxOffset = max(maxOffset, (*it).getOffset());
	}
	return maxOffset;
}
Esempio n. 16
0
  ///Method to remove a symbol
  bool remove_symbol(const char* symbol_name) {
    for( typename std::deque<std::pair<std::string, T> >::iterator it = symbols.begin() ; it != symbols.end() ; it++ ){
      if( it->first.compare(symbol_name) == 0 ){
	symbols.erase(it);
	return true;
      }
    }
    return false;
  }
Esempio n. 17
0
void EndSockWatch(SOCKET sock) {
	std::deque<SOCKET>::iterator it = std::find(
		socketwatches.begin(),
		socketwatches.end(),
		sock
	);
	if (it != socketwatches.end())
		socketwatches.erase(it);
}
Esempio n. 18
0
 inline void pack( Stream& s, const std::deque<T>& value ) {
   pack( s, unsigned_int((uint32_t)value.size()) );
   auto itr = value.begin();
   auto end = value.end();
   while( itr != end ) {
     fc::raw::pack( s, *itr );
     ++itr;
   }
 }
Esempio n. 19
0
 // Doles out all the work to the reader pool threads and waits for them to complete
 void SyncTail::prefetchOps(const std::deque<BSONObj>& ops) {
     threadpool::ThreadPool& prefetcherPool = theReplSet->getPrefetchPool();
     for (std::deque<BSONObj>::const_iterator it = ops.begin();
          it != ops.end();
          ++it) {
         prefetcherPool.schedule(&prefetchOp, *it);
     }
     prefetcherPool.join();
 }
Esempio n. 20
0
void raise_volatile_draw_all_event()
{
	for( std::deque<context>::iterator i = event_contexts.begin() ; i != event_contexts.end(); ++i) {
		const handler_list& event_handlers = (*i).handlers;
		for(auto handler : event_handlers) {
			handler->volatile_draw();
		}
	}
}
// Print the arm branches (eg, /    \ ) on a line
void printBranches(int branchLen, int nodeSpaceLen, int startLen, int nodesInThisLevel, const std::deque<Node*>& nodesQueue, \
    std::ostream& out) {
    std::deque<Node*>::const_iterator iter = nodesQueue.begin();
    for (int i = 0; i < nodesInThisLevel / 2; i++) {
        out << ((i == 0) ? std::setw(startLen - 1) : std::setw(nodeSpaceLen - 2)) << "" << ((*iter++) ? "/" : " ");
        out << std::setw(2 * branchLen + 2) << "" << ((*iter++) ? "\\" : " ");
    }
    out << std::endl;
}
CInputReceiver* CInputReceiver::GetReceiverAt(int x,int y)
{
	std::deque<CInputReceiver*>::iterator ri;
	for(ri=inputReceivers.begin();ri!=inputReceivers.end();++ri){
		if((*ri)->IsAbove(x,y))
			return *ri;
	}
	return 0;
}
Esempio n. 23
0
bool JsFile::AttemptOutput()
{
    std::stable_sort(m_events.begin(), m_events.end(), EventOrder());
    assert(m_readReq);
    size_t eventsWanted = m_readSize/sizeof(js_event);
    size_t eventsToSend = std::min(eventsWanted, m_events.size());
    if (eventsToSend > 0)
    {
        std::deque<js_event>::iterator i = m_events.begin() + eventsToSend;
        // need events in a contiguous area of memory
        std::vector<js_event> buf(m_events.begin(), i);
        m_events.erase(m_events.begin(), i);
        fuse_reply_buf(m_readReq, (char*)buf.data(),
                       buf.size()*sizeof(js_event));
        m_readReq = 0;
        return true;
    }
    return false;
}
CInputReceiver::~CInputReceiver(void)
{
	std::deque<CInputReceiver*>::iterator ri;
	for(ri=inputReceivers.begin();ri!=inputReceivers.end();++ri){
		if(*ri==this){
			inputReceivers.erase(ri);
			break;
		}
	}
}
Esempio n. 25
0
void XPathFinding<Type>::_remove_nodes(std::list<GraphTypes::node_id> & candidates,
				       const std::deque<GraphTypes::node_id> & waiting_for_insertion)
{
  std::deque<GraphTypes::node_id>::const_iterator node;

  for(node = waiting_for_insertion.begin(); node != waiting_for_insertion.end(); ++node)
    {
      candidates.remove(*node);
    }
}
    void processTask(int position) {

        auto task = tasks[position];
        tasks.erase(tasks.begin() + position);

        task->setTile(std::make_shared<Tile>(task->tileId(), s_projection, &task->source()));

        pendingTiles = true;
        processedCount++;
    }
Esempio n. 27
0
void FileIO::logPath(const std::string& filename, std::deque<const AbstractNode*> path) {
	std::ofstream ofs(filename.c_str());
	if (ofs.good()) {
		for (std::deque<const AbstractNode *>::const_iterator it = path.begin(); it != path.end(); ++it) {
			ofs << (*it)->toLogString() << std::endl;
		}
	} else {
		std::cerr << "Error: Could not open " << filename << " for writing the path." << std::endl;
	}
}
Esempio n. 28
0
void
test(int P, std::deque<int>& c1, int x)
{
    typedef std::deque<int> C;
    typedef C::iterator I;
    typedef C::const_iterator CI;
    std::size_t c1_osize = c1.size();
    CI i = c1.insert(c1.begin() + P, x);
    assert(i == c1.begin() + P);
    assert(c1.size() == c1_osize + 1);
    assert(distance(c1.begin(), c1.end()) == c1.size());
    i = c1.begin();
    for (int j = 0; j < P; ++j, ++i)
        assert(*i == j);
    assert(*i == x);
    ++i;
    for (int j = P; j < c1_osize; ++j, ++i)
        assert(*i == j);
}
Esempio n. 29
0
bool CCopasiMessage::checkForMessage(const unsigned C_INT32 & number)
{
  std::deque< CCopasiMessage >::const_iterator it = mMessageDeque.begin();
  std::deque< CCopasiMessage >::const_iterator end = mMessageDeque.end();

  for (; it != end; ++it)
    if (it->getNumber() == number) return true;

  return false;
}
Esempio n. 30
0
void SRTPose::setValues(std::deque<Geometry::Matrix4x4> _values, std::deque<double> _timeline, std::deque<uint32_t> _interpolationTypes)
{
    if(_values.empty() || _timeline.empty() || _interpolationTypes.empty())
        return;
    double timeOffset = _timeline[0];
    for(auto time : _timeline)
        timeline.emplace_back(time-timeOffset);
    
    std::copy(_interpolationTypes.begin(), _interpolationTypes.end(), std::back_inserter(interpolationTypes));
    std::copy(_values.begin(), _values.end(), std::back_inserter(keyframes));
    
    animationData.clear();
    if(keyframes.size() == 0)
        return;
    
    for(const auto keyframe : keyframes) {
        animationData.emplace_back(keyframe.toSRT());
    }
}