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


C++ hash_map::size方法代码示例

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


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

示例1: read_words

void read_words(const string filename) {
	assert(!open_word_list);

	ifstream fin(filename.c_str());
	assert(fin.is_open());

	_all_words.clear();

	word_list.clear();
	word_list.push_back("");
	assert(word_list.at(NO_WORD) == "");
	word_map.clear();
	word_map[""] = NO_WORD;		// FIXME: Don't use [] operator

	unsigned i;
	string word;
	while(!fin.eof()) {
		fin >> i >> ws >> word >> ws;

		word_list.push_back(word);
		assert(word_list.at(i) == word);
		word_map[word] = i;	// FIXME: Don't use [] operator
		_all_words.push_back(i);

//		if (word == "*content*") _Word_CONTENT = i;
	}
	assert(word_list.size() == word_map.size());

	cerr << "Read " << word_list.size()-1 << " words from '" << filename << "'\n";

	fin.close();
	open_word_list = true;
}
开发者ID:arne-cl,项目名称:turian-parser,代码行数:33,代码来源:vocabulary.C

示例2: add_var

    //добавить переменную в таблицу символов
    static void add_var(const string& name)
    {
        if (table.find(name)!= table.end()) error("duplicate variable");
        else{
            if (table.size() > SIZEVART) error("too many variables");
            else table[name] = 0.0;
        }

    }
开发者ID:ivanprosh,项目名称:Lingvo,代码行数:10,代码来源:main.cpp

示例3: InitHatLevData

void InitHatLevData(   // init the global HAT data needed for this pyr level
    const Image& img,  // in
    int          ilev) // in
{
    if (ilev <= HAT_START_LEV) // we use HATs only at upper pyr levs
    {
        hat_g.Init_(img, PatchWidth(ilev));
#if CACHE
        if (TRACE_CACHE) // show results from previous run
            lprintf("[calls %d hitrate %.2f cachesize %d]\n",
                    ncalls_g, double(nhits_g) / ncalls_g, cache_g.size());
        cache_g.clear();
#endif
    }
}
开发者ID:GianpaoloR,项目名称:polyphemus,代码行数:15,代码来源:hatdesc.cpp

示例4: createPermutation

    void createPermutation(hash_map<int,int> hm,vector<int> cur,vector<vector<int> >& res){
        if(hm.size()){
    		for(hash_map<int,int>::iterator it=hm.begin();it!=hm.end();it++){
				vector<int> tVec(cur);
				hash_map<int,int> tMap(hm);
				tVec.push_back(it->first);
				if(tMap[it->first]==1)
					tMap.erase(it->first);
				else
					tMap[it->first]--;
				createPermutation(tMap,tVec,res);
			}
		}
		else
			res.push_back(cur);
	}
开发者ID:husscc,项目名称:leetcode,代码行数:16,代码来源:PermutationsII.cpp

示例5: fin

void
Dictionary::loadDictionary(const string & f)
{
	wifstream fin(f.c_str());
    fin.imbue(std::locale(""));

    wstring word;
    float freq = 0;

    wcout << L"loading dictionary..." << endl;
	
    fin >> word >> freq;
    while (fin)
    {
        _dict[word] = freq;    
		fin >> word >> freq;
    }
    
    fin.close();
    wcout << L"finished, " 
          << "Totally " << _dict.size() << " words." << endl;
}
开发者ID:jokerlee,项目名称:college,代码行数:22,代码来源:segmentor.cpp

示例6: main

int main(int argc, char *argv[])
{
    

   outfile.open("./tree.txt");

    printf("THR = %f\n", THR);
    for (int ini = 0; ini < 9; ini++)
    {
        char temp = '1'+ini;
        AsciiToInt[temp] = ini;
        IntToAscii[ini] = temp;
    }
    for (int ini = 0; ini < 26; ini++)
    {
        char temp = 'a'+ini;
        AsciiToInt[temp] = 9 + ini;
        IntToAscii[9+ini] = temp;
    }
    for (int ini = 0; ini < 26; ini++)
    {
        char temp = 'A'+ini;
        AsciiToInt[temp] = 35 + ini;
        IntToAscii[35+ini] = temp;
    }
    //cout<<AsciiToInt.find('a')->first<<endl;
    //cout<<AsciiToInt.find('a')->second<<endl;
    double total_random_time = 0;
    double random_time , main_time;
    clock_t start_random_time, end_random_time;
    timeval tv, tv1, tvPartition;
    timeval treeover, DSeqover, Camover;
    register int i, j;
    long long subgraphCounterMain;
    generator gen;
      int next_option;
  const char *const short_options = "hi:d:o:r:s:f:";
  const struct option long_options[] = {
        {"help",   0, NULL, 'h'},
        {"input",  1, NULL, 'i'},
        {"Dnodes input",  1, NULL, 'd'},
        {"output", 1, NULL, 'o'},
        {"random", 1, NULL, 'r'},
        {"size",   1, NULL, 's'},
        {"treeflag",   1, NULL, 'f'},       
        {NULL,     0, NULL,  0 }        
    };
    
    char *program_name;
    char input_filename[256], output_directory[256], Dpath[256];

    int verbose = 0;
    strcpy(output_directory, "result");

    program_name = argv[0];
    do {
        next_option = getopt_long (argc, argv, short_options, long_options, NULL);
    
        switch (next_option) {
            case 'h':
                print_usage (stdout, 0);

            case 'i':
                strcpy(input_filename, optarg);
                break;

            case 'd':
                strcpy(Dpath, optarg);
                break;
                
            case 'o':
                strcpy(output_directory, optarg);
                break;
            
            case 'r':
                 num_random_graphs = atoi(optarg);
                break;

            case 's':
                subgraphSize = atoi(optarg);
                break;

            case 'f':
                treeflag = atoi(optarg);
                break;
            
            case '?':
                print_usage (stdout, 1);
                
            case -1:        /* Done with options. */
                break;
            
            default:        /* Something else: unexpected. */
                print_usage (stderr, -1);
        }
    } while (next_option != -1);

 
    if (input_filename == NULL) {
        fprintf(stderr, "Input Argument Error: Please specify an input filename using \"-i <FILE NAME>\".\n");
//.........这里部分代码省略.........
开发者ID:stormlovetao,项目名称:FS2015,代码行数:101,代码来源:main-speed.cpp

示例7: main

int main(int argc, char *argv[])
{
	char c;
	int nBadFiles = 0;
	vector<string> infiles;

	while ((c = getopt (argc, argv, "neckmsvbw?hgo:i:x:p:d:r:t:")) != -1) {
		switch (c) {
				case 'v':	verbose=true; break;
				case 'b':	binary=true; break;
				case 'c':	excludeCnv=true; break;
				case 'k':	includeCnv=true; break;
				case 'e':	excludeExo=true; break;
				case 'g':	genoSNP=true; break;
				case 's':	genoCalling=true; break;
				case 'm':	simOutput=true; break;
				case 'n':	normalise=false; break;
				case 'h':
				case '?':	displayUsage(); break;
				case 'o':	outputFile = optarg;	break;
				case 't':	tmpFile = optarg;	break;
				case 'p':	project = optarg; break;
                case 'd':   manifestDir = optarg; break;
                case 'x':   exclusionFile = optarg; break;
				case 'r':	chrSelect = optarg; break;
				case 'i':	ifstream f; string s;
							f.open(optarg);
							if (strcmp(optarg,".json")) {
								bool parsingSuccessful = reader.parse( f, root );
								if ( !parsingSuccessful ) {
									std::cout  << "Failed to parse json file\n" << reader.getFormatedErrorMessages() << endl;
									return 0;
								}
								for ( unsigned int index = 0; index < root.size(); ++index ) { // Iterates over the sequence elements.
									sampleNames.push_back(root[index]["uri"].asString());
									infiles.push_back(root[index]["result"].asString());
								}
							} else {
								while (f >> s) infiles.push_back(s);
							}
							f.close();
							break;
		}
	}

	if (outputFile.size() == 0) {
		cout << "No output file specified" << endl;
		displayUsage();
	}

	if (tmpFile.size() == 0) {
		tmpFile = outputFile;
	}

	if (project.size()) {
		getAutocallInfo(infiles,project);
	}

	if (exclusionFile.size() != 0) {
		loadExclusionFile(exclusionFile);
	}

	// read the rest of the command line
	for (int n = optind; n < argc; n++) {
		infiles.push_back(argv[n]);
	}

	if (infiles.size() == 0) {
		cout << "No input files specified" << endl;
		displayUsage();
	}

	if (excludeCnv && includeCnv) {
		cout << "You can't specify -c AND -k options together! That doesn't make sense!" << endl;
		displayUsage();
	}

	if (!excludeCnv && !includeCnv) excludeCnv=true;	// default to 'exclude' if nothing specified

	// sanity check the GTC files
	if (verbose) cout << timestamp() << "Sanity checking";

	for (vector<string>::iterator f = infiles.begin(); f != infiles.end(); f++) {
		bool badFile = false;
		if (verbose) cout << '.';
		try {
			gtc.open(*f,0);
			if (gtc.errorMsg.length()) throw gtc.errorMsg;
		}
		catch (string s) {
			cout << s << endl;
			badFile = true;
			nBadFiles++;
		}
		if (excludeExo && ( (gtc.sampleName.find("Exo") == 0) || 
		                    (gtc.sampleName.find("EXO") == 0))) {
			badFile=true;
			if (verbose) cout << "X";
		}
		if (exclusionList[gtc.sampleName]) {
//.........这里部分代码省略.........
开发者ID:dkj,项目名称:simtools,代码行数:101,代码来源:g2i.cpp

示例8: createGenoCalling

void createGenoCalling(string fname)
{
	int recordLength = gtcHash.size() * 18;
	char *buffer = new char[recordLength];
	memset(buffer,' ',recordLength);
	buffer[recordLength-1] = '\n';

	// Sort the SNPs into position order
	sort(manifest->snps.begin(), manifest->snps.end(), SortByPosition);

	// Create lockfile
	string lockFileName = fname + ".lock";
	FILE *lockfile = fopen(lockFileName.c_str(), "w");
	if (!lockfile) throw (strerror(errno));
	fclose(lockfile);

	//
	// Create all of the output files - one for each chromosome
	//
	for (vector<snpClass>::iterator snp = manifest->snps.begin(); snp != manifest->snps.end(); snp++) {
		if (excludeCnv && snp->name.find("cnv") != string::npos) continue;
		if (chrSelect.size() && chrSelect.compare(snp->chromosome)) continue;
		fstream *f = outFile[snp->chromosome];
		if (!f) {
			f = new fstream();
			string fullFname = fname + "_gtu_" + snp->chromosome + ".txt";
			filenameArray.push_back("_gtu_" + snp->chromosome + ".txt");
			
			if (verbose) cout << timestamp() << "creating file " << fullFname << endl;
			f->open(fullFname.c_str(), ios::in | ios::out | ios::trunc);

			// write sample names from all the gtc files
			for (hash_map<string,string>::iterator i = gtcHash.begin(); i != gtcHash.end(); i++) {
				*f << "\t" << i->first;
			}
			*f << endl;
			// associate the file handle with the chromosome
			outFile[snp->chromosome] = f;
		}
		f = outFile[snp->chromosome];
		*f << snp->name;
		filePos[snp->name] = f->tellp();	// store next position to write
		f->write(buffer,recordLength);	// fill with nulls (or spaces)

		gcCache[snp->name] = "";
	}

	//
	// Process each GTC file in turn
	//
	int n=1;
	int cacheIndex = 0;
	for (hash_map<string,string>::iterator i = gtcHash.begin(); i != gtcHash.end(); i++) {
		if (verbose) cout << timestamp() << "Processing GTC file " << n++ << " of " << gtcHash.size() << endl;
		gtc.open(i->second,Gtc::GENOTYPES | Gtc::BASECALLS | Gtc::SCORES);	// reload GTC file to read required arrays

		for (vector<snpClass>::iterator snp = manifest->snps.begin(); snp != manifest->snps.end(); snp++) {
			if (excludeCnv && snp->name.find("cnv") != string::npos) continue;
			if (chrSelect.size() && chrSelect.compare(snp->chromosome)) continue;
			int idx = snp->index - 1;	// index is zero based in arrays, but starts from 1 in the map file
			char buffer[128];
                        if (gtc.genotypes[idx] > 3)
			   cout << "Unknown genotype value: " << gtc.genotypes[idx] << endl;
                        if (gtc.genotypes[idx] == 0)
			    sprintf(buffer,"\tNN;%f", gtc.scores[idx]);
                        else
			    sprintf(buffer,"\t%c%c;%f", gtc.baseCalls[idx].a, gtc.baseCalls[idx].b, gtc.scores[idx]);
			gcCache[snp->name] += buffer;
		}
		cacheIndex++;
		if (cacheIndex == GCCACHESIZE) { flushgcCache(cacheIndex); cacheIndex=0; }
	}

	flushgcCache(cacheIndex);

	// close all of the files
	for (pos = outFile.begin(); pos != outFile.end(); pos++) {
		pos->second->close();
	}

	// delete lockfile and create donefile
	string doneFileName = lockFileName;
	string::size_type dot = doneFileName.find(".lock");
	doneFileName.replace(dot, 5, ".g2i");
	rename(lockFileName.c_str(), doneFileName.c_str());
	if (verbose) cout << timestamp() << "Renamed " << lockFileName << " to " << doneFileName << endl;
}
开发者ID:dkj,项目名称:simtools,代码行数:87,代码来源:g2i.cpp

示例9: createGenoSNP

void createGenoSNP(string fname)
{
	// Sort the SNPs into position order
	sort(manifest->snps.begin(), manifest->snps.end(), SortByPosition);

	// Create lockfile
	string lockFileName = fname + ".lock";
	FILE *lockfile = fopen(lockFileName.c_str(), "w");
	fclose(lockfile);

	//
	// Create all of the output files
	//
	string rawFname = fname + ".raw.txt";
	string snpFname = fname + ".snp.txt";
	string norFname = fname + ".nor.txt";
	filenameArray.push_back(".raw.txt");
	filenameArray.push_back(".snp.txt");
	filenameArray.push_back(".nor.txt");
	
	fstream fn;
	fstream fs;
	fstream fr;
	fr.open(rawFname.c_str(), ios::in | ios::out | ios::trunc);
	fn.open(norFname.c_str(), ios::in | ios::out | ios::trunc);
	fs.open(snpFname.c_str(), ios::in | ios::out | ios::trunc);
	if (verbose) cout << timestamp() << "creating file " << rawFname << ", " << norFname << " and " << snpFname << endl;

        // Write SNP list to .snp
	for (vector<snpClass>::iterator snp = manifest->snps.begin(); snp != manifest->snps.end(); snp++) {
		if (excludeCnv && snp->name.find("cnv") != string::npos) continue;
		if (chrSelect.size() && chrSelect.compare(snp->chromosome)) continue;
		fs << snp->name << '\t'
		   << (snp->normId % 100) + 1 << '\t'
		   << snp->snp[0] << " " << snp->snp[1] << endl;
	}
        fs.close();
        if (fs.bad())
            cout << "Error closing snp file" << endl;

	//
	// Process each GTC file in turn
	//
	int n=1;
	for (hash_map<string,string>::iterator i = gtcHash.begin(); i != gtcHash.end(); i++) {
		if (verbose) cout << timestamp() << "Processing GTC file " << n++ << " of " << gtcHash.size() << endl;
		//
		// add sample name to each output file
		// no family info as yet (todo?) - write sample ID twice
		fn << i->first << "\t" << i->first;
		fr << i->first << "\t" << i->first;

		gtc.open(i->second,Gtc::XFORM | Gtc::INTENSITY);	// reload GTC file to read XForm and Intensity arrays

		for (vector<snpClass>::iterator snp = manifest->snps.begin(); snp != manifest->snps.end(); snp++) {
			if (excludeCnv && snp->name.find("cnv") != string::npos) continue;
			if (chrSelect.size() && chrSelect.compare(snp->chromosome)) continue;
			int idx = snp->index - 1;	// index is zero based in arrays, but starts from 1 in the map file
			unsigned int norm = manifest->normIdMap[snp->normId];
			XFormClass *XF = &gtc.XForm[norm];

			// first do the normalisation calculation
			double tempx = gtc.xRawIntensity[idx] - XF->xOffset;
			double tempy = gtc.yRawIntensity[idx] - XF->yOffset;

			double cos_theta = cos(XF->theta);
			double sin_theta = sin(XF->theta);
			double tempx2 = cos_theta * tempx + sin_theta * tempy;
			double tempy2 = -sin_theta * tempx + cos_theta * tempy;

			double tempx3 = tempx2 - XF->shear * tempy2;
			double tempy3 = tempy2;

			double xn = tempx3 / XF->xScale;
			double yn = tempy3 / XF->yScale;

			// add raw/norm x/y to .raw and .nor files
			fr << "\t" << std::fixed << setprecision(3) << gtc.xRawIntensity[idx] << " " << gtc.yRawIntensity[idx];
			fn << "\t" << std::fixed << setprecision(3) << xn << " " << yn;
		}
		fn << endl;
		fr << endl;
	}

	fn.close();
	if (fn.bad()) cout << "Error closing nor file" << endl;
	fr.close();
	if (fr.bad()) cout << "Error closing raw file" << endl;

	// delete lockfile and create donefile
	string doneFileName = lockFileName;
	string::size_type dot = doneFileName.find(".lock");
	doneFileName.replace(dot, 5, ".g2i");
	rename(lockFileName.c_str(), doneFileName.c_str());
	if (verbose) cout << timestamp() << "Renamed " << lockFileName << " to " << doneFileName << endl;
}
开发者ID:dkj,项目名称:simtools,代码行数:96,代码来源:g2i.cpp

示例10: createSimFile

void createSimFile(string fname)
{
	Sim *sim = new Sim();

	hash_map<string,string>::iterator i = gtcHash.begin();
	gtc.open(i->second, Gtc::INTENSITY);
	sim->createFile(fname);
	sim->writeHeader(gtcHash.size(), gtc.xRawIntensity.size());

	//
	//
	// Process each GTC file in turn
	//
	unsigned int n=1;
	for (hash_map<string,string>::iterator i = gtcHash.begin(); i != gtcHash.end(); i++) {
		char *buffer;
		if (verbose) cout << timestamp() << "Processing GTC file " << n << " of " << gtcHash.size() << endl;
		//
		// add sample name to each output file
		// no family info as yet (todo?) - write sample ID twice
//		fn << i->first << endl;

		gtc.open(i->second,Gtc::XFORM | Gtc::INTENSITY);	// reload GTC file to read XForm and Intensity arrays
		buffer = new char[sim->sampleNameSize];
		memset(buffer,0,sim->sampleNameSize);
		// if we have a sample name from the json file, use it
		if (sampleNames.size() > (n-1)) { strcpy(buffer, sampleNames[n-1].c_str()); }
		else                            { strcpy(buffer,gtc.sampleName.c_str()); }
		sim->write(buffer, sim->sampleNameSize);

		for (unsigned int idx = 0; idx < gtc.xRawIntensity.size(); idx++) {
			uint16_t v;
			v = gtc.xRawIntensity[idx];
			sim->write(&v,sizeof(v));
			v = gtc.yRawIntensity[idx];
			sim->write(&v,sizeof(v));
		}
		n++;

#if 0
		for (vector<snpClass>::iterator snp = manifest->snps.begin(); snp != manifest->snps.end(); snp++) {
			if (excludeCnv && snp->name.find("cnv") != string::npos) continue;
			if (chrSelect.size() && chrSelect.compare(snp->chromosome)) continue;
			int idx = snp->index - 1;	// index is zero based in arrays, but starts from 1 in the map file
			unsigned int norm = manifest->normIdMap[snp->normId];
			XFormClass *XF = &gtc.XForm[norm];

			// first do the normalisation calculation
			double tempx = gtc.xRawIntensity[idx] - XF->xOffset;
			double tempy = gtc.yRawIntensity[idx] - XF->yOffset;

			double cos_theta = cos(XF->theta);
			double sin_theta = sin(XF->theta);
			double tempx2 = cos_theta * tempx + sin_theta * tempy;
			double tempy2 = -sin_theta * tempx + cos_theta * tempy;

			double tempx3 = tempx2 - XF->shear * tempy2;
			double tempy3 = tempy2;

			double xn = tempx3 / XF->xScale;
			double yn = tempy3 / XF->yScale;

			// add raw/norm x/y to .raw and .nor files
//			fn << "\t" << std::fixed << setprecision(3) << xn << " " << yn;
		}
#endif

	}
	sim->close();
}
开发者ID:dkj,项目名称:simtools,代码行数:70,代码来源:g2i.cpp

示例11: goForIt

//
// We've read the Manifest and all the GTC files
// Now it's time to create the output files
//
void goForIt(string fname)
{
	int recordLength = gtcHash.size() * 10 * 2;
	if (binary) recordLength = gtcHash.size() * sizeof(float) * 2;
	char *buffer = new char[recordLength];
	if (binary) {
		memset(buffer,0,recordLength);
	} else {
		memset(buffer,' ',recordLength);
		buffer[recordLength-1] = '\n';
	}

	// Sort the SNPs into position order
	sort(manifest->snps.begin(), manifest->snps.end(), SortByPosition);

	// Create lockfile
	string lockFileName = fname + ".lock";
	FILE *lockfile = fopen(lockFileName.c_str(), "w");
	if (!lockfile) {
		cerr << "Can't create lock file " << lockFileName << endl;
		cerr << strerror(errno) << endl;
		exit(1);
	}
	fclose(lockfile);

	//
	// Create all of the output files - one for each chromosome
	//
	for (vector<snpClass>::iterator snp = manifest->snps.begin(); snp != manifest->snps.end(); snp++) {
		if (excludeCnv && snp->name.find("cnv") != string::npos) continue;
		if (chrSelect.size() && chrSelect.compare(snp->chromosome)) continue;
		fstream *f = outFile[snp->chromosome];
		if (!f) {
			f = new fstream();
			string fullFname = fname + "_intu_" + snp->chromosome + ".txt";
			filenameArray.push_back("_intu_" + snp->chromosome + ".txt");
			if (verbose) cout << timestamp() << "creating file " << fullFname << endl;
			if (binary) f->open(fullFname.c_str(), ios::in | ios::out | ios::trunc | ios::binary);
			else        f->open(fullFname.c_str(), ios::in | ios::out | ios::trunc);

			*f << "SNP\tCoor\tAlleles";
			// write sample names from all the gtc files
			for (hash_map<string,string>::iterator i = gtcHash.begin(); i != gtcHash.end(); i++) {
				*f << "\t" << i->first << "A\t" << i->first << "B";
			}
			*f << endl;
			// associate the file handle with the chromosome
			outFile[snp->chromosome] = f;
		}
		f = outFile[snp->chromosome];
		*f << snp->name << "\t" << snp->position << "\t" << snp->snp[0] << snp->snp[1];
		filePos[snp->name] = f->tellp();	// store next position to write
		f->write(buffer,recordLength);	// fill with nulls (or spaces)

		cache[snp->name] = new float[CACHESIZE];
	}

	//
	// Process each GTC file in turn
	//
	int n=1;
	int cacheIndex = 0;
	for (hash_map<string,string>::iterator i = gtcHash.begin(); i != gtcHash.end(); i++) {
		if (verbose) cout << timestamp() << "Processing GTC file " << n++ << " of " << gtcHash.size() << endl;
		gtc.open(i->second,Gtc::XFORM | Gtc::INTENSITY);	// reload GTC file to read XForm and Intensity arrays

		for (vector<snpClass>::iterator snp = manifest->snps.begin(); snp != manifest->snps.end(); snp++) {
			if (excludeCnv && snp->name.find("cnv") != string::npos) continue;
			if (chrSelect.size() && chrSelect.compare(snp->chromosome)) continue;
			int idx = snp->index - 1;	// index is zero based in arrays, but starts from 1 in the map file
			unsigned int norm = manifest->normIdMap[snp->normId];
			XFormClass *XF = &gtc.XForm[norm];

			double xn, yn;
			if (normalise) {
				// first do the normalisation calculation
				double tempx = gtc.xRawIntensity[idx] - XF->xOffset;
				double tempy = gtc.yRawIntensity[idx] - XF->yOffset;

				double cos_theta = cos(XF->theta);
				double sin_theta = sin(XF->theta);
				double tempx2 = cos_theta * tempx + sin_theta * tempy;
				double tempy2 = -sin_theta * tempx + cos_theta * tempy;

				double tempx3 = tempx2 - XF->shear * tempy2;
				double tempy3 = tempy2;

				xn = tempx3 / XF->xScale;
				yn = tempy3 / XF->yScale;
			} else {
				xn = gtc.xRawIntensity[idx];
				yn = gtc.yRawIntensity[idx];
			}

			cache[snp->name][cacheIndex] = xn;
			cache[snp->name][cacheIndex+1] = yn;
//.........这里部分代码省略.........
开发者ID:dkj,项目名称:simtools,代码行数:101,代码来源:g2i.cpp

示例12: Callback

void Callback(string dir,WCHAR* X,vector<data*>& Y,hash_map<string,indx>& Z,int label)
{
	std::wstring wstr(X);
	char buf[MAX_SIZE];
	string file(wstr.begin(),wstr.end());
	file=dir+file;
	std::ifstream ifs(file,ifstream::in);
	string temp;
	int pos=0;
	int tos=0;
	int sum=0;
	hash_map<string,indx>::iterator ter;
	hash_map<string,int>::iterator iter;
	while(ifs.good())
	{
		if(label==1)
			positivecnt++;
		else if(label==-1)
			negativecnt++;
		else
			predictcnt++;
		sum=0;
		data* _dt=new data();
		set<attribute,attribute>example;	
		hash_map<string,int>tempo;
		ifs.getline(buf,MAX_SIZE);
		temp.assign(buf);
		if(temp.length()<=1)
			continue;
		while((pos=temp.find_first_of(',',tos+1))!=string::npos)
		{
			if((iter=tempo.find(temp.substr(tos,pos-tos)))!=tempo.end())
			{
				iter->second++;
				sum++;
			}
			else 
			{
				if(temp.substr(tos,pos-tos)!="")
				{
				tempo.insert(pair<string,int>(temp.substr(tos,pos-tos),1));
				sum++;
				}
			}
			tos=pos+1;
			
		}
	
		if((iter=tempo.find(temp.substr(tos)))!=tempo.end())
		{
			iter->second++;
			sum++;
		}
			else
			{
				if(temp.substr(tos,pos-tos)!="")
				{
				tempo.insert(pair<string,int>(temp.substr(tos),1));
				sum++;
				}
		}

		int i;
		for(i=0,iter=tempo.begin();iter!=tempo.end();iter++,i++)
		{
			if(label!=0)
			{
			if((ter=Z.find(iter->first))!=Z.end())
				ter->second.DF++;
			else
			{
			
				indx i;
				i.DF=1;
				i.index=Z.size()+1;
				Z.insert(pair<string,indx>(iter->first,i));
			}
			}
			attribute a;
			a.feature=iter->first;
			a.TF=((double)iter->second)/(double)sum;
			a.index=((ter=Z.find(iter->first))!=Z.end())?ter->second.index:0;
			example.insert(a);		
		}	
		_dt->features=example;
		if(label==1)
		_dt->label=1;
		else if(label==-1)
		_dt->label=-1;
		else
		_dt->label=0;
		Y.push_back(_dt);
		pos=0;
		tos=0;
	}
}
开发者ID:OrlandoChen0308,项目名称:karana,代码行数:96,代码来源:main.cpp

示例13: mapLoadDefaultColour

void mapLoadDefaultColour()
{
    if(g_dayColourUnits.size()&&g_nightColourUnits.size())
    {
        return;
    }
    g_dayColourUnits.clear();
    g_nightColourUnits.clear();

    size_t maxTableSize = sizeof(g_roadColourTable) / sizeof(TMapColourEntry);
    for(size_t i = 0; i < maxTableSize; i++){                            //load road
        ColourUnit cUnit;
        cUnit.type = ROAD_ARC_MISC;
        RGBCOLOUR colour = g_navDisplay->getColour(g_roadColourTable[i].colourIndex);
        cUnit.colour.red = colour.red;
        cUnit.colour.green = colour.green;
        cUnit.colour.blue = colour.blue;
        cUnit.colour.alpha = colour.alpha;
        cUnit.typeIndex = i;
        if(g_dayColourUnits.find(g_roadColourTable[i].legend) == g_dayColourUnits.end())
        {
            g_dayColourUnits.insert(ColourPair(g_roadColourTable[i].legend, cUnit));
            g_nightColourUnits.insert(ColourPair(g_roadColourTable[i].legend, cUnit));
        }

    }
    TElevationPalette *pElevationPalette = g_navDisplay->getElevationPalette();
    for(size_t i = 0; i < numberOfGradients; i++){                       //load gradient
        ColourUnit cUnit;
        if(i < pElevationPalette->elevationThresholdsCount){
            cUnit.type = GRADIENT_ENABLE;
            TElevationPaletteEntry entry = pElevationPalette->elevationPalette[i];
            cUnit.colour.red = entry.r;
            cUnit.colour.green = entry.g;
            cUnit.colour.blue = entry.b;
            cUnit.colour.alpha = entry.elevation;
        }else{
            cUnit.type = GRADIENT_DISABLE;
        }
        if(g_dayColourUnits.find(STR_GRADIENT[i]) == g_dayColourUnits.end())
        {
            g_dayColourUnits.insert(ColourPair(STR_GRADIENT[i], cUnit));
            g_nightColourUnits.insert(ColourPair(STR_GRADIENT[i], cUnit));
        }

    }
    maxTableSize = sizeof(g_polyColourTable) /
            sizeof(TPolyMapColourEntry) - 1;                                   //last one is elevation, so skip
    for(size_t i = 0; i < maxTableSize; i++) {                           //load poly
        ColourUnit cUnit;
        cUnit.type = POLY_CITY;
        RGBCOLOUR colour = g_navDisplay->getPolygonFillColour(g_polyColourTable[i].polyClass);
        cUnit.colour.red = colour.red;
        cUnit.colour.green = colour.green;
        cUnit.colour.blue = colour.blue;
        cUnit.colour.alpha = colour.alpha;
        cUnit.typeIndex = i;
        if(g_dayColourUnits.find(g_polyColourTable[i].polyName) == g_dayColourUnits.end())
        {
            g_dayColourUnits.insert(ColourPair(g_polyColourTable[i].polyName, cUnit));
            g_nightColourUnits.insert(ColourPair(g_polyColourTable[i].polyName, cUnit));
        }

    }
    g_currentColourType = DAY;
}
开发者ID:bgtwoigu,项目名称:Innov_code,代码行数:66,代码来源:interface_map.cpp

示例14: select_map_size

unsigned int select_map_size(){
	return select_sockets_hash_map.size();
}
开发者ID:jilieryuyi,项目名称:wing-php,代码行数:3,代码来源:wing_select_socket_map.c

示例15: read_labels

/// \todo Make some assertion about # of constit. labels, and/or that
/// they are the lowest numbered ones?
void read_labels(const string filename) {
	assert(!open_label_list);

	ifstream fin(filename.c_str());
	assert(fin.is_open());

	_all_labels.clear();
	_all_constituent_labels.clear();
	_all_terminal_labels.clear();
	_max_label = 0;

	label_list.clear();
	label_map.clear();
	terminal_set.clear();
	constituent_set.clear();

	unsigned i, is_terminal, cnt;
	string label;
	while(!fin.eof()) {
		fin >> i >> ws >> is_terminal >> ws >> cnt >> label >> ws;

		if (i == NO_LABEL)
			label = "";

		label_list.push_back(label);
		assert(label_list.at(i) == label);
		label_map[label] = i;	// FIXME: Don't use [] operator

		if (i != NO_LABEL) {
			_all_labels.push_back(i);
			if (is_terminal) {
				terminal_set.insert(i, true);
				_all_terminal_labels.push_back(i);
			} else {
				constituent_set.insert(i, true);
				_all_constituent_labels.push_back(i);
			}
			if (i > _max_label) _max_label = i+1;
		}
	}
	assert(label_list.at(NO_LABEL) == "");
	assert(label_map[""] == NO_LABEL);	// FIXME: Don't use [] operator
	assert(label_list.size() == label_map.size());
//	assert(label_map.size() == terminal_set.size() + constituent_set.size() + 1);
	terminal_set.lock();
	constituent_set.lock();

/*
	Debug::log(1) << "Read " << constituent_set.size() << " constituents, " << \
			terminal_set.size() << " terminals from '" << filename << "'\n";
*/

	fin.close();
	open_label_list = true;

	if (is_label_string("ADJP")) _Label_ADJP = string_to_label("ADJP");
	if (is_label_string("ADVP")) _Label_ADVP = string_to_label("ADVP");
	if (is_label_string("AUX")) _Label_AUX = string_to_label("AUX");
	if (is_label_string("AUXG")) _Label_AUXG = string_to_label("AUXG");
	if (is_label_string("CC")) _Label_CC = string_to_label("CC");
	if (is_label_string("CD")) _Label_CD = string_to_label("CD");
	if (is_label_string("COLON")) _Label_COLON = string_to_label(":");
	if (is_label_string("COMMA")) _Label_COMMA = string_to_label(",");
	if (is_label_string("CONJP")) _Label_CONJP = string_to_label("CONJP");
	if (is_label_string("DOLLAR")) _Label_DOLLAR = string_to_label("$");
	if (is_label_string("DT")) _Label_DT = string_to_label("DT");
	if (is_label_string("EX")) _Label_EX = string_to_label("EX");
	if (is_label_string("FRAG")) _Label_FRAG = string_to_label("FRAG");
	if (is_label_string("FW")) _Label_FW = string_to_label("FW");
	if (is_label_string("HASH")) _Label_HASH = string_to_label("#");
	if (is_label_string("IN")) _Label_IN = string_to_label("IN");
	if (is_label_string("INTJ")) _Label_INTJ = string_to_label("INTJ");
	if (is_label_string("JJ")) _Label_JJ = string_to_label("JJ");
	if (is_label_string("JJR")) _Label_JJR = string_to_label("JJR");
	if (is_label_string("JJS")) _Label_JJS = string_to_label("JJS");
	if (is_label_string("LS")) _Label_LS = string_to_label("LS");
	if (is_label_string("LST")) _Label_LST = string_to_label("LST");
	if (is_label_string("MD")) _Label_MD = string_to_label("MD");
	if (is_label_string("NAC")) _Label_NAC = string_to_label("NAC");
	if (is_label_string("NN")) _Label_NN = string_to_label("NN");
	if (is_label_string("NNP")) _Label_NNP = string_to_label("NNP");
	if (is_label_string("NNPS")) _Label_NNPS = string_to_label("NNPS");
	if (is_label_string("NNS")) _Label_NNS = string_to_label("NNS");
	if (is_label_string("NP")) _Label_NP = string_to_label("NP");
	if (is_label_string("NPB")) _Label_NPB = string_to_label("NPB");
	if (is_label_string("NX")) _Label_NX = string_to_label("NX");
	if (is_label_string("POS")) _Label_POS = string_to_label("POS");
	if (is_label_string("PP")) _Label_PP = string_to_label("PP");
	if (is_label_string("PRN")) _Label_PRN = string_to_label("PRN");
	if (is_label_string("PRP")) _Label_PRP = string_to_label("PRP");
	if (is_label_string("PRPP")) _Label_PRPP = string_to_label("PRP$");
	if (is_label_string("PRT")) _Label_PRT = string_to_label("PRT");
	if (is_label_string("QP")) _Label_QP = string_to_label("QP");
	if (is_label_string("RB")) _Label_RB = string_to_label("RB");
	if (is_label_string("RBR")) _Label_RBR = string_to_label("RBR");
	if (is_label_string("RBS")) _Label_RBS = string_to_label("RBS");
	if (is_label_string("RP")) _Label_RP = string_to_label("RP");
	if (is_label_string("RRC")) _Label_RRC = string_to_label("RRC");
//.........这里部分代码省略.........
开发者ID:arne-cl,项目名称:turian-parser,代码行数:101,代码来源:vocabulary.C


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