void* b3SortedOverlappingPairCache::removeOverlappingPair(int proxy0,int proxy1, b3Dispatcher* dispatcher ) { if (!hasDeferredRemoval()) { b3BroadphasePair findPair(proxy0,proxy1); int findIndex = m_overlappingPairArray.findLinearSearch(findPair); if (findIndex < m_overlappingPairArray.size()) { b3g_overlappingPairs--; b3BroadphasePair& pair = m_overlappingPairArray[findIndex]; cleanOverlappingPair(pair,dispatcher); //if (m_ghostPairCallback) // m_ghostPairCallback->removeOverlappingPair(proxy0, proxy1,dispatcher); m_overlappingPairArray.swap(findIndex,m_overlappingPairArray.capacity()-1); m_overlappingPairArray.pop_back(); return 0; } } return 0; }
void addPairs(struct bacTrack *bt, struct contigTrack *ctList) /* Add in pairs that are contained in ctList. */ { struct contigTrack *ct; int lastIx = ctList->ix; int ix; int a, b; struct contigPair *cp; for (ct = ctList->next; ct != NULL; ct = ct->next) { ix = ct->ix; if (ix < lastIx) { a = ix; b = lastIx; } else { a = lastIx; b = ix; } if ((cp = findPair(bt->gluePairs, a, b)) != NULL) ++cp->useCount; else { AllocVar(cp); cp->ix1 = a; cp->ix2 = b; cp->useCount = 1; slAddHead(&bt->gluePairs, cp); } lastIx = ix; } }
// Driver program to test above function int main() { int arr[] = {1, 8, 30, 40, 100}; int size = sizeof(arr)/sizeof(arr[0]); int n = 60; findPair(arr, size, n); return 0; }
void GeomFeature::Init(const std::vector<mol_setup::Angle>& angles, const BondList& bList) { uint atomsPer = bondsPer + 1; count = angles.size(); if (count == 0) return; //find corresponding bond indices kinds = new uint[count]; bondIndices = new uint[count * bondsPer]; int bondCounter = 0; for (uint i = 0; i < angles.size(); ++i) { bondIndices[bondCounter] = findPair(angles[i].a0, angles[i].a1, bList); ++bondCounter; bondIndices[bondCounter] = findPair(angles[i].a1, angles[i].a2, bList); ++bondCounter; kinds[i] = angles[i].kind; } }
const std::string & ParseArguments::string(const std::string &field, const std::string &default_value) { const std::string *str = findPair(field); if (str == NULL) { return default_value; } else { return *str; } }
int ParseArguments::integer(const std::string &field, int default_value) { const std::string *str = findPair(field); if (str == NULL) { return default_value; } else { return atoi(str->c_str()); } }
int main() { int size; printf("Please enter the number of elements: "); scanf("%d", &size); int arr[size]; int i = 0; for (i = 0; i < size; i++) { arr[i] = 0; } //input the elements into array printf("Please enter %d integers: ", size); i = 0; char c = getchar(); do { c = getchar(); //printf("%d ", c); if (c > 47 && c < 58) { arr[i] = (arr[i] * 10) + (c - '0'); } else if (c == ' ' || c == '\n') { i++; } } while (i < size); for (i = 0; i < size; i++) { //printf("%d ", arr[i]); } printf("Please enter the target sum: "); int sum = 0; scanf("%d", &sum); //printf("sum: %d\n", sum); int one, two; int found = findPair(arr, size, sum, &one, &two); if (found) { printf("found\n"); } else { printf("not found\n"); } return 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; } }
int findCombo(vector<Card> &c) { sort(c.begin(),c.end()); int x=0; if(x=findStreetFlash(c)) { return x; } else if(x=findQuads(c)) { return x; } else if(x=findFulHouse(c)) { return x; } else if(x=findFlash(c)) { return x; } else if(x=findStreet(c)) { return x; } else if(x=findSet(c)) { return x; } else if(x=findTwoPair(c)) { return x; } else if(x=findPair(c)) { return x; } else { return kikirInDiap(c,0,c.size()); } return 0; }
void* btSortedOverlappingPairCache::removeOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1, btDispatcher* dispatcher ) { if (!hasDeferredRemoval()) { btBroadphasePair findPair(*proxy0,*proxy1); int findIndex = m_overlappingPairArray.findLinearSearch(findPair); if (findIndex < m_overlappingPairArray.size()) { btBroadphasePair& pair = m_overlappingPairArray[findIndex]; void* userData = pair.m_internalInfo1; cleanOverlappingPair(pair,dispatcher); if (m_ghostPairCallback) m_ghostPairCallback->removeOverlappingPair(proxy0, proxy1,dispatcher); m_overlappingPairArray.swap(findIndex,m_overlappingPairArray.capacity()-1); m_overlappingPairArray.pop_back(); return userData; } } return 0; }
int findTwoPair(vector<Card> &c) { int x=findPair(c); int r=0; int counter=0; if(!x) { return false; } else { for(int i=0;i<c.size();i++) { for(int j=0;j<c.size();j++) { if((c[i].value==c[j].value && i!=j) && c[i].value!=(x-200)) { counter++; } } if(counter==1) { r=c[i].value; } counter=0; } if(r) { //cout<<x<<" "<<r<<endl; if((x-200)>r) return 100+x; else 300+r; } return false; } }
void Process(const btDbvtNode* leaf0,const btDbvtNode* leaf1) { m_numOverlapPairs++; int childIndex0 = leaf0->dataAsInt; int childIndex1 = leaf1->dataAsInt; btAssert(childIndex0>=0); btAssert(childIndex1>=0); const btCompoundShape* compoundShape0 = static_cast<const btCompoundShape*>(m_compound0ColObjWrap->getCollisionShape()); btAssert(childIndex0<compoundShape0->getNumChildShapes()); const btCompoundShape* compoundShape1 = static_cast<const btCompoundShape*>(m_compound1ColObjWrap->getCollisionShape()); btAssert(childIndex1<compoundShape1->getNumChildShapes()); const btCollisionShape* childShape0 = compoundShape0->getChildShape(childIndex0); const btCollisionShape* childShape1 = compoundShape1->getChildShape(childIndex1); //backup btTransform orgTrans0 = m_compound0ColObjWrap->getWorldTransform(); const btTransform& childTrans0 = compoundShape0->getChildTransform(childIndex0); btTransform newChildWorldTrans0 = orgTrans0*childTrans0 ; btTransform orgTrans1 = m_compound1ColObjWrap->getWorldTransform(); const btTransform& childTrans1 = compoundShape1->getChildTransform(childIndex1); btTransform newChildWorldTrans1 = orgTrans1*childTrans1 ; //perform an AABB check first btVector3 aabbMin0,aabbMax0,aabbMin1,aabbMax1; childShape0->getAabb(newChildWorldTrans0,aabbMin0,aabbMax0); childShape1->getAabb(newChildWorldTrans1,aabbMin1,aabbMax1); if (gCompoundCompoundChildShapePairCallback) { if (!gCompoundCompoundChildShapePairCallback(childShape0,childShape1)) return; } if (TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1)) { btCollisionObjectWrapper compoundWrap0(this->m_compound0ColObjWrap,childShape0, m_compound0ColObjWrap->getCollisionObject(),newChildWorldTrans0,-1,childIndex0); btCollisionObjectWrapper compoundWrap1(this->m_compound1ColObjWrap,childShape1,m_compound1ColObjWrap->getCollisionObject(),newChildWorldTrans1,-1,childIndex1); btSimplePair* pair = m_childCollisionAlgorithmCache->findPair(childIndex0,childIndex1); btCollisionAlgorithm* colAlgo = 0; if (pair) { colAlgo = (btCollisionAlgorithm*)pair->m_userPointer; } else { colAlgo = m_dispatcher->findAlgorithm(&compoundWrap0,&compoundWrap1,m_sharedManifold); pair = m_childCollisionAlgorithmCache->addOverlappingPair(childIndex0,childIndex1); btAssert(pair); pair->m_userPointer = colAlgo; } btAssert(colAlgo); const btCollisionObjectWrapper* tmpWrap0 = 0; const btCollisionObjectWrapper* tmpWrap1 = 0; tmpWrap0 = m_resultOut->getBody0Wrap(); tmpWrap1 = m_resultOut->getBody1Wrap(); m_resultOut->setBody0Wrap(&compoundWrap0); m_resultOut->setBody1Wrap(&compoundWrap1); m_resultOut->setShapeIdentifiersA(-1,childIndex0); m_resultOut->setShapeIdentifiersB(-1,childIndex1); colAlgo->processCollision(&compoundWrap0,&compoundWrap1,m_dispatchInfo,m_resultOut); m_resultOut->setBody0Wrap(tmpWrap0); m_resultOut->setBody1Wrap(tmpWrap1); } }