static bool compare(map_type const & MA, map_type const & MB)
			{
				std::vector < std::pair<std::string,std::string> > SA, SB;
				for ( typename map_type::const_iterator ita = MA.begin(); ita != MA.end(); ++ita )
					SA.push_back(std::pair<std::string,std::string>(ita->first,ita->second));
				for ( typename map_type::const_iterator ita = MB.begin(); ita != MB.end(); ++ita )
					SB.push_back(std::pair<std::string,std::string>(ita->first,ita->second));
				std::sort(SA.begin(),SA.end());
				std::sort(SB.begin(),SB.end());
				
				uint64_t ia = 0, ib = 0;
				
				for ( ; ia != SA.size() && ib != SB.size() ; ++ia, ++ib )
					if ( SA[ia] != SB[ib] )
					{
						#if 0
						std::cerr << printPair(SA[ia]) << " != " << printPair(SB[ib]) << std::endl;
						
						for ( uint64_t i = 0; i < SA.size(); ++i )
							std::cerr << SA[i].first << ";";
						std::cerr << MA.size();
						std::cerr << std::endl;
						for ( uint64_t i = 0; i < SB.size(); ++i )
							std::cerr << SB[i].first << ";";
						std::cerr << MB.size();
						std::cerr << std::endl;
						#endif
						
						return SA[ia] < SB[ib];
					}

				return ia < ib;
			}
Ejemplo n.º 2
0
void printVector(std::vector<std::pair<int, int>> &vec) {
	for (std::vector<std::pair<int, int> >::iterator iter = vec.begin();
			iter != vec.end(); ++iter)
		printPair(*iter);
	std::cout<<std::endl;

}
Ejemplo n.º 3
0
void combinations(int n, int k) {
    int arr1[k], arr2[k];
    for (int i = 0; i < k; ++i) arr1[i] = i, arr2[i] = i;
    do {
        do {
            printPair(arr1, arr2, k);
        } while (combinationsHelper(arr2, n, k));
    } while (combinationsHelper(arr1, n, k));
}
Ejemplo n.º 4
0
static void
DECLARE4(emitcode, TIFF*, tif, int, dx, int, x, int, count)
{
    CodeEntry* thisCode;

    switch (fax.pass) {
    case 1:    /* count potential code & pair use */
	thisCode = enterCode(x-dx, count);
	thisCode->c.count++;
	if (dopairs) {
	    if (fax.lastCode)
		enterPair(fax.lastCode, thisCode)->c.count++;
	    fax.lastCode = thisCode;
	}
	break;
    case 2:    /* rescan w/ potential codes */
	thisCode = enterCode(x-dx, count);
	if (fax.lastCode) {
	    CodePairEntry* pair = findPair(fax.lastCode, thisCode);
	    if (pair) {
		pair->c.count++;
		fax.lastCode = 0;
	    } else {
		fax.lastCode->c.count++;
		fax.lastCode = thisCode;
	    }
	} else
	    fax.lastCode = thisCode;
	break;
    case 3:    /* generate encoded output */
	thisCode = enterCode(x-dx, count);
	if (dopairs) {
	    if (fax.lastCode) {
		if (!printPair(tif, fax.lastCode, thisCode)) {
		    printCode(tif, fax.lastCode);
		    fax.lastCode = thisCode;
		} else
		    fax.lastCode = 0;
	    } else
		fax.lastCode = thisCode;
	} else
	    printCode(tif, thisCode);
	break;
    }
}
Ejemplo n.º 5
0
void printPair(int fd,
               folly::StringPiece first,
               int64_t second) {
  char buf[24];
  printPair(fd, first, conv_10(second, buf + sizeof buf));
}