• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ std::set类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中std::set的典型用法代码示例。如果您正苦于以下问题:C++ set类的具体用法?C++ set怎么用?C++ set使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了set类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: symbolExistsInSearchPath

 bool symbolExistsInSearchPath(const std::string& symbol,
                               const std::set<std::string>& searchPathObjects) const
 {
    return searchPathObjects.count(symbol) != 0;
 }
开发者ID:igitur,项目名称:rstudio,代码行数:5,代码来源:SessionRParser.hpp


示例2: NxsCompressDiscreteMatrix

unsigned NxsCompressDiscreteMatrix(
  const NxsCXXDiscreteMatrix & mat,			/**< is the data source */
  std::set<NxsCharacterPattern> & patternSet, /* matrix that will hold the compressed columns */
  std::vector<const NxsCharacterPattern *> * compressedIndexPattern, /** if not 0L, this will be filled to provide a map from an index in `compressedTransposedMatrix` to the original character count */
  const NxsUnsignedSet * taxaToInclude,	/**< if not 0L, this should be  the indices of the taxa in `mat` to include (if 0L all characters will be included). Excluding taxa will result in shorter patterns (the skipped taxa will not be filled with empty codes, instead the taxon indexing will be frameshifted -- the client code must keep track of these frameshifts). */
  const NxsUnsignedSet * charactersToInclude)
    {
    const unsigned origNumPatterns = (unsigned) patternSet.size();
	unsigned ntax = mat.getNTax();
	unsigned patternLength = ntax;
	unsigned nchar = mat.getNChar();
	if (compressedIndexPattern)
	    {
	    compressedIndexPattern->resize(nchar);
	    }
	NxsUnsignedSet allTaxaInds;
	if (taxaToInclude)
	    {
	    if (taxaToInclude->empty())
	        return 0; // might want to warn about this!
	    const unsigned lastTaxonIndex = *(taxaToInclude->rbegin());
	    if (lastTaxonIndex >= ntax)
	        throw NxsException("Taxon index in taxaToInclude argument to NxsCompressDiscreteMatrix is out of range");
        patternLength -= taxaToInclude->size();
	    }
    else
        {
        for (unsigned i = 0; i < ntax; ++i)
            allTaxaInds.insert(i);
        taxaToInclude = &allTaxaInds;
        }
	if (charactersToInclude)
	    {
	    if (charactersToInclude->empty())
	        return 0; // might want to warn about this!
	    const unsigned lastColumnIndex = *(charactersToInclude->rbegin());
	    if (lastColumnIndex >= nchar)
	        throw NxsException("Character index in charactersToInclude argument to NxsCompressDiscreteMatrix is out of range");
	    }

    // Create actingWeights vector and copy the integer weights from mat into it
    // If there are no integer weights in mat, copy the floating point weights instead
    // if floating point weights have been defined
	const std::vector<int> & iwts = mat.getIntWeightsConst();
	std::vector<double> actingWeights(nchar, 1.0);
	//bool weightsSpecified = false;
	//bool weightsAsInts = false;
	if (!iwts.empty())
		{
		NCL_ASSERT(iwts.size() >= nchar);
		//weightsSpecified = true;
		//weightsAsInts = true;
		for (unsigned j = 0; j < nchar; ++j)
			actingWeights[j] = (double)iwts.at(j);
		}
	else
		{
		const std::vector<double> & dwts = mat.getDblWeightsConst();
		if (!dwts.empty())
			{
		//weightsSpecified = true;
			actingWeights = dwts;
			NCL_ASSERT(actingWeights.size() == nchar);
			}
		}

    // Set corresponding actingWeights elements to zero if any characters have been excluded in mat
	const NxsUnsignedSet & excl = mat.getExcludedCharIndices();
	for (NxsUnsignedSet::const_iterator eIt = excl.begin(); eIt != excl.end(); ++eIt)
		{
		NCL_ASSERT(*eIt < nchar);
		actingWeights[*eIt] = 0.0;
		}
	const double * wts = &(actingWeights[0]);

	NxsCharacterPattern patternTemp;
    patternTemp.count = 1;
	for (unsigned j = 0; j < nchar; ++j)
		{
        double patternWeight = wts[j];
        bool shouldInclude = (charactersToInclude == 0L || (charactersToInclude->find(j) != charactersToInclude->end()));
        if (patternWeight > 0.0 &&  shouldInclude)
            {
            // Build up a vector representing the pattern of state codes at this site
            patternTemp.stateCodes.clear();
            patternTemp.stateCodes.reserve(patternLength);
            patternTemp.sumOfPatternWeights = patternWeight;

            unsigned indexInPattern = 0;
            for (NxsUnsignedSet::const_iterator taxIndIt = taxaToInclude->begin(); taxIndIt != taxaToInclude->end(); ++taxIndIt, ++indexInPattern)
                {
                const unsigned taxonIndex = *taxIndIt;
                const NxsCDiscreteStateSet * row	= mat.getRow(taxonIndex);
                const NxsCDiscreteStateSet code = row[j];
                patternTemp.stateCodes.push_back(code);
                }
            NCL_ASSERT(indexInPattern == patternLength);

            std::set<NxsCharacterPattern>::iterator lowBoundLoc = patternSet.lower_bound(patternTemp);
            if ((lowBoundLoc == patternSet.end()) || (patternTemp < *lowBoundLoc))
//.........这里部分代码省略.........
开发者ID:cran,项目名称:rncl,代码行数:101,代码来源:nxscxxdiscretematrix.cpp


示例3: IMPLEMENT_THREAD_LOCAL_NO_CHECK_HOT

namespace HPHP {
///////////////////////////////////////////////////////////////////////////////

static Mutex s_thread_info_mutex;
static std::set<ThreadInfo*> s_thread_infos;

__thread char* ThreadInfo::t_stackbase = 0;

IMPLEMENT_THREAD_LOCAL_NO_CHECK_HOT(ThreadInfo, ThreadInfo::s_threadInfo);

ThreadInfo::ThreadInfo()
    : m_stacklimit(0), m_executing(Idling) {
  assert(!t_stackbase);
  t_stackbase = static_cast<char*>(stack_top_ptr());

  map<int, ObjectAllocatorBaseGetter> &wrappers =
    ObjectAllocatorCollector::getWrappers();
  m_allocators.resize(wrappers.rbegin()->first + 1);
  for (map<int, ObjectAllocatorBaseGetter>::iterator it = wrappers.begin();
       it != wrappers.end(); it++) {
    m_allocators[it->first] = it->second();
    assert(it->second() != nullptr);
  }

  m_mm = MemoryManager::TheMemoryManager();

  m_profiler = nullptr;
  m_pendingException = nullptr;
  m_coverage = new CodeCoverage();

  Transl::TargetCache::threadInit();
  onSessionInit();

  Lock lock(s_thread_info_mutex);
  s_thread_infos.insert(this);
}

ThreadInfo::~ThreadInfo() {
  t_stackbase = 0;

  Lock lock(s_thread_info_mutex);
  s_thread_infos.erase(this);
  delete m_coverage;
  Transl::TargetCache::threadExit();
}

bool ThreadInfo::valid(ThreadInfo* info) {
  Lock lock(s_thread_info_mutex);
  return s_thread_infos.find(info) != s_thread_infos.end();
}

void ThreadInfo::GetExecutionSamples(std::map<Executing, int> &counts) {
  Lock lock(s_thread_info_mutex);
  for (std::set<ThreadInfo*>::const_iterator iter = s_thread_infos.begin();
       iter != s_thread_infos.end(); ++iter) {
    ++counts[(*iter)->m_executing];
  }
}

void ThreadInfo::onSessionInit() {
  m_reqInjectionData.onSessionInit();

  // Take the address of the cached per-thread stackLimit, and use this to allow
  // some slack for (a) stack usage above the caller of reset() and (b) stack
  // usage after the position gets checked.
  // If we're not in a threaded environment, then Util::s_stackSize will be
  // zero. Use getrlimit to figure out what the size of the stack is to
  // calculate an approximation of where the bottom of the stack should be.
  if (Util::s_stackSize == 0) {
    struct rlimit rl;

    getrlimit(RLIMIT_STACK, &rl);
    m_stacklimit = t_stackbase - (rl.rlim_cur - StackSlack);
  } else {
    m_stacklimit = (char *)Util::s_stackLimit + StackSlack;
    assert(uintptr_t(m_stacklimit) < (Util::s_stackLimit + Util::s_stackSize));
  }
}

void ThreadInfo::clearPendingException() {
  m_reqInjectionData.clearPendingExceptionFlag();
  if (m_pendingException != nullptr) delete m_pendingException;
  m_pendingException = nullptr;
}

void ThreadInfo::setPendingException(Exception* e) {
  m_reqInjectionData.setPendingExceptionFlag();
  if (m_pendingException != nullptr) delete m_pendingException;
  m_pendingException = e;
}

void ThreadInfo::onSessionExit() {
  m_reqInjectionData.reset();
  Transl::TargetCache::requestExit();
}

void RequestInjectionData::onSessionInit() {
  Transl::TargetCache::requestInit();
  cflagsPtr = Transl::TargetCache::conditionFlagsPtr();
  reset();
//.........这里部分代码省略.........
开发者ID:CyaLiven,项目名称:hiphop-php,代码行数:101,代码来源:thread_info.cpp


示例4: receiveUdp

/* Receive UDP */
void receiveUdp(int idx) {
	struct missedDataNack missedData;
  long int seqNum = 0;
  char buffer[DGRAM_SIZE + 8];
  struct sockaddr_in clientAddr, serverAddr;
  socklen_t clientAddrLen;
  int udpSocket, rc;
  long int recvSize = 0;
  int yes = 1;
  /* TBD: exactLocation */
  long int exactLocation = 0;
  long int recvDataSize = 0;
  /* NACK */
  long int expectedSeqNum = 0;
  
  int i = 0;
  /* lets do some time out */
  /*struct timeval tv;
  tv.tv_sec = 0;
  tv.tv_usec = 100000;*/
  
  for (i = 0; i < idx; i++) {
    exactLocation += splitSize[idx];
  }

  udpSocket = socket(AF_INET, SOCK_DGRAM, 0);
  if (udpSocket < 0) {
    cout << "Error: Creating Socket" << endl;
    exit(1);
  }
  
  if (setsockopt(udpSocket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) == -1) {
    cout << "Error: Setting Socket Options" << endl;
    exit(1);
  }

  /*if (setsockopt(udpSocket, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) {
    cout << "Error: Setting Socket Options\n");
    exit(1);
  }
  long int n = 1024 * 100; //experiment with it
  if (setsockopt(udpSocket, SOL_SOCKET, SO_RCVBUF, &n, sizeof(n)) == -1) {
    cout << "Error: Setting Socket Options" << endl;
    exit(1);
  }*/

  serverAddr.sin_family = AF_INET;
  serverAddr.sin_addr.s_addr = INADDR_ANY;
  serverAddr.sin_port = htons(UDP_PORT_NO + idx);
  //fprintf(stdout, "Listening on Port: %d\n", ntohs(serverAddr.sin_port));
  
  if (bind(udpSocket, (struct sockaddr *) &serverAddr, sizeof(serverAddr)) < 0) {
    cout << "Error: Binding to Socket " <<  ntohs(serverAddr.sin_port) << endl;
    exit(1);
  }
	clientAddrLen = sizeof(clientAddr);
  

  while (expectedSeqNum < splitSize[idx]) {
    bzero((char *) buffer, sizeof(buffer));
    rc = recvfrom(udpSocket, buffer, sizeof(buffer), 0,
                  (struct sockaddr *) &clientAddr, &clientAddrLen);
    if (rc < 0) {
      cout << "Error: Receiving Data" << endl;
      exit(1);
    }
    totalPackets[idx]++;
    memcpy(&seqNum, buffer, sizeof(long int));
    seqNum = ntohl(seqNum);
    memcpy(&recvDataSize, (buffer + 4), sizeof(long int));
    recvDataSize = ntohl(recvDataSize);
    recvSize += recvDataSize;
    //printf("Got seqNum: %ld, size: %d\n", seqNum, rc);
    if (expectedSeqNum < seqNum) {
      while (expectedSeqNum < seqNum) {
        /* need to get Locking */
        pthread_mutex_lock(&nackLock);
        missedData.idx = idx;
        missedData.missedSeq = expectedSeqNum;
				missedDataSet.insert(missedData);
        expectedSeqNum += recvDataSize;
				missedDataPtr++;
        pthread_mutex_unlock(&nackLock);
      }
			expectedSeqNum += recvDataSize;
			memcpy((file + exactLocation + seqNum), (buffer + 8), recvDataSize);
    } else if (expectedSeqNum == seqNum) {
			expectedSeqNum += recvDataSize;
			memcpy((file + exactLocation + seqNum), (buffer + 8), recvDataSize);
    }else{ //OutofOrder
			/* got a packet out of order need to handle */
      pthread_mutex_lock(&nackLock);
			missedData.idx = idx;
      missedData.missedSeq = seqNum;
			missedDataSet.erase(missedData);
			missedDataPtr--;
      pthread_mutex_unlock(&nackLock);
			memcpy((file + exactLocation + seqNum), (buffer + 8), recvDataSize); 
		}
//.........这里部分代码省略.........
开发者ID:guptaadhip,项目名称:FastFtp,代码行数:101,代码来源:server.cpp


示例5: getCharSet

void String::getCharSet(std::set<unsigned int> &cset) const {
  for(std::vector<unsigned int>::const_iterator itr = d_str.begin();
    itr != d_str.end(); itr++) {
      cset.insert( *itr );
    }
}
开发者ID:ntsis,项目名称:CVC4,代码行数:6,代码来源:regexp.cpp


示例6: switch

bool ConsoleAdapter::consoleInputBox_KeyUp(const CEGUI::EventArgs& args)
{
  const CEGUI::KeyEventArgs& keyargs = static_cast<const CEGUI::KeyEventArgs&>(args);

  if (keyargs.scancode != CEGUI::Key::Tab) {
    mTabPressed = false;
  }
  switch (keyargs.scancode) {
  case CEGUI::Key::ArrowUp:
  {
    if (mBackend->getHistory().getHistoryPosition() == 0) {
      mCommandLine = mInputBox->getText().c_str();
    } else {
      // we are not at the command line but in the history
      // => write back the editing
      mBackend->getHistory().changeHistory(mBackend->getHistory().getHistoryPosition(), mInputBox->getText().c_str());
    }
    mBackend->getHistory().moveBackwards();
    if (mBackend->getHistory().getHistoryPosition() != 0) {
      mInputBox->setText(mBackend->getHistory().getHistoryString());
    }

    return true;
  }
  case CEGUI::Key::ArrowDown:
  {
    if (mBackend->getHistory().getHistoryPosition() > 0) {
      mBackend->getHistory().changeHistory(mBackend->getHistory().getHistoryPosition(), mInputBox->getText().c_str());
      mBackend->getHistory().moveForwards();
      if (mBackend->getHistory().getHistoryPosition() == 0) {
        mInputBox->setText(mCommandLine);
      } else {
        mInputBox->setText(mBackend->getHistory().getHistoryString());
      }
    }

    return true;
  }
  case CEGUI::Key::Tab:
  {
    std::string sCommand(mInputBox->getText().c_str());

    // only process commands
    if (sCommand[0] != '/') {
      return true;
    }
    sCommand = sCommand.substr(1, mInputBox->getCaratIndex() - 1);
    if (mTabPressed == true) {
      const std::set<std::string> commands(mBackend->getPrefixes(sCommand));

      //std::cout << sCommand << std::endl;
      if (commands.size() > 0) {
        std::set<std::string>::const_iterator iCommand(commands.begin());
        std::string sMessage("");

        mSelected = (mSelected + 1) % commands.size();

        int select(0);

        while (iCommand != commands.end()) {
          if (select == mSelected) {
            std::string sCommandLine(mInputBox->getText().c_str());

            // compose the new command line: old text before the caret + selected command
            mInputBox->setText(sCommandLine.substr(0, mInputBox->getCaratIndex()) + iCommand->substr(mInputBox->getCaratIndex() - 1));
            mInputBox->setSelection(mInputBox->getCaratIndex(), 0xFFFFFFFF);
          }
          sMessage += *iCommand + ' ';
          ++iCommand;
          ++select;
        }
        mBackend->pushMessage(sMessage);
      }
    } else {
      mTabPressed = true;
      mSelected = 0;

      const std::set<std::string> commands(mBackend->getPrefixes(sCommand));

      if (commands.size() == 0) {
        // TODO: Error reporting?
      } else {
        // if any command starts with the current prefix
        if (commands.size() == 1) {
          mInputBox->setText(std::string("/") + *(commands.begin()) + ' ');
          // this will be at the end of the text
          mInputBox->setCaratIndex(0xFFFFFFFF);
        } else {
          //If there are multiple matches we need to find the lowest common denominator. We'll do this by iterating through all characters and then checking with all the possible commands if they match that prefix, until we get a false.
          std::set<std::string>::const_iterator iSelected(commands.begin());
          std::set<std::string>::const_iterator iCommand(commands.begin());
          std::string sCommonPrefix(*iCommand);
          int select = 1;

          ++iCommand;
          while (iCommand != commands.end()) {
            if (select == mSelected) {
              iSelected = iCommand;
            }

//.........这里部分代码省略.........
开发者ID:junrw,项目名称:ember-gsoc2012,代码行数:101,代码来源:ConsoleAdapter.cpp


示例7: F1Score

double F1Score( std::set<unsigned int>& com1, std::set<unsigned int>& com2, double* precision, double* recall) {
	*precision = 0.0f;
	*recall = 0.0f;
	
	//computing intersection
	unsigned int counter = 0;
	if( com1.size() < com2.size() ) {
		for( std::set<unsigned int>::iterator iterCom1 = com1.begin(); iterCom1 != com1.end(); iterCom1++ ) {
			if( com2.find( *iterCom1 ) != com2.end() ) {
				counter++;
			}	
		}
	} else {
		for( std::set<unsigned int>::iterator iterCom2 = com2.begin(); iterCom2 != com2.end(); iterCom2++ ) {
			if( com1.find( *iterCom2 ) != com1.end() ) {
				counter++;
			}	
		}
	}
	*precision = counter / (double) com1.size();
	*recall = counter / (double) com2.size();
	if( *precision + *recall > 0.0f ){
		return 2*(*precision)*(*recall)/((*precision) + (*recall));
	}
	return 0.0f;
}
开发者ID:mikemaal,项目名称:SCD,代码行数:26,代码来源:main.cpp


示例8: PrintTainted

void ComputeSSO::PrintTainted(std::set<GraphNode*> tainted)
{
    //  errs()<<"\n\n Tainted Nodes: "<<tainted.size();


    for(set<GraphNode*>::iterator taintNode = tainted.begin();taintNode != tainted.end();++taintNode)
    {
        //errs()<<"\n Node Label : "<<(*taintNode)->getLabel();
        // errs()<<"--";
        if(isa<MemNode>(*taintNode))
        {
            // errs()<<"\n is mem node";
            //string nodeLab = (*taintNode)->getLabel();
           // string str = "sub_42BC4";
          //  std::size_t found = nodeLab.find(str);
            // if (found!=std::string::npos || 1)
            {

                MemNode * memNew = dyn_cast<MemNode>(*taintNode);
                Value * val = memNew->defLocation.second;
                std::set<Value*> aliases = memNew->getAliases();

                if(val)
                {
                    errs()<<"\n Sink Node Tainted : "<<(*taintNode)->getLabel();
                    if(isa<Instruction>(val))
                    {
                        Instruction * inst = dyn_cast<Instruction>(val);
                        string funcName = inst->getParent()->getParent()->getName();
                        errs()<<"\n Function: "<<funcName;
                    }
                    val->dump();
                }
                if(aliases.size()>0)
                    errs()<<"\n Sink Node Tainted : "<<(*taintNode)->getLabel();
                for(set<Value*>::iterator alVal = aliases.begin(); alVal != aliases.end();++alVal)
                {
                    if(isa<Instruction>(*alVal))
                    {
                        Instruction * inst = dyn_cast<Instruction>(*alVal);
                        string funcName = inst->getParent()->getParent()->getName();
                        errs()<<"\n Function: "<<funcName;
                    }
                    (*alVal)->dump();
                }
            }

        }
        if(isa<VarNode>(*taintNode))
        {
            VarNode * varNew = dyn_cast<VarNode>(*taintNode);
            Value * val = varNew->getValue(); //->defLocation.second;
            if(val)
            {
                errs()<<"\n Sink Node Tainted : "<<(*taintNode)->getLabel();
                if(isa<Instruction>(val))
                {
                    Instruction * inst = dyn_cast<Instruction>(val);
                    string funcName = inst->getParent()->getParent()->getName();
                    errs()<<"\n Function: "<<funcName;
                }
                val->dump();
            }
        }
        //if
    }
}
开发者ID:jamella,项目名称:TaintFlowAnalysis,代码行数:67,代码来源:computesso.cpp


示例9: AddOutOfRangeGUID

void UpdateData::AddOutOfRangeGUID(std::set<uint64>& guids)
{
    m_outOfRangeGUIDs.insert(guids.begin(),guids.end());
}
开发者ID:Neskafee,项目名称:TrinityCore,代码行数:4,代码来源:UpdateData.cpp


示例10: contain

 bool contain(const char* s) {
     return pset.find(pstring(s, strlen(s) + 1)) != pset.end();
 }
开发者ID:PeterLValve,项目名称:apitrace,代码行数:3,代码来源:trace_backtrace.cpp


示例11: main

int main() {

    // This test must be run with an OpenGL target
    const Target &target = get_jit_target_from_environment();
    if (!target.has_feature(Target::OpenGL))  {
        fprintf(stderr,"ERROR: This test must be run with an OpenGL target, e.g. by setting HL_JIT_TARGET=host-opengl.\n");
        return 1;
    }

    Var x("x");
    Var y("y");
    Var c("c");

    // This is a simple test case where there are two expressions that are not
    // linearly varying in terms of a loop variable and one expression that is.
    fprintf(stderr, "Test f0\n");

    float p_value = 8.0f;
    Param<float> p("p"); p.set(p_value);

    Func f0("f0");
    f0(x, y, c) = select(c == 0, 4.0f,             // Constant term
                      c == 1, p * 10.0f,        // Linear expression not in terms of a loop parameter
                      cast<float>(x) * 100.0f); // Linear expression in terms of x

    Image<float> out0(8, 8, 3);
    f0.bound(c, 0, 3);
    f0.glsl(x, y, c);

    // Run the test
    varyings.clear();
    f0.add_custom_lowering_pass(new CountVarying);
    f0.realize(out0);

    // Check for the correct number of varying attributes
    if (varyings.size() != 2) {
        fprintf(stderr,
                "Error: wrong number of varying attributes: %d should be %d\n",
                (int)varyings.size(), 2);
        return 1;
    }

    // Check for correct result values
    out0.copy_to_host();

    for (int c=0; c != out0.extent(2); ++c) {
        for (int y=0; y != out0.extent(1); ++y) {
            for (int x=0; x != out0.extent(0); ++x) {
                float expected;
                switch (c) {
                    case 0:
                        expected = 4.0f;
                        break;
                    case 1:
                        expected = p_value * 10.0f;
                        break;
                    default:
                        expected = static_cast<float>(x) * 100.0f;

                }
                float result = out0(x, y, c);
                if (result != expected) {
                    fprintf(stderr, "Incorrect value: %f != %f at %d,%d,%d.\n",
                            result, expected, x, y, c);
                    return 1;
                }
            }
        }
    }
    fprintf(stderr, "Passed!\n");

    // This is a more complicated test case where several expressions are linear
    // in all of the loop variables. This is the coordinate transformation case
    fprintf(stderr, "Test f1\n");

    float th = 3.141592f/8.0f;
    float s_th = sinf(th);
    float c_th = cosf(th);

    float m[] = {
        c_th, -s_th, 0.0f,
        s_th,  c_th, 0.0f
    };

    Param<float> m0("m0"), m1("m1"), m2("m2"),
                 m3("m3"), m4("m4"), m5("m5");

    m0.set(m[0]); m1.set(m[1]); m2.set(m[2]);
    m3.set(m[3]); m4.set(m[4]); m5.set(m[5]);

    Func f1("f1");
    f1(x, y, c) = select(c == 0, m0 * x + m1 * y + m2,
                       c == 1, m3 * x + m4 * y + m5,
                       1.0f);

    f1.bound(c, 0, 3);
    f1.glsl(x, y, c);

    Image<float> out1(8, 8, 3);

//.........这里部分代码省略.........
开发者ID:Embededalexis,项目名称:Halide,代码行数:101,代码来源:varying.cpp


示例12: GetSetIntersection

 template<class T> std::set<T> GetSetIntersection( const std::set<T>& a, const std::set<T>& b ) {
     std::set<T> c;
     set_intersection( a.begin(), a.end(), b.begin(), b.end(), inserter( c, c.begin() ) );
     return c;
 }
开发者ID:sh19910711,项目名称:topcoder-solutions,代码行数:5,代码来源:InternetSecurity.cpp


示例13: HandleArgs

bool HandleArgs(int argc, char** argv, uint32& threads, std::set<uint32>& mapList, bool& debugOutput, uint32& extractFlags)
{
    char* param = NULL;
    extractFlags = 0;

    for (int i = 1; i < argc; ++i)
    {
        if (strcmp(argv[i], "--threads") == 0)
        {
            param = argv[++i];
            if (!param)
                return false;

            threads = atoi(param);
            printf("Using %u threads\n", threads);
        }
        else if (strcmp(argv[i], "--maps") == 0)
        {
            param = argv[++i];
            if (!param)
                return false;

            char* copy = strdup(param);
            char* token = strtok(copy, ",");
            while (token)
            {
                mapList.insert(atoi(token));
                token = strtok(NULL, ",");
            }
            
            free(copy);

            printf("Extracting only provided list of maps (%u).\n", uint32(mapList.size()));
        }
        else if (strcmp(argv[i], "--debug") == 0)
        {
            param = argv[++i];
            if (!param)
                return false;
            debugOutput = atoi(param);
            if (debugOutput)
                printf("Output will contain debug information (.obj files)\n");
        }
        else if (strcmp(argv[i], "--extract") == 0)
        {
            param = argv[++i];
            if (!param)
                return false;

            extractFlags = atoi(param);

            if (!(extractFlags & Constants::EXTRACT_FLAG_ALLOWED)) // Tried to use an invalid flag
                return false;

            printf("Detected flags: \n");
            printf("* Extract DBCs: %s\n", (extractFlags & Constants::EXTRACT_FLAG_DBC) ? "Yes" : "No");
            printf("* Extract Maps: %s\n", (extractFlags & Constants::EXTRACT_FLAG_MAPS) ? "Yes" : "No");
            printf("* Extract VMaps: %s\n", (extractFlags & Constants::EXTRACT_FLAG_VMAPS) ? "Yes" : "No");
            printf("* Extract GameObject Models: %s\n", (extractFlags & Constants::EXTRACT_FLAG_GOB_MODELS) ? "Yes" : "No");
            printf("* Extract MMaps: %s\n", (extractFlags & Constants::EXTRACT_FLAG_MMAPS) ? "Yes" : "No");
        }
    }
    return true;
}
开发者ID:AzerothShard-Dev,项目名称:azerothcore,代码行数:64,代码来源:MeshExtractor.cpp


示例14: is_ignored

bool is_ignored(int i) {
  static std::set<int> ignore = {};
  return ignore.find(i) != ignore.end();
}
开发者ID:MIPS,项目名称:frameworks-ml,代码行数:4,代码来源:avg_pool_float_4_relaxed.model.cpp


示例15: Init

namespace WindowsRawInput {
	static std::set<int> keyboardKeysDown;
	static void *rawInputBuffer;
	static size_t rawInputBufferSize;
	static bool menuActive;
	static bool focused = true;
	static bool mouseRightDown = false;

	void Init() {
		RAWINPUTDEVICE dev[3];
		memset(dev, 0, sizeof(dev));

		dev[0].usUsagePage = HID_USAGE_PAGE_GENERIC;
		dev[0].usUsage = HID_USAGE_GENERIC_KEYBOARD;
		dev[0].dwFlags = g_Config.bIgnoreWindowsKey ? RIDEV_NOHOTKEYS : 0;

		dev[1].usUsagePage = HID_USAGE_PAGE_GENERIC;
		dev[1].usUsage = HID_USAGE_GENERIC_MOUSE;
		dev[1].dwFlags = 0;

		dev[2].usUsagePage = HID_USAGE_PAGE_GENERIC;
		dev[2].usUsage = HID_USAGE_GENERIC_JOYSTICK;
		dev[2].dwFlags = 0;

		if (!RegisterRawInputDevices(dev, 3, sizeof(RAWINPUTDEVICE))) {
			WARN_LOG(COMMON, "Unable to register raw input devices: %s", GetLastErrorMsg());
		}
	}

	bool UpdateMenuActive() {
		MENUBARINFO info;
		memset(&info, 0, sizeof(info));
		info.cbSize = sizeof(info);
		if (GetMenuBarInfo(MainWindow::GetHWND(), OBJID_MENU, 0, &info) != 0) {
			menuActive = info.fBarFocused != FALSE;
		} else {
			// In fullscreen mode, we remove the menu
			menuActive = false;
		}
		return menuActive;
	}

	static int GetTrueVKey(const RAWKEYBOARD &kb) {
		int vKey = kb.VKey;
		switch (kb.VKey) {
		case VK_SHIFT:
			vKey = MapVirtualKey(kb.MakeCode, MAPVK_VSC_TO_VK_EX);
			break;

		case VK_CONTROL:
			if (kb.Flags & RI_KEY_E0)
				vKey = VK_RCONTROL;
			else
				vKey = VK_LCONTROL;
			break;

		case VK_MENU:
			if (kb.Flags & RI_KEY_E0)
				vKey = VK_RMENU;  // Right Alt / AltGr
			else
				vKey = VK_LMENU;  // Left Alt

		//case VK_RETURN:
			// if (kb.Flags & RI_KEY_E0)
			//	vKey = VK_RETURN;  // Numeric return - no code for this. Can special case.
		//	break;

		// Source: http://molecularmusings.wordpress.com/2011/09/05/properly-handling-keyboard-input/
		case VK_NUMLOCK:
			// correct PAUSE/BREAK and NUM LOCK silliness, and set the extended bit
			vKey = MapVirtualKey(kb.VKey, MAPVK_VK_TO_VSC) | 0x100;
			break;

		default:
			break;
		}

		return windowsTransTable[vKey];
	}

	void ProcessKeyboard(RAWINPUT *raw, bool foreground) {
		if (menuActive && UpdateMenuActive()) {
			// Ignore keyboard input while a menu is active, it's probably interacting with the menu.
			return;
		}

		KeyInput key;
		key.deviceId = DEVICE_ID_KEYBOARD;

		if (raw->data.keyboard.Message == WM_KEYDOWN || raw->data.keyboard.Message == WM_SYSKEYDOWN) {
			key.flags = KEY_DOWN;
			key.keyCode = GetTrueVKey(raw->data.keyboard);

			if (key.keyCode) {
				NativeKey(key);
				keyboardKeysDown.insert(key.keyCode);
			}
		} else if (raw->data.keyboard.Message == WM_KEYUP) {
			key.flags = KEY_UP;
			key.keyCode = GetTrueVKey(raw->data.keyboard);
//.........这里部分代码省略.........
开发者ID:njh08d,项目名称:ppsspp,代码行数:101,代码来源:RawInput.cpp


示例16: insertMainStart

void VKFragmentDecompilerThread::insertMainStart(std::stringstream & OS)
{
	//TODO: Generate input mask during parse stage to avoid this
	for (const ParamType& PT : m_parr.params[PF_PARAM_IN])
	{
		for (const ParamItem& PI : PT.items)
		{
			if (PI.name == "fogc")
			{
				glsl::insert_fog_declaration(OS);
				break;
			}
		}
	}

	const std::set<std::string> output_values =
	{
		"r0", "r1", "r2", "r3", "r4",
		"h0", "h2", "h4", "h6", "h8"
	};

	std::string parameters = "";
	const auto half4 = getHalfTypeName(4);
	for (auto &reg_name : output_values)
	{
		const auto type = (reg_name[0] == 'r' || !device_props.has_native_half_support)? "vec4" : half4;
		if (m_parr.HasParam(PF_PARAM_NONE, type, reg_name))
		{
			if (parameters.length())
				parameters += ", ";

			parameters += "inout " + type + " " + reg_name;
		}
	}

	OS << "void fs_main(" << parameters << ")\n";
	OS << "{\n";

	for (const ParamType& PT : m_parr.params[PF_PARAM_NONE])
	{
		for (const ParamItem& PI : PT.items)
		{
			if (output_values.find(PI.name) != output_values.end())
				continue;

			OS << "	" << PT.type << " " << PI.name;
			if (!PI.value.empty())
				OS << " = " << PI.value;

			OS << ";\n";
		}
	}

	if (m_parr.HasParam(PF_PARAM_IN, "vec4", "ssa"))
		OS << "	vec4 ssa = gl_FrontFacing ? vec4(1.) : vec4(-1.);\n";

	if (properties.has_wpos_input)
		OS << "	vec4 wpos = get_wpos();\n";

	bool two_sided_enabled = m_prog.front_back_color_enabled && (m_prog.back_color_diffuse_output || m_prog.back_color_specular_output);

	//Some registers require redirection
	for (const ParamType& PT : m_parr.params[PF_PARAM_IN])
	{
		for (const ParamItem& PI : PT.items)
		{
			if (two_sided_enabled)
			{
				if (PI.name == "spec_color")
				{
					//Only redirect/rename variables if the back_color exists
					if (m_prog.back_color_specular_output)
					{
						if (m_prog.back_color_specular_output && m_prog.front_color_specular_output)
						{
							OS << "	vec4 spec_color = gl_FrontFacing ? front_spec_color : back_spec_color;\n";
						}
						else
						{
							OS << "	vec4 spec_color = back_spec_color;\n";
						}
					}

					continue;
				}

				else if (PI.name == "diff_color")
				{
					//Only redirect/rename variables if the back_color exists
					if (m_prog.back_color_diffuse_output)
					{
						if (m_prog.back_color_diffuse_output && m_prog.front_color_diffuse_output)
						{
							OS << "	vec4 diff_color = gl_FrontFacing ? front_diff_color : back_diff_color;\n";
						}
						else
						{
							OS << "	vec4 diff_color = back_diff_color;\n";
						}
					}
//.........这里部分代码省略.........
开发者ID:Nekotekina,项目名称:rpcs3,代码行数:101,代码来源:VKFragmentProgram.cpp


示例17: fields

void CFileItemHandler::HandleFileItem(const char *ID, bool allowFile, const char *resultname, CFileItemPtr item, const CVariant &parameterObject, const std::set<std::string> &validFields, CVariant &result, bool append /* = true */, CThumbLoader *thumbLoader /* = NULL */)
{
  CVariant object;
  std::set<std::string> fields(validFields.begin(), validFields.end());

  if (item.get())
  {
    std::set<std::string>::const_iterator fileField = fields.find("file");
    if (fileField != fields.end())
    {
      if (allowFile)
      {
        if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->GetPath().empty())
          object["file"] = item->GetVideoInfoTag()->GetPath().c_str();
        if (item->HasMusicInfoTag() && !item->GetMusicInfoTag()->GetURL().empty())
          object["file"] = item->GetMusicInfoTag()->GetURL().c_str();

        if (!object.isMember("file"))
          object["file"] = item->GetPath().c_str();
      }
      fields.erase(fileField);
    }

    if (ID)
    {
      if (item->HasPVRChannelInfoTag() && item->GetPVRChannelInfoTag()->ChannelID() > 0)
         object[ID] = item->GetPVRChannelInfoTag()->ChannelID();
      else if (item->HasEPGInfoTag() && item->GetEPGInfoTag()->UniqueBroadcastID() > 0)
         object[ID] = item->GetEPGInfoTag()->UniqueBroadcastID();
      else if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDatabaseId() > 0)
        object[ID] = (int)item->GetMusicInfoTag()->GetDatabaseId();
      else if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iDbId > 0)
        object[ID] = item->GetVideoInfoTag()->m_iDbId;

      if (stricmp(ID, "id") == 0)
      {
        if (item->HasPVRChannelInfoTag())
          object["type"] = "channel";
        else if (item->HasMusicInfoTag())
        {
          std::string type = item->GetMusicInfoTag()->GetType();
          if (type == "album" || type == "song" || type == "artist")
            object["type"] = type;
          else
            object["type"] = "song";
        }
        else if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_type.empty())
        {
          std::string type = item->GetVideoInfoTag()->m_type;
          if (type == "movie" || type == "tvshow" || type == "episode" || type == "musicvideo")
            object["type"] = type;
        }
        else if (item->HasPictureInfoTag())
          object["type"] = "picture";

        if (!object.isMember("type"))
          object["type"] = "unknown";

        if (fields.find("filetype") != fields.end())
        {
          if (item->m_bIsFolder)
            object["filetype"] = "directory";
          else 
            object["filetype"] = "file";
        }
      }
    }

    bool deleteThumbloader = false;
    if (thumbLoader == NULL)
    {
      if (item->HasVideoInfoTag())
        thumbLoader = new CVideoThumbLoader();
      else if (item->HasMusicInfoTag())
        thumbLoader = new CMusicThumbLoader();

      if (thumbLoader != NULL)
      {
        deleteThumbloader = true;
        thumbLoader->OnLoaderStart();
      }
    }

    if (item->HasPVRChannelInfoTag())
      FillDetails(item->GetPVRChannelInfoTag(), item, fields, object, thumbLoader);
    if (item->HasEPGInfoTag())
      FillDetails(item->GetEPGInfoTag(), item, fields, object, thumbLoader);
    if (item->HasVideoInfoTag())
      FillDetails(item->GetVideoInfoTag(), item, fields, object, thumbLoader);
    if (item->HasMusicInfoTag())
      FillDetails(item->GetMusicInfoTag(), item, fields, object, thumbLoader);
    if (item->HasPictureInfoTag())
      FillDetails(item->GetPictureInfoTag(), item, fields, object, thumbLoader);
    
    FillDetails(item.get(), item, fields, object, thumbLoader);

    if (deleteThumbloader)
      delete thumbLoader;

    object["label"] = item->GetLabel().c_str();
//.........这里部分代码省略.........
开发者ID:CaptainRewind,项目名称:xbmc,代码行数:101,代码来源:FileItemHandler.cpp


示例18: FindGameWords

void MessageWndEdit::FindGameWords() {
     // add player and empire names
    for (EmpireManager::const_iterator it = Empires().begin(); it != Empires().end(); ++it) {
        m_game_words.insert(it->second->Name());
        m_game_words.insert(it->second->PlayerName());
    }
    // add system names
    std::vector<TemporaryPtr<System> > systems = GetUniverse().Objects().FindObjects<System>();
    for (unsigned int i = 0; i < systems.size(); ++i) {
        if (systems[i]->Name() != "")
            m_game_words.insert(systems[i]->Name());
    }
     // add ship names
    std::vector<TemporaryPtr<Ship> > ships = GetUniverse().Objects().FindObjects<Ship>();
    for (unsigned int i = 0; i < ships.size(); ++i) {
        if (ships[i]->Name() != "")
            m_game_words.insert(ships[i]->Name());
    }
     // add ship design names
    for (PredefinedShipDesignManager::iterator it = GetPredefinedShipDesignManager().begin();
         it != GetPredefinedShipDesignManager().end(); ++it)
    {
        if (it->second->Name() != "")
            m_game_words.insert(UserString(it->second->Name()));
    }
     // add specials names
    std::vector<std::string> specials =  SpecialNames();
    for (unsigned int i = 0; i < specials.size(); ++i) {
        if (specials[i] != "")
            m_game_words.insert(UserString(specials[i]));
    }
     // add species names
    for (SpeciesManager::iterator it = GetSpeciesManager().begin();
         it != GetSpeciesManager().end(); ++it)
    {
        if (it->second->Name() != "")
            m_game_words.insert(UserString(it->second->Name()));
    }
     // add techs names
    std::vector<std::string> techs = GetTechManager().TechNames();
    for (unsigned int i = 0; i < techs.size(); ++i) {
        if (techs[i] != "")
            m_game_words.insert(UserString(techs[i]));
    }
    // add building type names
    for (BuildingTypeManager::iterator it = GetBuildingTypeManager().begin();
         it != GetBuildingTypeManager().end(); ++it)
    {
        if (it->second->Name() != "")
            m_game_words.insert(UserString(it->second->Name()));
    }
    // add ship hulls
    for (PredefinedShipDesignManager::iterator it = GetPredefinedShipDesignManager().begin();
         it != GetPredefinedShipDesignManager().end(); ++it)
    {
        if (it->second->Hull() != "")
            m_game_words.insert(UserString(it->second->Hull()));
    }
    // add ship parts
    for (PredefinedShipDesignManager::iterator it = GetPredefinedShipDesignManager().begin();
         it != GetPredefinedShipDesignManager().end(); ++it)
    {
        const std::vector<std::string>& parts = it->second->Parts();
        for (std::vector<std::string>::const_iterator it1 = parts.begin(); it1 != parts.end(); ++it1) {
            if (*it1 != "")
                m_game_words.insert(UserString(*it1));
        }
    }
 }
开发者ID:adityavs,项目名称:freeorion,代码行数:69,代码来源:ChatWnd.cpp


示例


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ std::shared_ptr类代码示例发布时间:2022-06-01
下一篇:
C++ std::recursive_mutex类代码示例发布时间:2022-06-01
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap