本文整理汇总了C++中Pairs类的典型用法代码示例。如果您正苦于以下问题:C++ Pairs类的具体用法?C++ Pairs怎么用?C++ Pairs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pairs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeEstimate
static void writeEstimate(ostream& out,
const ContigNode& id0, const ContigNode& id1,
unsigned len0, unsigned len1,
const Pairs& pairs, const PMF& pmf)
{
if (pairs.size() < opt::npairs)
return;
DistanceEst est;
est.distance = estimateDistance(len0, len1,
pairs, pmf, est.numPairs);
est.stdDev = pmf.getSampleStdDev(est.numPairs);
std::pair<ContigNode, ContigNode> e(id0, id1 ^ id0.sense());
if (est.numPairs >= opt::npairs) {
if (opt::format == DOT) {
#pragma omp critical(out)
out << get(g_contigNames, e) << " [" << est << "]\n";
} else
out << ' ' << get(g_contigNames, id1) << ',' << est;
} else if (opt::verbose > 1) {
#pragma omp critical(cerr)
cerr << "warning: " << get(g_contigNames, e)
<< " [d=" << est.distance << "] "
<< est.numPairs << " of " << pairs.size()
<< " pairs fit the expected distribution\n";
}
}
示例2: onMeta
void WebLoadManager::onMeta() {
QNetworkReply *reply = qobject_cast<QNetworkReply*>(QObject::sender());
if (!reply) return;
Replies::iterator j = _replies.find(reply);
if (j == _replies.cend()) { // handled already
return;
}
webFileLoaderPrivate *loader = j.value();
typedef QList<QNetworkReply::RawHeaderPair> Pairs;
Pairs pairs = reply->rawHeaderPairs();
for (Pairs::iterator i = pairs.begin(), e = pairs.end(); i != e; ++i) {
if (QString::fromUtf8(i->first).toLower() == "content-range") {
QRegularExpressionMatch m = QRegularExpression(qsl("/(\\d+)([^\\d]|$)")).match(QString::fromUtf8(i->second));
if (m.hasMatch()) {
loader->setProgress(qMax(qint64(loader->data().size()), loader->already()), m.captured(1).toLongLong());
if (!handleReplyResult(loader, WebReplyProcessProgress)) {
_replies.erase(j);
_loaders.remove(loader);
delete loader;
reply->abort();
reply->deleteLater();
}
}
}
}
}
示例3: dAASSERT
void dxSAPSpace::collide (void *data, dNearCallback *callback)
{
dAASSERT (callback);
lock_count++;
cleanGeoms();
// by now all geoms are in GeomList, and DirtyList must be empty
int geomSize = GeomList.size();
dUASSERT( geomSize == count, "geom counts messed up" );
// separate all geoms into infinite AABBs and normal AABBs
TmpGeomList.setSize(0);
TmpInfGeomList.setSize(0);
int axis0max = SortAxes.mAxis0*2+1;
for( int i = 0; i < geomSize; ++i ) {
dxGeom* g =GeomList[i];
if( !GEOM_ENABLED(g) ) // skip disabled ones
continue;
const dReal& amax = g->aabb[axis0max];
if( amax == dInfinity ) // HACK? probably not...
TmpInfGeomList.push( g );
else
TmpGeomList.push( g );
}
// do SAP on normal AABBs
Pairs overlapBoxes;
bool isok = complete_box_pruning( TmpGeomList.size(), (const dxGeom**)TmpGeomList.data(), overlapBoxes, SortAxes );
// collide overlapping
udword overlapCount = overlapBoxes.GetNbPairs();
for( udword j = 0; j < overlapCount; ++j ) {
const Pair* pair = overlapBoxes.GetPair(j);
dxGeom* g1 = TmpGeomList[pair->id0];
dxGeom* g2 = TmpGeomList[pair->id1];
collideGeomsNoAABBs( g1, g2, data, callback );
}
int infSize = TmpInfGeomList.size();
int normSize = TmpGeomList.size();
int m, n;
for( m = 0; m < infSize; ++m ) {
dxGeom* g1 = TmpInfGeomList[m];
// collide infinite ones
for( n = m+1; n < infSize; ++n ) {
dxGeom* g2 = TmpInfGeomList[n];
collideGeomsNoAABBs( g1, g2, data, callback );
}
// collide infinite ones with normal ones
for( n = 0; n < normSize; ++n ) {
dxGeom* g2 = TmpGeomList[n];
collideGeomsNoAABBs( g1, g2, data, callback );
}
}
lock_count--;
}
示例4: myhash
void mapHM::set(string key, int value){
int hash_value = myhash(&*key.begin(), key.length(), size_of_table);
if (!(is_in(key))){
Pairs p;
p.setPairs(key, value);
arrayOfPairs[hash_value].add(p);
}
}
示例5: main
int
main(void)
{
Pairs pairs;
pairs.Run();
return 0;
}
示例6: gb
// complete algorithm to compute a Groebner basis F
void gb( IntermediateBasis &F, int n) {
int nextIndex = F.size();
rearrangeBasis(F, -1);
interreduction(F);
Pairs B = makeList(F, n);
//unsigned int countAddPoly = 0;
//unsigned int numSPoly= 0;
int interreductionCounter = 0;
while (!B.empty()) {
Pair pair = *(B.begin());
B.erase(B.begin());
if (isGoodPair(pair,F,B,n)) {
//numSPoly++;
BRP S = sPolynomial(pair,F,n);
reduce(S,F);
if ( ! S.isZero() ) {
//countAddPoly++;
F[nextIndex] = S;
if(interreductionCounter == 5) {
interreductionCounter = 0;
interreduction(F);
B = makeList(F, n);
} else {
interreductionCounter++;
Pairs newList = makeNewPairs(nextIndex, F, n);
B.insert(newList.begin(), newList.end());
}
nextIndex++;
}
}
}
interreduction(F);
//cout << "we computed " << numSPoly << " S Polynomials and added " << countAddPoly << " of them to the intermediate basis." << endl;
}
示例7: main
int main(int argc, char** argv)
{
FTAGArgs args;
args.getArgs(argc, argv);
srand48(args._seed);
cout << "SEED=" << args._seed << endl;
ofstream ofile(args._outFile.c_str());
if (!ofile)
{
cerr << "Specifiy output file with ofile=<path>" << endl;
exit(1);
}
ofstream pfile(args._fpFileOut.c_str());
AxtReader ar;
try
{
ar.read(args._inFile);
const vector<AxtPair>& wholeThing = ar.getAlignments();
Pairs allAlignments;
for (size_t i = 0; i < wholeThing.size(); ++i)
{
allAlignments.push_back(wholeThing[i].getAlignment());
}
Pairs alignments = ar.sample(args._numPairs, args._maxLength / 2,
args._maxLength, 0, false);
FTAGParams parAll = estParams(allAlignments, args._symmetric);
FTAGParams parInput = estParams(alignments, args._symmetric);
cout << "From Whole File: " << parAll << endl;
cout << "From input: " << parInput << endl;
ofile << alignments;
if (pfile.is_open())
{
pfile << parInput;
}
}
catch(string message)
{
cerr << message << endl;
return 1;
}
return 0;
}
示例8: partMetaGot
void PsUpdateDownloader::partMetaGot() {
typedef QList<QNetworkReply::RawHeaderPair> Pairs;
Pairs pairs = reply->rawHeaderPairs();
for (Pairs::iterator i = pairs.begin(), e = pairs.end(); i != e; ++i) {
if (QString::fromUtf8(i->first).toLower() == "content-range") {
QRegularExpressionMatch m = QRegularExpression(qsl("/(\\d+)([^\\d]|$)")).match(QString::fromUtf8(i->second));
if (m.hasMatch()) {
{
QMutexLocker lock(&mutex);
full = m.captured(1).toInt();
}
emit App::app()->updateDownloading(already, full);
}
}
}
}
示例9: makeNewPairs
// generate list of index pairs for a new index and an intermediate basis
Pairs makeNewPairs(int newIndex, const IntermediateBasis &F, int n) {
Pairs B;
Pairs::iterator position = B.begin();
for(int i=-n; i<0; i++) {
Pair pair = Pair(i, newIndex, F);
position = B.insert(position, pair);
}
IntermediateBasis::const_iterator end = F.end();
end--;
for(IntermediateBasis::const_iterator iter = F.begin(); iter != end; ++iter) {
int j = iter->first;
Pair pair = Pair(newIndex, j, F);
if (pair.good) {
position = B.insert(position, pair);
}
}
return B;
}
示例10: makeList
// generate list of index pairs for given intermediate basis
// first insert all pairs with FPs, then insert pairs of all other polynomials
// the list of indeces was ordered by increasingly
Pairs makeList(const IntermediateBasis &F, int n) {
Pairs B;
Pairs::iterator position = B.begin();
IntermediateBasis::const_iterator end = F.end();
for(IntermediateBasis::const_iterator iter = F.begin(); iter != end; ++iter) {
int j = iter->first;
for(int i=-n; i<0; i++) {
Pair pair = Pair(i, j, F);
position = B.insert(position, pair);
}
for(int i=0; i<j; i++) {
Pair pair = Pair(i, j, F);
if (pair.good) {
position = B.insert(position, pair);
}
}
}
return B;
}
示例11: findPairs
void findPairs( _Adapter& model, Pairs& pairs, double d_box )
{
model.reset();
while( model.hasNext() )
{
_TreeNode node = model.next();
std::pair<typename tree_type::const_iterator,double> found = kdtree.find_nearest(node, d_box);
if( found.first != kdtree.end() && filter(node, *(found.first)) )
pairs.add((found.first)->point, node.point, found.second);
}
}
示例12: _align
/** performs a single alignment of the measurement to the model.
* The model needs to be added using addToModel before this call.
*
* @param measurement - the mesh that needs to be matched
* @param max_iter - maximum number of iterations
* @param min_mse - minimum average square distance between points after which to stop
* @param min_mse_diff - minimum difference in average square distance between points after which to stop
* @param overlap - percentage of overlap, range between [0..1]. A value of
* 0.95 will discard 5% of the pairs with the worst matches
*/
Result _align( _Adapter measurement, size_t max_iter, double min_mse, double min_mse_diff, double overlap )
{
Result result;
Pairs pairs;
result.C_global2globalnew = Eigen::Affine3d::Identity();
result.iter = 0;
result.overlap = overlap;
result.d_box = std::numeric_limits<double>::infinity();
result.mse_diff = result.mse = std::numeric_limits<double>::infinity();
double old_mse = result.mse;
while( result.iter < max_iter && result.mse > min_mse && result.mse_diff > min_mse_diff )
{
old_mse = result.mse;
pairs.clear();
findPairs.findPairs( measurement, pairs, result.d_box );
const size_t n_po = measurement.size() * result.overlap;
result.d_box = pairs.trim( n_po ) * 2.0;
result.pairs = pairs.size();
if( result.pairs < Pairs::MIN_PAIRS )
return result;
Eigen::Affine3d C_globalprev2globalnew = pairs.getTransform();
result.C_global2globalnew = C_globalprev2globalnew * result.C_global2globalnew;
measurement.setOffsetTransform( result.C_global2globalnew );
result.mse = pairs.getMeanSquareError();
result.mse_diff = old_mse - result.mse;
result.iter++;
// std::cout
// << "points: " << measurement.size()
// << "\titer: " << result.iter
// << "\tpairs: " << pairs.size()
// << "\tmse: " << result.mse
// << "\tmse_diff: " << result.mse_diff
// << "\td_box: " << result.d_box
// << "\toverlap: " << result.overlap
// << std::endl;
}
// std::cout
// << std::endl;
std::vector<double> pairs_distance;
for( size_t i = 0; i < pairs.size(); i++ ) {
pairs_distance.push_back( pairs.pairs[i].distance );
}
result.pairs_distance = pairs_distance;
return result;
}
示例13: BruteForceCompleteBoxTest
bool Opcode::BruteForceCompleteBoxTest(udword nb, const AABB** array, Pairs& pairs)
{
// Checkings
if(!nb || !array) return false;
// Brute-force n(n-1)/2 overlap tests
for(udword i=0;i<nb;i++)
{
for(udword j=i+1;j<nb;j++)
{
if(array[i]->Intersect(*array[j])) pairs.AddPair(i, j);
}
}
return true;
}
示例14: BruteForceBipartiteBoxTest
bool Opcode::BruteForceBipartiteBoxTest(udword nb0, const AABB** array0, udword nb1, const AABB** array1, Pairs& pairs)
{
// Checkings
if(!nb0 || !array0 || !nb1 || !array1) return false;
// Brute-force nb0*nb1 overlap tests
for(udword i=0;i<nb0;i++)
{
for(udword j=0;j<nb1;j++)
{
if(array0[i]->Intersect(*array1[j])) pairs.AddPair(i, j);
}
}
return true;
}
示例15: BipartiteBoxPruning
bool Opcode::BipartiteBoxPruning(udword nb0, const AABB** array0, udword nb1, const AABB** array1, Pairs& pairs, const Axes& axes)
{
// Checkings
if(!nb0 || !array0 || !nb1 || !array1) return false;
// Catch axes
udword Axis0 = axes.mAxis0;
udword Axis1 = axes.mAxis1;
udword Axis2 = axes.mAxis2;
// Allocate some temporary data
float* MinPosList0 = new float[nb0];
float* MinPosList1 = new float[nb1];
// 1) Build main lists using the primary axis
for(udword i=0;i<nb0;i++) MinPosList0[i] = array0[i]->GetMin(Axis0);
for(udword i=0;i<nb1;i++) MinPosList1[i] = array1[i]->GetMin(Axis0);
// 2) Sort the lists
PRUNING_SORTER* RS0 = GetBipartitePruningSorter0();
PRUNING_SORTER* RS1 = GetBipartitePruningSorter1();
const udword* Sorted0 = RS0->Sort(MinPosList0, nb0).GetRanks();
const udword* Sorted1 = RS1->Sort(MinPosList1, nb1).GetRanks();
// 3) Prune the lists
udword Index0, Index1;
const udword* const LastSorted0 = &Sorted0[nb0];
const udword* const LastSorted1 = &Sorted1[nb1];
const udword* RunningAddress0 = Sorted0;
const udword* RunningAddress1 = Sorted1;
while(RunningAddress1<LastSorted1 && Sorted0<LastSorted0)
{
Index0 = *Sorted0++;
while(RunningAddress1<LastSorted1 && MinPosList1[*RunningAddress1]<MinPosList0[Index0]) RunningAddress1++;
const udword* RunningAddress2_1 = RunningAddress1;
while(RunningAddress2_1<LastSorted1 && MinPosList1[Index1 = *RunningAddress2_1++]<=array0[Index0]->GetMax(Axis0))
{
if(array0[Index0]->Intersect(*array1[Index1], Axis1))
{
if(array0[Index0]->Intersect(*array1[Index1], Axis2))
{
pairs.AddPair(Index0, Index1);
}
}
}
}
////
while(RunningAddress0<LastSorted0 && Sorted1<LastSorted1)
{
Index0 = *Sorted1++;
while(RunningAddress0<LastSorted0 && MinPosList0[*RunningAddress0]<=MinPosList1[Index0]) RunningAddress0++;
const udword* RunningAddress2_0 = RunningAddress0;
while(RunningAddress2_0<LastSorted0 && MinPosList0[Index1 = *RunningAddress2_0++]<=array1[Index0]->GetMax(Axis0))
{
if(array0[Index1]->Intersect(*array1[Index0], Axis1))
{
if(array0[Index1]->Intersect(*array1[Index0], Axis2))
{
pairs.AddPair(Index1, Index0);
}
}
}
}
DELETEARRAY(MinPosList1);
DELETEARRAY(MinPosList0);
return true;
}