当前位置: 首页>>代码示例>>C++>>正文


C++ map::find方法代码示例

本文整理汇总了C++中map::find方法的典型用法代码示例。如果您正苦于以下问题:C++ map::find方法的具体用法?C++ map::find怎么用?C++ map::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在map的用法示例。


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

示例1: checkConstraints

bool checkConstraints( MeshTopologyPtr mesh, unsigned entityDim, map<unsigned,pair<IndexType,unsigned> > &expectedConstraints, string meshName = "mesh")
{
  bool success = true;

  // check constraints for entities belonging to active cells
  set<IndexType> myActiveCells = mesh->getMyActiveCellIndices();

  for (IndexType cellIndex : myActiveCells)
  {
    CellPtr cell = mesh->getCell(cellIndex);
    vector<unsigned> entitiesForCell = cell->getEntityIndices(entityDim);
    for (vector<unsigned>::iterator entityIt = entitiesForCell.begin(); entityIt != entitiesForCell.end(); entityIt++)
    {
      unsigned entityIndex = *entityIt;

      pair<IndexType,unsigned> constrainingEntity = mesh->getConstrainingEntity(entityDim, entityIndex);

      unsigned constrainingEntityIndex = constrainingEntity.first;
      unsigned constrainingEntityDim = constrainingEntity.second;
      if ((constrainingEntityIndex==entityIndex) && (constrainingEntityDim == entityDim))
      {
        // then we should expect not to have an entry in expectedConstraints:
        if (expectedConstraints.find(entityIndex) != expectedConstraints.end())
        {
          cout << "Expected entity constraint is not imposed in " << meshName << ".\n";
          cout << "Expected " << typeString(entityDim) << " " << entityIndex << " to be constrained by ";
          cout << typeString(expectedConstraints[entityIndex].second) << " " << expectedConstraints[entityIndex].first << endl;
          cout << typeString(entityDim) << " " << entityIndex << " vertices:\n";
          mesh->printEntityVertices(entityDim, entityIndex);
          cout << typeString(expectedConstraints[entityIndex].second) << " " << expectedConstraints[entityIndex].first << " vertices:\n";
          mesh->printEntityVertices(entityDim, expectedConstraints[entityIndex].first);
          success = false;
        }
      }
      else
      {
        if (expectedConstraints.find(entityIndex) == expectedConstraints.end())
        {
          cout << "Unexpected entity constraint is imposed in " << meshName << ".\n";

          string entityType;
          if (entityDim==0)
          {
            entityType = "Vertex ";
          }
          else if (entityDim==1)
          {
            entityType = "Edge ";
          }
          else if (entityDim==2)
          {
            entityType = "Face ";
          }
          else if (entityDim==3)
          {
            entityType = "Volume ";
          }
          string constrainingEntityType;
          if (constrainingEntityDim==0)
          {
            constrainingEntityType = "Vertex ";
          }
          else if (constrainingEntityDim==1)
          {
            constrainingEntityType = "Edge ";
          }
          else if (constrainingEntityDim==2)
          {
            constrainingEntityType = "Face ";
          }
          else if (constrainingEntityDim==3)
          {
            constrainingEntityType = "Volume ";
          }

          cout << entityType << entityIndex << " unexpectedly constrained by " << constrainingEntityType << constrainingEntityIndex << endl;
          cout << entityType << entityIndex << " vertices:\n";
          mesh->printEntityVertices(entityDim, entityIndex);
          cout << constrainingEntityType << constrainingEntityIndex << " vertices:\n";
          mesh->printEntityVertices(constrainingEntityDim, constrainingEntityIndex);
          success = false;
        }
        else
        {
          unsigned expectedConstrainingEntity = expectedConstraints[entityIndex].first;
          if (expectedConstrainingEntity != constrainingEntityIndex)
          {
            cout << "The constraining entity is not the expected one in " << meshName << ".\n";
            cout << "Expected " << typeString(entityDim) << " " << entityIndex << " to be constrained by ";
            cout << typeString(expectedConstraints[entityIndex].second) << " " << expectedConstrainingEntity;
            cout << "; was constrained by " << constrainingEntityIndex << endl;
            cout << typeString(entityDim) << " " << entityIndex << " vertices:\n";
            mesh->printEntityVertices(entityDim, entityIndex);
            cout << typeString(expectedConstraints[entityIndex].second) << " " << expectedConstrainingEntity << " vertices:\n";
            mesh->printEntityVertices(entityDim, expectedConstrainingEntity);
            cout << typeString(constrainingEntityDim) << " " << constrainingEntityIndex << " vertices:\n";
            mesh->printEntityVertices(constrainingEntityDim, constrainingEntityIndex);
            success = false;
          }
        }
//.........这里部分代码省略.........
开发者ID:vijaysm,项目名称:Camellia,代码行数:101,代码来源:MeshTopologyTests.cpp

示例2: assert

const string &primOpName(PrimOpPtr x) {
    map<int, string>::iterator i = primOpNames.find(x->primOpCode);
    assert(i != primOpNames.end());
    return i->second;
}
开发者ID:kssreeram,项目名称:clay-old,代码行数:5,代码来源:loader.cpp

示例3: if

void
setupNextSubsession(RTSPClient* rtspClient) {
	UsageEnvironment& env = rtspClient->envir(); // alias
	StreamClientState& scs = ((ourRTSPClient*)rtspClient)->scs; // alias
	bool rtpOverTCP = false;

	if(rtspconf->proto == IPPROTO_TCP) {
		rtpOverTCP = true;
	}

	scs.subsession = scs.iter->next();
	do if (scs.subsession != NULL) {
		if (!scs.subsession->initiate()) {
			env << *rtspClient << "Failed to initiate the \"" << *scs.subsession << "\" subsession: " << env.getResultMsg() << "\n";
			setupNextSubsession(rtspClient); // give up on this subsession; go to the next one
		} else {
			if(strcmp("video", scs.subsession->mediumName()) == 0) {
				video_sess_fmt = scs.subsession->rtpPayloadFormat();
				video_codec_name = strdup(scs.subsession->codecName());
				if(port2channel.find(scs.subsession->clientPortNum()) == port2channel.end()) {
					int cid = port2channel.size();
					port2channel[scs.subsession->clientPortNum()] = cid;
#ifdef ANDROID
					if(rtspconf->builtin_video_decoder != 0) {
						video_codec_id = ga_lookup_codec_id(video_codec_name);
					} else {
					////// Work with ffmpeg
#endif
					/*if(init_vdecoder(cid, scs.subsession->fmtp_spropparametersets()) < 0) {
						rtsperror("cannot initialize video decoder(%d)\n", cid);
						rtspParam->quitLive555 = 1;
						return;
					}*/
					rtsperror("video decoder(%d) initialized (client port %d)\n",
						cid, scs.subsession->clientPortNum());
#ifdef ANDROID
					////////////////////////
					}
#endif
				}
			} else if(strcmp("audio", scs.subsession->mediumName()) == 0) {
				const char *mime = NULL;
				audio_sess_fmt = scs.subsession->rtpPayloadFormat();
				audio_codec_name = strdup(scs.subsession->codecName());
#ifdef ANDROID
				if((mime = ga_lookup_mime(audio_codec_name)) == NULL) {
					showToast(rtspParam->jnienv, "codec %s not supported", audio_codec_name);
					rtsperror("rtspclient: unsupported audio codec: %s\n", audio_codec_name);
					usleep(300000);
					rtspParam->quitLive555 = 1;
					return;
				}
				audio_codec_id = ga_lookup_codec_id(audio_codec_name);
				if(android_prepare_audio(rtspParam, mime, rtspconf->builtin_audio_decoder != 0) < 0)
					return;
				if(rtspconf->builtin_audio_decoder == 0) {
				//////////////////////////////////////
				rtsperror("init software audio decoder.\n");
#endif
				if(adecoder == NULL) {
					if(init_adecoder() < 0) {
						rtsperror("cannot initialize audio decoder.\n");
						rtspParam->quitLive555 = 1;
						return;
					}
				}
#ifdef ANDROID
				//////////////////////////////////////
				}
#endif
				rtsperror("audio decoder initialized.\n");
			}
			env << *rtspClient << "Initiated the \"" << *scs.subsession
				<< "\" subsession (client ports " << scs.subsession->clientPortNum() << "-" << scs.subsession->clientPortNum()+1 << ")\n";

			// Continue setting up this subsession, by sending a RTSP "SETUP" command:
			rtspClient->sendSetupCommand(*scs.subsession, continueAfterSETUP, False, rtpOverTCP ? True : False/*TCP?*/, False, NULL);
		}
		return;
	} while(0);
	//

	// We've finished setting up all of the subsessions.  Now, send a RTSP "PLAY" command to start the streaming:
	scs.duration = scs.session->playEndTime() - scs.session->playStartTime();
	rtspClient->sendPlayCommand(*scs.session, continueAfterPLAY);
}
开发者ID:hillaker,项目名称:AdvancedNetworking,代码行数:86,代码来源:rtspclient.cpp

示例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);
    		    }
    	    }
开发者ID:BioWu,项目名称:variationtoolkit,代码行数:81,代码来源:angelheart.cpp

示例5: calculateIrDarkCurrent

/**
 * This calculates the dark current corrections for IR. If
 * IRDARKAVG is false, then it translates the sideplane data
 * into the lineBasedDarkCorrections map directly and does nothing further
 * with the data. Otherwise, this will apply a least squares linear
 * fit (the original script did chi-squared, but this is okay) for
 * each band and uses the points on the line instead of the sideplane
 * data directly.
 *
 * @param icube
 */
void calculateIrDarkCurrent(Cube *icube) {
  UserInterface &ui = Application::GetUserInterface();

  bool found = false;

  // verify if IR we have sideplane data
  for(int obj = 0; !found && obj < icube->label()->objects(); obj++) {
    PvlObject &object = icube->label()->object(obj);

    if(object.name() != "Table") continue;

    if(object.hasKeyword("Name") && object["Name"][0] == "SideplaneIr") found = true;
  }

  if(!found) {
    calibInfo += PvlKeyword("SideplaneCorrection", "None");
    return;
  }

  Table sideplane("SideplaneIr", ui.GetFileName("FROM"));

  // If spectal summing is on OR compressor_id isnt N/A then
  //   just return.
  PvlGroup &archive = icube->label()->findGroup("Archive", Pvl::Traverse);

  // If dark subtracted (compressorid is valid) and cant do linear
  //   correction (spectral editing flag on) then do not do dark
  if(archive["CompressorId"][0] != "N/A" &&
      archive["SpectralEditingFlag"][0] == "ON") {
    calibInfo += PvlKeyword("SideplaneCorrection", "None");
    return;
  }

  // If subtracted (compressor id is valid) and dont do linear then return
  if(archive["CompressorId"][0] != "N/A" && ui.GetBoolean("IRORIGDARK") == true) {
    calibInfo += PvlKeyword("SideplaneCorrection", "None");
    return;
  }

  if(archive["SpectralSummingFlag"][0] == "ON") return;

  // Insert the sideplane data into our lineBasedDarkCorrections map (line,band to correction)
  for(int line = 1; line <= icube->lineCount(); line++) {
    for(int band = 1; band <= icube->bandCount(); band++) {
      pair<int, int> index = pair<int, int>(line, band);
      int value = (int)sideplane[(line-1)*icube->bandCount() + (band-1)][2];

      if(value != 57344)
        lineBasedDarkCorrections.insert(pair< pair<int, int>, double>(index, value));
      else
        lineBasedDarkCorrections.insert(pair< pair<int, int>, double>(index, Null));
    }
  }

  if(ui.GetBoolean("IRORIGDARK") == true) {
    calibInfo += PvlKeyword("SideplaneCorrection", "Sideplane");
    return;
  }

  // do linear fits
  for(int band = 1; band <= icube->bandCount(); band++) {
    PolynomialUnivariate basis(1);
    LeastSquares lsq(basis);

    for(int line = 1; line <= icube->lineCount(); line++) {
      pair<int, int> index = pair<int, int>(line, band);
      map< pair<int, int>, double>::iterator val = lineBasedDarkCorrections.find(index);

      if(val != lineBasedDarkCorrections.end()) {
        vector<double> input;
        input.push_back(line);
        double expected = val->second;

        if(!IsSpecial(expected))
          lsq.AddKnown(input, expected);
      }
    }

    if(lsq.Rows() == 0) return;
    lsq.Solve();

    double coefficients[2] = {
      basis.Coefficient(0),
      basis.Coefficient(1)
    };

    for(int line = 1; line <= icube->lineCount(); line++) {
      pair<int, int> index = pair<int, int>(line, band);

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

示例6: user

void *clientSession(void *arg) {
	unsigned int *connection = (unsigned int *) arg;
	int connfd = connection[0];
	unsigned int ip = connection[1];
	sem_wait(&sem);
	if (repeatedLogins.find(ip) == repeatedLogins.end())
		repeatedLogins.insert(pair<unsigned int, pair<string, int> >(ip, pair<string, int>("", 2)));
	sem_post(&sem);
	delete connection;
	int n = 0;
	char *message = new char[BUFFER_SIZE];
	char *username = new char[BUFFER_SIZE];
	char *password = new char[BUFFER_SIZE];
	bzero(message, BUFFER_SIZE);
	bool loggingIn = true;
	while (loggingIn) {
		if (send(connfd, "> Username: ", 12, 0) == -1) {
			perror("error: ");
			pthread_exit(NULL);
		}
		bzero(username, BUFFER_SIZE);
		if ((n = recv(connfd, username, BUFFER_SIZE, 0)) == -1) {
			perror("error: ");
			pthread_exit(NULL);
		} else if (n == 0) {
			if (close(connfd) == -1) {
				perror("error: ");
				pthread_exit(NULL);
			}
			delete username;
			delete message;
			pthread_exit(NULL);
		}
		if (send(connfd, "> Password: ", 12, 0) == -1) {
			perror("error: ");
			pthread_exit(NULL);
		}
		bzero(password, BUFFER_SIZE);
		if (recv(connfd, password, BUFFER_SIZE, 0) == -1) {
			perror("error: ");
			pthread_exit(NULL);
		} else if (n == 0) {
			if (close(connfd) == -1) {
				perror("error: ");
				pthread_exit(NULL);
			}
			delete username;
			delete password;
			delete message;
			pthread_exit(NULL);
		}
		sem_wait(&sem);
		string user(username);
		string pass(password);
		if (accounts.find(user) != accounts.end()) {
			if (accounts[user].isBlocked(ip)) {
				if (accounts[user].blockExpired(ip, BLOCK_TIME)) {
					accounts[user].removeBlocked(ip);
				} else {
					sem_post(&sem);
					stringstream blockStream;
					blockStream << "IP was blocked for " << BLOCK_TIME << " seconds for 3 consecutively failed logins\n";
					string blockMessage = blockStream.str();
					if (send(connfd, blockMessage.data(), blockMessage.length(), 0) == -1) {
						perror("error: ");
						pthread_exit(NULL);
					}
					bzero(message, BUFFER_SIZE);
					continue;
				}
			}
			if (accounts[user].getPassword() == pass) {
				if (accounts[user].getConnection() == -1) {
					string validLogin("Welcome to simple chat server!\n");
					if (send(connfd, validLogin.data(), validLogin.length(), 0) == -1) {
						perror("error: ");
						pthread_exit(NULL);
					}
					if (send(connfd, "> ", 2, 0) == -1) {
						perror("error: ");
						pthread_exit(NULL);
					}
					loggingIn = false;
					accounts[user].setConnection(connfd);
					bzero(message, BUFFER_SIZE);
				} else {
					string dupeLogin("User already signed in, try again.\n");
					if (send(connfd, dupeLogin.data(), dupeLogin.length(), 0) == -1) {
						perror("error: ");
						pthread_exit(NULL);
					}
				}
			} else {
				string invalidPassword("Invalid password, try again.\n");
				if (repeatedLogins[ip].first == user) {
					repeatedLogins[ip].second--;
					if (repeatedLogins[ip].second <= 0) {
						accounts[user].addBlocked(ip);
						repeatedLogins[ip].first = "";
						repeatedLogins[ip].second = 2;
//.........这里部分代码省略.........
开发者ID:Tubebaum,项目名称:CSEE-W4119,代码行数:101,代码来源:Server.cpp

示例7: SIDReqStr

void *processRequest (void *socketid)
{
    int n;
    int *sock = (int*)socketid;
    int acceptSock = *sock; 
	string videoName;

    bool clientSignaledToClose = false;

    while(!clientSignaledToClose){
        char SIDReq[1024];
        memset(SIDReq, 0, sizeof(SIDReq));

        //Receive packet
        say("Receiving packet...\n");
        if ((n = Xrecv(acceptSock, SIDReq, sizeof(SIDReq), 0)) <= 0) {
            cerr << "Xrecv failed!" << endl;
            Xclose(acceptSock);
            delete sock;
            return NULL;
        }

        string SIDReqStr(SIDReq);
        say("Got request: " + SIDReqStr);
        // if the request is about number of chunks return number of chunks
        // since this is first time, you would return along with header

        // If Request contains "numchunks", return number of CID's.
        if(isNumChunksRequest(SIDReqStr)){
			// Get Video Name out of the request
			string prefix = "get numchunks ";
			videoName = SIDReqStr.substr(prefix.length());
			
			say("Request asks for number of chunks: " + videoName);

			//Figure out what video they would like
            			
			// Check to see if this video is the one that the user is looking for
			if(CIDlist.find(videoName) != CIDlist.end()){
				// Add the number of chunks to the string
	            stringstream yy;
	            yy << CIDlist[videoName]->size();
	            string response = yy.str();
	
	            // Add a character of whitespace to the response
				response += " ";
	
				// Append on the list of Server AD-HIDs to the response
				for(vector<string>::iterator it = ContentServerXidList[videoName]->begin();
					it != ContentServerXidList["BigBuckBunny"]->end();
					++it){
						response += *it + " ";
				}
	
		        // Send back the number of CIDs followed by list of AD-HIDs
	            say("Sending back " + response, LVL_DEBUG);
	            Xsend(acceptSock,(void *) response.c_str(), response.length(), 0);
			}
			else{
	            cerr << "Invalid Video Name: " << videoName << endl;
	            Xclose(acceptSock);
	            delete sock;
	            return NULL;
			}
        } 
        else if(isTerminationRequest(SIDReqStr)){
            clientSignaledToClose = true;
        }
		else if(isVideoSelectionRequest(SIDReqStr)){
			ostringstream oss;
			for(vector<string>::iterator it = videoList.begin(); it != videoList.end(); ++it){
				oss << *it << " ";
			}
			Xsend(acceptSock,(void *) oss.str().c_str(), oss.str().length(), 0);
		}
        else {
            // Otherwise, if the request was not about the number of chunks,
            // it must be a request for a certain chunk

            // Format of the request:   start-offset:end-offset
            // Each offset position corresponds to a CID (chunk)
            say("Request is for a certain chunk span");

            // Parse the Request, extract start and end offsets

            int findpos = SIDReqStr.find(":");
            // split around this position
            string prefix = "block ";
            string str = SIDReqStr.substr(prefix.length(), findpos);
            int start_offset = atoi(str.c_str()); 
            str = SIDReqStr.substr(findpos + 1);
            int end_offset = atoi(str.c_str());

            // construct the string from CIDlist
            // return the list of CIDs, NOT including end_offset
            string requestedCIDlist = "";
            for(int i = start_offset; i < end_offset; i++){
                requestedCIDlist += CIDlist[videoName]->at(i) + " ";
            }       
            Xsend(acceptSock, (void *)requestedCIDlist.c_str(), requestedCIDlist.length(), 0);
//.........这里部分代码省略.........
开发者ID:StephenBrownCS,项目名称:cs740-xia,代码行数:101,代码来源:CidDirectoryServer.cpp

示例8: Write

void NiRoom::Write( ostream& out, const map<NiObjectRef,unsigned int> & link_map, list<NiObject *> & missing_link_stack, const NifInfo & info ) const {
	//--BEGIN PRE-WRITE CUSTOM CODE--//

	//--END CUSTOM CODE--//

	NiNode::Write( out, link_map, missing_link_stack, info );
	numItems = (int)(items.size());
	numPortals2 = (int)(portals2.size());
	numInPortals = (int)(inPortals.size());
	numWalls = (int)(wallPlane.size());
	NifStream( numWalls, out, info );
	for (unsigned int i1 = 0; i1 < wallPlane.size(); i1++) {
		NifStream( wallPlane[i1], out, info );
	};
	NifStream( numInPortals, out, info );
	for (unsigned int i1 = 0; i1 < inPortals.size(); i1++) {
		if ( info.version < VER_3_3_0_13 ) {
			WritePtr32( &(*inPortals[i1]), out );
		} else {
			if ( inPortals[i1] != NULL ) {
				map<NiObjectRef,unsigned int>::const_iterator it = link_map.find( StaticCast<NiObject>(inPortals[i1]) );
				if (it != link_map.end()) {
					NifStream( it->second, out, info );
					missing_link_stack.push_back( NULL );
				} else {
					NifStream( 0xFFFFFFFF, out, info );
					missing_link_stack.push_back( inPortals[i1] );
				}
			} else {
				NifStream( 0xFFFFFFFF, out, info );
				missing_link_stack.push_back( NULL );
			}
		}
	};
	NifStream( numPortals2, out, info );
	for (unsigned int i1 = 0; i1 < portals2.size(); i1++) {
		if ( info.version < VER_3_3_0_13 ) {
			WritePtr32( &(*portals2[i1]), out );
		} else {
			if ( portals2[i1] != NULL ) {
				map<NiObjectRef,unsigned int>::const_iterator it = link_map.find( StaticCast<NiObject>(portals2[i1]) );
				if (it != link_map.end()) {
					NifStream( it->second, out, info );
					missing_link_stack.push_back( NULL );
				} else {
					NifStream( 0xFFFFFFFF, out, info );
					missing_link_stack.push_back( portals2[i1] );
				}
			} else {
				NifStream( 0xFFFFFFFF, out, info );
				missing_link_stack.push_back( NULL );
			}
		}
	};
	NifStream( numItems, out, info );
	for (unsigned int i1 = 0; i1 < items.size(); i1++) {
		if ( info.version < VER_3_3_0_13 ) {
			WritePtr32( &(*items[i1]), out );
		} else {
			if ( items[i1] != NULL ) {
				map<NiObjectRef,unsigned int>::const_iterator it = link_map.find( StaticCast<NiObject>(items[i1]) );
				if (it != link_map.end()) {
					NifStream( it->second, out, info );
					missing_link_stack.push_back( NULL );
				} else {
					NifStream( 0xFFFFFFFF, out, info );
					missing_link_stack.push_back( items[i1] );
				}
			} else {
				NifStream( 0xFFFFFFFF, out, info );
				missing_link_stack.push_back( NULL );
			}
		}
	};

	//--BEGIN POST-WRITE CUSTOM CODE--//

	//--END CUSTOM CODE--//
}
开发者ID:Alecu100,项目名称:niflib,代码行数:79,代码来源:NiRoom.cpp

示例9: find_distances_to_maximizing_objects

//template<class ObjectT, ObjectT nullObjectValue>
void find_distances_to_maximizing_objects(const bpp::Tree &tree,
        const vector<int> &breadth_first_visit_order,
        const map<ObjectT, map<ObjectT, set<int> *> *> 
          &alternative_nearest_objects,
        const map<ObjectT, int> &leaf_of_object,
        map<int, map<ObjectT, double> *> &distances_to_maximizing_objects) {
  set<ObjectT> maximizing_objects;
  map<ObjectT, map<ObjectT, set<int> *> *>::const_iterator
    obj_objs_nodes_iter;
  map<ObjectT, set<int> *>::const_iterator obj_nodes_iter;
  ObjectT obj0, obj1;
  for (obj_objs_nodes_iter 
        = alternative_nearest_objects.begin();
      obj_objs_nodes_iter
        != alternative_nearest_objects.end();
      ++obj_objs_nodes_iter) {
    obj0 = obj_objs_nodes_iter->first;
    maximizing_objects.insert(obj0);
    for (obj_nodes_iter = obj_objs_nodes_iter->second->begin();
        obj_nodes_iter != obj_objs_nodes_iter->second->end();
        ++obj_nodes_iter) {
      obj1 = obj_nodes_iter->first;
      maximizing_objects.insert(obj1);
    }
  }
  set<ObjectT>::const_iterator max_obj_iter;
  int nodeId;
  for (max_obj_iter = maximizing_objects.begin();
      max_obj_iter != maximizing_objects.end(); ++max_obj_iter) {
    nodeId = leaf_of_object.find(*max_obj_iter)->second;
    distances_to_maximizing_objects[nodeId] = new map<ObjectT, double>;
    (*distances_to_maximizing_objects[nodeId])[*max_obj_iter] = 0.0;
  }
  map<int, map<ObjectT, double> *>::iterator node_obj_dist_iter, 
                                          parent_node_obj_dist_iter;
  map<ObjectT, double>::iterator obj_dist_iter, parent_obj_dist_iter;
  double parent_distance_to_object_through_node,
      parent_distance_to_object,
      node_distance_to_object;
  int parentId;
  ObjectT obj;
  for (int i = breadth_first_visit_order.size() - 1; i >= 1; --i) {
    nodeId = breadth_first_visit_order[i];
    parentId = tree.getFatherId(nodeId);
    node_obj_dist_iter = distances_to_maximizing_objects.find(nodeId);
    if (node_obj_dist_iter == distances_to_maximizing_objects.end()) {
      continue;
    }
    parent_node_obj_dist_iter = distances_to_maximizing_objects.find(parentId);
    if (parent_node_obj_dist_iter 
          == distances_to_maximizing_objects.end()) {
      distances_to_maximizing_objects[parentId] = new map<ObjectT, double>;
    }
    for (obj_dist_iter = distances_to_maximizing_objects[nodeId]->begin();
        obj_dist_iter != distances_to_maximizing_objects[nodeId]->end();
        ++obj_dist_iter) {
      obj = obj_dist_iter->first;
      node_distance_to_object = obj_dist_iter->second;
      parent_distance_to_object_through_node
        = node_distance_to_object + tree.getDistanceToFather(nodeId);
      parent_obj_dist_iter 
        = distances_to_maximizing_objects[parentId]->find(obj);
      if (parent_obj_dist_iter 
          == distances_to_maximizing_objects[parentId]->end()) {
        (*distances_to_maximizing_objects[parentId])[obj]
          = parent_distance_to_object_through_node;
      } else {
        parent_distance_to_object
          = (*distances_to_maximizing_objects[parentId])[obj];
        if (parent_distance_to_object_through_node
            < parent_distance_to_object) {
          (*distances_to_maximizing_objects[parentId])[obj]
            = parent_distance_to_object_through_node;
        }
      }
    }
  }
}
开发者ID:ruchira,项目名称:Bioinformatics,代码行数:79,代码来源:find_duplication_distances.cpp

示例10: main

int main(){
    cntp=sieve();

    two63 = (1ll<<63);

    recur(0, 63, 1);

//    copy(s.begin(), s.end(), ostream_iterator<ll>(cout, "\n"));

    printf("%d\n", s.size());

    vector<int> es;
    for(set<ll>::iterator it=s.begin(); it!=s.end(); it++){
        es.clear();
        ll cur = *it;
        ll oldcur=cur;

        int sum=0;
        for(int i=0; i<cntp && cur>1 ; i++){
            int cnt=0;
            while(cur%primes[i]==0) cur/=primes[i], cnt++;
            if(cnt>0) es.push_back(cnt);
            sum+=cnt;
        }

        memset(cntprimes, 0, sizeof cntprimes);

        while(sum){
            int cur=sum;
            for(int j=0; j<cntp && cur>1 ; j++){
                int cnt=0;
                while(cur%primes[j]==0) cur/=primes[j], cnt++;
                cntprimes[j]+=cnt;
            }
            sum--;
        }

        for(int i=0; i<es.size(); i++){
            while(es[i]){
                int cur=es[i];
                for(int j=0; j<cntp && cur>1 ; j++){
                    int cnt=0;
                    while(cur%primes[j]==0) cur/=primes[j], cnt++;
                    cntprimes[j]-=cnt;
                }
                es[i]--;
            }
        }

        ll val=1;
        bool valid=true;
        for(int i=0; i<cntp && valid; i++){
            while(cntprimes[i]--){
                val*=primes[i];
                if(val>=two63) {valid=false; break;}
            }
        }

        if(valid){
            if(m.find(val)==m.end()) m[val]=oldcur;
            else m[val]=min(oldcur, m[val]);
        }
    }
//        freopen("factors.out", "w", stdout);
//printf("%d\n", m.size());
//for(map<ll, ll>::iterator it = m.begin(); it!=m.end(); it++) printf("%lld %lld\n", it->first, it->second);

    ll n;

    while(scanf("%lld", &n)>0){
        if(n==1) { printf("1 2\n"); continue; }

        printf("%llu %llu\n", n, m[n]);
    }

    return 0;
}
开发者ID:ABHINAVKR,项目名称:ACM,代码行数:77,代码来源:Factors.cpp

示例11: find_duplication_distances

void find_duplication_distances(const bpp::Tree &tree,
        const vector<int> &breadth_first_visit_order,
        const map<int, AttributeT> attribute_of_node,
        const map<int, map<AttributeT, TreeDistanceInfo<ObjectT, 
                                                    nullObjectValue> *> *>
          distance_from_object_with_attribute_to_node,
        const LeftRightIdsOfNodeIdMap &idMap,
        const map<int, int> &nodeIdOfLeftIdMap,
        const map<ObjectT, int> &leaf_of_object,
        const map<int, ObjectT> &object_of_leaf,
        const map<ObjectT, map<ObjectT, set<int> *> *> 
          &alternative_nearest_objects,
        map<ObjectT, map<ObjectT, DupInfo *> *> &duplication_node_of_objects,
        map<int, ObjObjInfo *>
          &pair_of_objects_yielding_duplication_node_distance,
        map<int, ObjObjInfo *>
          &pair_of_nearest_objects_to_maximal_node,
        map<int,  double> 
          &greatest_distance_of_maximal_descendant) {

  if (alternative_nearest_objects.size() == 0) {
    // There is nothing to do here but set the root
    int rootId = tree.getRootId();
    greatest_distance_of_maximal_descendant[rootId] = -1;
    return;
  }
  // A maximal node is one for which, for some attribute, it is not the case
  // that the node, its parent, and all its siblings have the same nearest
  // object in the tree with that attribute.  There must be at least two
  // distinct objects with the same attribute such that they are the nearest
  // object with that attribute to some of the node, its parent, and its
  // siblings.  All such pairs of objects, and the maximal nodes to which they
  // pertain, have previously been recorded in alternative_nearest_objects.

  // For each pair of objects in alternative_nearest_objects, we will find
  // the most recent common ancestor (MRCA) of that pair of objects.  That is
  // the duplication node for the pair of objects.  We also will find the tree
  // distance between the two objects.  If the tree obeyed a molecular clock,
  // then half this tree distance would tell us how long ago the duplication
  // happened, and each of the two objects would be exactly this distance from
  // the duplication node.  Because the tree does not obey a molecular clock,
  // for any particular duplication node, the distances we get this way from
  // different pairs of duplicated objects that descend from it may be
  // different.  For each duplication node, we will record the maximum of all
  // such distances for any pair of duplicated objects descending from that
  // node, and which pair of objects yielded this maximum.  Call this maximum
  // duplication_node_distance.  

  // For each maximal node, it is maximal due to several possible pairs of
  // alternative nearest objects.  It may not always be the case that for each
  // pair of alternative nearest objects causing a particular node to be
  // maximal, one or both members of the pair will be descendants of the maximal
  // node.  The duplication node between them also may not be a descendant of
  // the maximal node.  The duplication distance of a maximal node will be the
  // maximum duplication_node_distance for all duplication nodes of pairs of
  // alternative nearest objects to the maximal node.  We will find the
  // duplication distance for each maximal node, and record which pair of
  // objects has the duplication_node_distance yielding that duplication
  // distance.  Note that this pair of objects may not be the same as the one
  // yielding the duplication_node_distance of the duplication node.

  // We find the distances from each of the objects that cause nodes to be
  // maximal to each of their ancestors.
  map<int, map<ObjectT, double> *> distances_to_maximizing_objects;
  find_distances_to_maximizing_objects(tree, breadth_first_visit_order,
                                    alternative_nearest_objects,
                                    leaf_of_object,
                                    distances_to_maximizing_objects);

  // The left_ids and right_ids of the nodes in this tree have previously been
  // computed and passed in idMap (which has idMap[nodeId] == pair<left_id,
  // right_id>).  These numbers, which were computed by a modified preorder tree
  // traversal, have the useful properties that:
  // node N1 descends from ndoe N2 if and only if (iff):
  //   left_id(N1) >= left_id(N2) and right_id(N1) <= right_id(N2)
  // node N is an ancestor of nodes N1, ..., Nk iff:
  //   left_id(Ni) >= left_id(N) for all i = 1,...,k and
  //   right_id(Ni) <= right_id(N) for all i = 1,...,k
  // node N is the most recent common ancestor of nodes N1, ..., Nk iff
  //   node N is an ancestor of nodes N1, ..., Nk and
  //   any of the following equivalent conditions holds:
  //   (i) node N has the greatest left_id among ancestors of nodes N1,...,Nk
  //   (ii) node N has the least right_id among ancestors of nodes N1,...,Nk
  //   (iii) node N appears last in the breadth_first_search_order among
  //   ancestors of nodes N1,...,Nk
  // We'll be using (iii).

  // We'll be looking up nodes by either their left_id or their right_id.  The
  // nodeIdOfLeftIdMap was passed in, but we now create a nodeIdOfRighgtIdMap as
  // well, using the idMap (which has idMap[nodeId] == pair<left_id, right_id>).
  map<int, int> nodeIdOfRightIdMap;
  map<int, pair<int, int> >::const_iterator node_id_iter;
  for (node_id_iter = idMap.begin(); node_id_iter != idMap.end();
        ++node_id_iter) {
    nodeIdOfRightIdMap[node_id_iter->second.second] = node_id_iter->first;
  }

  // We will be finding the tree distances between pairs of
  // alternative_nearest_objects.  To make it easy to test the condition that
  // N is an ancestor of N1 and N2, i.e., that
//.........这里部分代码省略.........
开发者ID:ruchira,项目名称:Bioinformatics,代码行数:101,代码来源:find_duplication_distances.cpp

示例12: if

BeginMap::BeginMap(map<string, string> params):Level(){
    MyGame::loaded=0;
    textIndex=0;
    isthread=false;
    SoundEffectManager::unloadData();
    SoundEffectManager::loadFromFile("/Users/alexpeixoto/Desktop/sound.list");

    
    p=new Adventure::Player("/Developer/movement.png", 32, 64);
    
    Point2f playerPosition;
    
    t=new Core::TextControl("/Developer/times.ttf");
    
    d=new Dialog("/Developer/times.ttf");
    pf=nullptr;
    mapLevel="/Users/alexpeixoto/Documents/maps/beginMap.map";
    collisionLevel="/Users/alexpeixoto/Documents/maps/beginMap.map.collision";
    itemLevel="/Users/alexpeixoto/Documents/maps/beginMap.map.item";
    soundLevel="/Users/alexpeixoto/Documents/maps/beginMap.map.sound";
    objectLevel="/Users/alexpeixoto/Documents/maps/beginMap.map.object";
    warpLevel="/Users/alexpeixoto/Documents/maps/beginMap.map.warp";
    mapManager.loadTileLayer(mapLevel);
    mapManager.loadCollisionMap(collisionLevel);
    mapManager.loadItemMap(itemLevel);
    mapManager.loadSoundMap(soundLevel);
    mapManager.loadObjectMap(objectLevel);
    mapManager.loadWarpMap(warpLevel);
    

    WarpManager::loadFromFile("/Users/alexpeixoto/Desktop/beginMap.map.warpList");
    
    initData();
    
    if(params.find("position") != params.end()){
        if(params.at("position")=="outHouse"){
            //disable animation
            mode=1;
            playerPosition.x = 320;
            playerPosition.y = 140;
            p->updateDirection(Adventure::Character::Directions::DOWN, true);
            p->call();
        }
        else if(params.at("position")=="outTest"){
            playerPosition.x = 560;
            playerPosition.y = 170;
            mapManager.move(-400, 0);
            p->updateDirection(Adventure::Character::Directions::LEFT, true);
        }
        else if(params.at("position")=="outObject"){
            playerPosition.x = 290;
            playerPosition.y = 360;
            mapManager.move(0, -100);
            p->updateDirection(Adventure::Character::Directions::UP, true);
        }
        else{
            playerPosition.x = 150;
            playerPosition.y = 300;
            p->updateDirection(Adventure::Character::Directions::LEFT, true);
        }
    }
    else{
        playerPosition.x = 150;
        playerPosition.y = 300;
        p->updateDirection(Adventure::Character::Directions::LEFT, true);
    }
    
    p->setPosition(playerPosition);
    p->setLoop(true);
    p->setPixelsPerCall(150);
    p->resetLoopTo(3);
    p->setWidthScale(1);
    p->setHeightScale(1);
    p->setChangeOnCall(20);
    if(MyGame::oneCross==false){
        BackgroundMusic::intersectWith("/Users/alexpeixoto/Downloads/AF/beginmap.ogg", BackgroundMusic::IntersectMode::CROSS, 4);
        MyGame::oneCross=true;
    }

}
开发者ID:AAGEngine,项目名称:AAGEngine,代码行数:80,代码来源:beginMap.cpp

示例13: setIndex

 inline int setIndex(string s){
     if(label2Index.find(s) == label2Index.end())
         label2Index[s] = totalIndex++;
 }
开发者ID:hophacker,项目名称:algorithm_coding,代码行数:4,代码来源:print-tree-from-pair-sets.cpp

示例14: key

static bool
isFieldValid(const map<string, string> &codec, const char *field, Predicate p)
{
    map<string, string>::const_iterator key(codec.find(field));
    return key != codec.end() and p(key->second);
}
开发者ID:dot-Sean,项目名称:telephony,代码行数:6,代码来源:account.cpp

示例15: PvLog

void AdMatchManagerI::PvLog(const set<AdGroupPtr>& zone_selected, const UserProfile& profile, uint64_t user_key, AdInfoSeq& ad_info_seq, const string& referer, const AdZonePtr& zone_ptr, const map<Ice::Long, int>& group_costs, int rotate_index){
  TimeStat ts;
  ostringstream log;
  int abs_pos = 1;
	vector<string> logseq;
  string referer_tmp = referer;
  LogHelper::instance().Process(referer_tmp);
  for(set<AdGroupPtr>::iterator sit = zone_selected.begin(); sit != zone_selected.end(); ++sit, ++abs_pos){
    AdInfo ad_info;
    MyUtil::Date date(time(NULL));
    AdGroupPtr group_ptr = *sit;

    AdEffectStat::instance().IncPv(user_key, group_ptr->group_id());
    //MCE_INFO("AdMatchNManagerI::GetAds --> IncPv user_key = " << user_key << " group_id = " << group_ptr->group_id());

    if(!group_ptr->creative_ids().empty()){
      //ad_info.creativeid = *(group_ptr->creative_ids().begin());
      int next_creative_index = 0;
      if(zone_ptr->GetRotateSize()){
        next_creative_index = rotate_index / zone_ptr->GetRotateSize();
        //MCE_INFO("AdMatchManagerI::PvLog -->  userid = " << userid << " rotate_index = " << rotate_index << " RotateSize = " << zone_ptr->GetRotateSize() << " next_creative_index = " << next_creative_index);
      }
      ad_info.creativeid = group_ptr->GetNextCreative(next_creative_index);
    }
    else{
      ad_info.creativeid = 0;
    }
    ad_info.groupid = group_ptr->group_id();
    ad_info.updateTime = 0;
    LogParas log_para;
    log_para.server_index_ = server_index_;
    map<Ice::Long, int>::const_iterator cost_it = group_costs.find(ad_info.groupid);
    if(cost_it == group_costs.end()){
      log_para.cost_ = 0;
    }
    else{
      log_para.cost_ = cost_it->second;
    }
    log_para.user_profile_ = profile;
    log_para.pv_time_ = Date(time(NULL)).time();
    log_para.creative_id_ = ad_info.creativeid;
    log_para.user_key_ = user_key;
    log_para.bid_unit_key_ = group_ptr->bid_unit_key();
    log_para.max_price_ = group_ptr->max_price();
    log_para.zone_id_ = zone_ptr->id();
    log_para.ad_count_ = zone_ptr->ad_count();
    ad_info.text = LogHelper::instance().MakeText(log_para);
    ad_info_seq.push_back(ad_info);

    //call AdLogAdapter
    Ice::Long zone_id = log_para.zone_id_;
    Ice::Long creativeid = log_para.creative_id_;
    string http = LogHelper::instance().MakeHttp(log_para);
    string ip = LogHelper::instance().MakeIp(profile.ip());
    log << "[email protected]||" << ip << "||" << date.toDateTime() << "||\"GET " << http << " HTTP/1.0\"||" << "200||"
        << "undefined||" << "undefined||" << "undefined||" << "2||" << "1||" << "none||" << referer_tmp << "||" << zone_id <<
        "^B^B^B^B^B^B^B" <<"||" << creativeid << "^B" << group_ptr->member_id() << "^B" << group_ptr->bid_unit_id()
        << "^B0^B" << group_ptr->max_price() << "^B" << referer_tmp << "^B" << abs_pos << "" << "^B1" << "^B2||4";
		logseq.push_back(log.str());
    /*try{
      ts.reset();
			logseq.push_buck(log.str());
      //AdLogAdapter::instance().Pv(log.str());
      //MCE_INFO("AdMatchManagerI::PvLog --> TIME_TEST write pv_log : " << ts.getTime());
    }
    catch(Ice::Exception& e){
      MCE_WARN("AdMatchManagerI::PvLog --> call AdLogAdapter.Pv ERR  line:"<<__LINE__<<" err:"<<e);
    }
    catch(std::exception& e){
      MCE_WARN("AdMatchManagerI::PvLog --> call AdLogAdapter.Pv ERR  line:"<<__LINE__<<" err:"<<e.what());
    }*/
    log.str("");
  }
	try{
    AdLogAdapter::instance().PvBySeq(logseq);
    //MCE_INFO("AdMatchManagerI::PvLog --> TIME_TEST write pv_log : " << ts.getTime());
  }
  catch(Ice::Exception& e){
    MCE_WARN("AdMatchManagerI::PvLog --> call AdLogAdapter.Pv ERR  line:"<<__LINE__<<" err:"<<e);
  }
  catch(std::exception& e){
    MCE_WARN("AdMatchManagerI::PvLog --> call AdLogAdapter.Pv ERR  line:"<<__LINE__<<" err:"<<e.what());
  }

}
开发者ID:bradenwu,项目名称:oce,代码行数:85,代码来源:AdMatchManagerI.cpp


注:本文中的map::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。