bool Tringle::isPointOutTringle (const Point& p) const { Tringle temp1 (first, second, p); Tringle temp2 (second, third, p); Tringle temp3 (third, first, p); if (temp1.square() + temp2.square() + temp3.square() == this->square()) return false; return true; }
void smatrix::transpose() { for (node *cursor = head_ptr; cursor != NULL; cursor = cursor->link()) { entry temp1(cursor->data().c, cursor->data().r, cursor->data().v); cursor->set_data(temp1); } }
void crossing::crossover() { std::vector<unsigned int> chosen; std::default_random_engine generator; std::uniform_real_distribution<double> distribution(0.0,1.0); std::vector<double> randomvector(fpop.size(), 0.0); for(unsigned int i=0; i < fpop.size(); i++ ) { randomvector[i] = distribution(generator); if(randomvector[i] < 0.25) { chosen.push_back(i); //std::cout<<"i = "<<i<<std::endl; } } if((chosen.size()%2 != 0) || (chosen.size() == 1)) { chosen.pop_back(); } Chromosome temp1(fpop[0].size(), 0.0); Chromosome temp2(fpop[0].size(), 0.0); unsigned int position = static_cast<unsigned int>(distribution(generator)*fpop[0].size()); //std::cout<<"fpop size = "<<fpop.size()<<std::endl; //std::cout<<" position = "<<position<<std::endl; #pragma omp parallel for for(unsigned int i = 0; i < chosen.size(); i = i+2) { std::copy(fpop[chosen[i]].begin(), fpop[chosen[i]].end(), temp1.begin() ); std::copy(fpop[chosen[i+1]].begin(), fpop[chosen[i+1]].end(), temp2.begin() ); //#pragma omp parallel for for(unsigned int k = position; k<fpop[0].size(); k++) { temp1[k] = fpop[chosen[i+1]][k]; temp2[k] = fpop[chosen[i]][k]; //std::cout<<" end number chosen = "<<chosen.size()<<std::endl; std::copy(temp1.begin(), temp1.end(), fpop[chosen[i]].begin() ); std::copy(temp2.begin(), temp2.end(), fpop[chosen[i+1]].begin() ); } } }
//! \brief Apply the multiplier block with an embedded axpy //! \param[in] alpha The scalar to scale with //! \param[in] x The vector to apply the operator to //! \param[out] y The result of the operator evaluation void applyscaleadd(field_type alpha, const Vector& x, Vector& y) const { Vector temp1(B.N()); B.mv(x, temp1); Vector temp(temp1.size()); Dune::InverseOperatorResult res; temp = 0; op.apply(temp, temp1); B.usmtv(alpha, temp, y); }
PRBool nsStaticCaseInsensitiveNameTable::Init(const char* const aNames[], PRInt32 Count) { NS_ASSERTION(!mNameArray, "double Init"); NS_ASSERTION(!mNameTable.ops, "double Init"); NS_ASSERTION(aNames, "null name table"); NS_ASSERTION(Count, "0 count"); mNameArray = (nsDependentCString*) nsMemory::Alloc(Count * sizeof(nsDependentCString)); if (!mNameArray) return PR_FALSE; if (!PL_DHashTableInit(&mNameTable, &nametable_CaseInsensitiveHashTableOps, nsnull, sizeof(NameTableEntry), Count)) { mNameTable.ops = nsnull; return PR_FALSE; } for (PRInt32 index = 0; index < Count; ++index) { const char* raw = aNames[index]; #ifdef DEBUG { // verify invariants of contents nsCAutoString temp1(raw); nsDependentCString temp2(raw); ToLowerCase(temp1); NS_ASSERTION(temp1.Equals(temp2), "upper case char in table"); NS_ASSERTION(nsCRT::IsAscii(raw), "non-ascii string in table -- " "case-insensitive matching won't work right"); } #endif // use placement-new to initialize the string object nsDependentCString* strPtr = &mNameArray[index]; new (strPtr) nsDependentCString(raw); NameTableKey key(strPtr); NameTableEntry *entry = static_cast<NameTableEntry*> (PL_DHashTableOperate(&mNameTable, &key, PL_DHASH_ADD)); if (!entry) continue; NS_ASSERTION(entry->mString == 0, "Entry already exists!"); entry->mString = strPtr; // not owned! entry->mIndex = index; } return PR_TRUE; }
hMatrix Pseudo_Inverse(hMatrix Mat){ int row = Mat.GetRow(), col = Mat.GetCol(); hMatrix trans(col,row); trans =Transpose(Mat); hMatrix temp1(row,row); temp1 = Inverse(Mat*trans); hMatrix temp2(col,row); temp2 = trans*temp1; return temp2; }
std::vector<PID::Produce> makeArray() { string a; std::vector<PID::Produce> temp; for (int i = 1; i <= 1; i++) { a = "resources/" + std::to_string(i) + ".jpg"; IP::ImageProcessor temp1(a); temp1.exportData(); temp.push_back(BP::BarcodeProcessing::parse_produce()); } return temp; }
Machine::Machine() { std::shared_ptr<stack_t> temp1(new stack_t); std::shared_ptr<stack_t> temp2(new stack_t); std::shared_ptr<stack_t> temp3(new stack_t); D = nullptr; S = temp1; E = temp2; C = temp3; }
CBC_CommonPerspectiveTransform* CBC_CommonPerspectiveTransform::QuadrilateralToSquare(FX_FLOAT x0, FX_FLOAT y0, FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2, FX_FLOAT x3, FX_FLOAT y3) { std::unique_ptr<CBC_CommonPerspectiveTransform> temp1( SquareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3)); return temp1->BuildAdjoint(); }
ColorMap::ColorMap(int _width, int _heidht) : width(_width + 1) , height(_heidht + 1) { for (int i = 0; i < width; i++) { vector<double> temp(height, 0); vector<double> temp1(height, 0); vector<double> temp2(height, 0); red.push_back(temp); green.push_back(temp1); blue.push_back(temp2); } }
void gmm::mult(const gmm::GMMGSmoothAMatrix &m, const std::vector<double> &x, std::vector<double> &y) { std::vector<double> temp1(m.B->nrows()), temp2(m.P->nrows()); gmm::mult(*m.B, x, temp1); //temp1 = G * x; gmm::mult(*m.P, temp1, temp2); //temp2 = P * temp1; gmm::mult(gmm::transposed(*m.P), temp2, temp1); //temp1 = P.trans_mult(temp2); gmm::mult(gmm::transposed(*m.B), temp1, y); //temp2 = G.trans_mult(temp1); gmm::mult(*m.S, x, y, y); }
//通过引用,修改rotation和scale,使shape1和shape2差距最小 void SimilarityTransform(const Mat_<double>& shape1, const Mat_<double>& shape2, Mat_<double>& rotation, double& scale) { rotation = Mat::zeros(2, 2, CV_64FC1); scale = 0; // center the data double center_x_1 = 0; double center_y_1 = 0; double center_x_2 = 0; double center_y_2 = 0; for (int i = 0; i < shape1.rows; i++) { center_x_1 += shape1(i, 0); center_y_1 += shape1(i, 1); center_x_2 += shape2(i, 0); center_y_2 += shape2(i, 1); } center_x_1 /= shape1.rows; center_y_1 /= shape1.rows; center_x_2 /= shape2.rows; center_y_2 /= shape2.rows; Mat_<double> temp1 = shape1.clone(); Mat_<double> temp2 = shape2.clone(); for (int i = 0; i < shape1.rows; i++) { temp1(i, 0) -= center_x_1; temp1(i, 1) -= center_y_1; temp2(i, 0) -= center_x_2; temp2(i, 1) -= center_y_2; } //至此,temp1(与shape1形状相同)和temp2(与shape2形状相同)已经移到了以(0,0)为原点的坐标系 Mat_<double> covariance1, covariance2; //covariance = 协方差 Mat_<double> mean1, mean2; // calculate covariance matrix calcCovarMatrix(temp1, covariance1, mean1, CV_COVAR_COLS); //输出covariance1为temp1的协方差,mean1为temp1的均值 calcCovarMatrix(temp2, covariance2, mean2, CV_COVAR_COLS); double s1 = sqrt(norm(covariance1)); //norm用来计算covariance1的L2范数 double s2 = sqrt(norm(covariance2)); scale = s1 / s2; temp1 = 1.0 / s1 * temp1; temp2 = 1.0 / s2 * temp2; // 至此,通过缩放,temp1和temp2的差距最小(周叔说,这是最小二乘法) double num = 0; double den = 0; for (int i = 0; i < shape1.rows; i++) { num = num + temp1(i, 1) * temp2(i, 0) - temp1(i, 0) * temp2(i, 1); den = den + temp1(i, 0) * temp2(i, 0) + temp1(i, 1) * temp2(i, 1); } double norm = sqrt(num * num + den * den); double sin_theta = num / norm; double cos_theta = den / norm; rotation(0, 0) = cos_theta; rotation(0, 1) = -sin_theta; rotation(1, 0) = sin_theta; rotation(1, 1) = cos_theta; }
void gmm::mult(const gmm::GMMGSmoothAMatrix &m, const gmm::VectorRef &ref, const std::vector<double> &v, std::vector<double>& y) { std::vector<double> x(m.B->ncols()), temp1(m.B->nrows()), temp2(m.P->nrows()); x.assign(ref.begin_, ref.end_); mult(*m.B, x, temp1); //temp1 = G * x; gmm::mult(*m.P, temp1, temp2); //temp2 = P * temp1; gmm::mult(gmm::transposed(*m.P), temp2, temp1); //temp1 = P.trans_mult(temp2); gmm::mult(gmm::transposed(*m.B), temp1, y); //temp2 = G.trans_mult(temp1); gmm::mult(*m.S, x, y, y); gmm::add(v, y, y); }
void make(vector<int>& A, vector<int> temp, int curr, vector<vector<int> >& ans){ int n = A.size(); ans.push_back(temp); if(curr == n){ return; } for(int i = curr; i < n; i++){ vector<int> temp1(temp); temp1.push_back(A[i]); make(A, temp1, i+1, ans); } }
Polynom Polynom::operator^(Polynom degree) { Polynom temp = *this; Complex<int> temp1(1,0); Polynom res(temp1,0); int deg = (degree.coefB[0].getRe()).getInt(); while (deg) { if (deg & 1) res = res * temp; temp = temp * temp; deg >>= 1; } return res; }
/* This is a very simple main function used here for testing. It * instantiates 2 processing objects. The parameters are then changed * in the observable parameter object. The processing objects should * then update themselves and so the last "cout" calls should reveal the * new parameters. At least, this is what I would like to happen!*/ int main(int argc, char *argv[]) { kPublisher Publisher; kSubscriber temp0(Publisher, 0); kSubscriber temp1(Publisher, 1); std::cout << "Processing unit " << 0 << " param = " << temp0.getParam() << std::endl; std::cout << "Processing unit " << 1 << " param = " << temp1.getParam() << std::endl; Publisher.changePars(); std::cout << "Processing unit " << 0 << " param = " << temp0.getParam() << std::endl; std::cout << "Processing unit " << 1 << " param = " << temp1.getParam() << std::endl; std::cin.get(); }
void spreadsheet::save_spreadsheet(std::string filename) { string File = "../Saves";// one dot local two for parent string cell_info; string cell_name; string cell_contents; // heavily modified code from Ingo Leonhardt but seems really basic once you understand it http://stackoverflow.com/questions/18100097/portable-way-to-check-if-directory-exists-windows-linux-c /* struct stat info; if( stat( File.c_str(), &info ) != 0 )//changed pathname to file printf( "cannot access %s\n", File.c_str()); else if( info.st_mode & S_IFDIR ) printf( "%s is a directory\n", File.c_str()); else{ printf( "%s is no directory creating one \n", File.c_str()); // modified mkdir(File.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); // my line of code }*/ //end of cited code string full_name = filename; ofstream save_file(full_name.c_str()); if (save_file.is_open()){ for (map<string, string>::iterator it = cells.begin(); it != cells.end(); ++it){ cell_name = it->first; cell_contents = it->second; string temp1(cell_name); string temp2(cell_contents); string cell_info = temp1 + "|" + temp2; save_file << cell_info << endl; } } }
void draw(color_t** arr, int arr_w, int arr_h) { int num_vertices = vertices.size(); if (num_vertices < 3) return; else { list<point_t>::iterator itr = vertices.begin(); point_t temp(itr->x, itr->y); vertices.push_back(temp); for (int i = 0 ; i < num_vertices ; i++) { point_t temp1(itr->x, itr->y); itr++; point_t temp2(itr->x, itr->y); line_t edge(temp1, temp2, border); edge.draw(arr, arr_w, arr_h); } vertices.pop_back(); } }
void triangulate(){ bool pit; pit = true;//points in triangle, assume there are points in the given tri unsigned int i = 0; vector<V3> vec; vector<V3> temp(Points); vector<double> temp1(pointsType); if(Points.size()>0){ while(Points.size() > 2 && i < Points.size()){ pit = true; if(Points.size() == 3){ vec.push_back(Points.at(0)); vec.push_back(Points.at(1)); vec.push_back(Points.at(2)); Tris.push_back(vec); vec.clear(); break; } if(getPointType(i) == CONVEX){ cout<<"CONVEX\n"; if(i == 0) pit = checkTriangle(i, i + 1, Points.size() - 1, Points); else pit = checkTriangle(i, i + 1, i - 1, Points); if(pit){ if(i == 0){ vec.push_back(Points.at(i)); vec.push_back(Points.at(i + 1)); vec.push_back(Points.at(Points.size() - 1)); Tris.push_back(vec); vec.clear(); }else{ vec.push_back(Points.at(i)); vec.push_back(Points.at(i + 1));vec.push_back(Points.at(i - 1)); Tris.push_back(vec); vec.clear(); } Points.erase (Points.begin() + i); pointsType.erase (pointsType.begin() + i); }else{ i++; } }else{ i++; } } } pointsType = temp1; Points = temp; }
inline void operator()(const IrradianceSample &sample) { /* Distance to the positive point source of the dipole */ const __m128 lengthSquared = _mm_set1_ps((p - sample.p).lengthSquared()), drSqr = _mm_add_ps(zrSqr, lengthSquared), dvSqr = _mm_add_ps(zvSqr, lengthSquared), dr = _mm_sqrt_ps(drSqr), dv = _mm_sqrt_ps(dvSqr), one = _mm_set1_ps(1.0f), factor = _mm_mul_ps(_mm_set1_ps(0.25f*INV_PI*sample.area * Fdt), _mm_set_ps(sample.E[0], sample.E[1], sample.E[2], 0)), C1fac = _mm_div_ps(_mm_mul_ps(zr, _mm_add_ps(sigmaTr, _mm_div_ps(one, dr))), drSqr), C2fac = _mm_div_ps(_mm_mul_ps(zv, _mm_add_ps(sigmaTr, _mm_div_ps(one, dv))), dvSqr); SSEVector temp1(_mm_mul_ps(dr, sigmaTr)), temp2(_mm_mul_ps(dv, sigmaTr)); const __m128 exp1 = _mm_set_ps(expf(-temp1.f[3]), expf(-temp1.f[2]), expf(-temp1.f[1]), 0), exp2 = _mm_set_ps(expf(-temp2.f[3]), expf(-temp2.f[2]), expf(-temp2.f[1]), 0); result.ps = _mm_add_ps(result.ps, _mm_mul_ps(factor, _mm_add_ps( _mm_mul_ps(C1fac, exp1), _mm_mul_ps(C2fac, exp2)))); }
CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly* other, int32_t& e) { if (other->IsZero()) { e = BCExceptionDivideByZero; BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } CBC_ReedSolomonGF256Poly* rsg1 = m_field->GetZero()->Clone(e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); CBC_AutoPtr<CBC_ReedSolomonGF256Poly> quotient(rsg1); CBC_ReedSolomonGF256Poly* rsg2 = this->Clone(e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); CBC_AutoPtr<CBC_ReedSolomonGF256Poly> remainder(rsg2); int32_t denominatorLeadingTerm = other->GetCoefficients(other->GetDegree()); int32_t inverseDenominatorLeadingTeam = m_field->Inverse(denominatorLeadingTerm, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); while (remainder->GetDegree() >= other->GetDegree() && !remainder->IsZero()) { int32_t degreeDifference = remainder->GetDegree() - other->GetDegree(); int32_t scale = m_field->Multiply(remainder->GetCoefficients((remainder->GetDegree())), inverseDenominatorLeadingTeam); CBC_ReedSolomonGF256Poly* rsg3 = other->MultiplyByMonomial(degreeDifference, scale, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); CBC_AutoPtr<CBC_ReedSolomonGF256Poly> term(rsg3); CBC_ReedSolomonGF256Poly* rsg4 = m_field->BuildMonomial(degreeDifference, scale, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); CBC_AutoPtr<CBC_ReedSolomonGF256Poly> iteratorQuotient(rsg4); CBC_ReedSolomonGF256Poly* rsg5 = quotient->AddOrSubtract(iteratorQuotient.get(), e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsg5); quotient = temp; CBC_ReedSolomonGF256Poly* rsg6 = remainder->AddOrSubtract(term.get(), e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp1(rsg6); remainder = temp1; } CFX_PtrArray* tempPtrA = new CFX_PtrArray; tempPtrA->Add(quotient.release()); tempPtrA->Add(remainder.release()); return tempPtrA; }
void filter_object::test<4>() { set_test_name("LLEventTimeout::errorAfter()"); WrapLLErrs capture; LLEventPump& driver(pumps.obtain("driver")); TestEventTimeout filter(driver); listener0.reset(0); LLTempBoundListener temp1( listener0.listenTo(filter)); filter.errorAfter(20, "timeout"); // Okay, (fake) timer is ticking. 'filter' can only sense the timer // when we pump mainloop. Do that right now to take the logic path // before either the anticipated event arrives or the timer expires. mainloop.post(17); check_listener("no timeout 1", listener0, LLSD(0)); // Expected event arrives... driver.post(1); check_listener("event passed thru", listener0, LLSD(1)); // Should have canceled the timer. Verify that by asserting that the // time has expired, then pumping mainloop again. filter.forceTimeout(); mainloop.post(17); check_listener("no timeout 2", listener0, LLSD(1)); // Set timer again. filter.errorAfter(20, "timeout"); // Now let the timer expire. filter.forceTimeout(); // Notice the timeout. std::string threw; try { mainloop.post(17); } catch (const WrapLLErrs::FatalException& e) { threw = e.what(); } ensure_contains("errorAfter() timeout exception", threw, "timeout"); // Timing out cancels the timer. Verify that. listener0.reset(0); filter.forceTimeout(); mainloop.post(17); check_listener("no timeout 3", listener0, LLSD(0)); }
void Machine::toDump() { Dump *temp_D = D; D = new Dump; D->D = temp_D; D->S = S; D->E = E; D->C = C; std::shared_ptr<stack_t> temp1(new stack_t); std::shared_ptr<stack_t> temp2(new stack_t); std::shared_ptr<stack_t> temp3(new stack_t); S = temp1; E = temp2; C = temp3; }
void splitAreas(QList<Geometry*> *firstHalf, QList<Geometry*> *secondHalf, QList<Geometry*> all) { int length1 = 1; int length2 = all.length()-1; int splitIdx = 0; //last index included in the first half of objs QList<Geometry*> prev1(all.mid(0,length1)); QList<Geometry*> prev2(all.mid(1,all.length()-1)); float prevArea1 = calcAreas(prev1); float prevArea2 = calcAreas(prev2); for (int i = 0; i < all.length(); i++) { length1++; //add one to firstHalf list of objs length2--; //remove one from secondHalf list QList<Geometry*> temp1(all.mid(0, length1)); QList<Geometry*> temp2(all.mid(splitIdx, length2)); float area1 = calcAreas(temp1); float area2 = calcAreas(temp2); if (area1 > area2) { //when area of first is finally greater than area 2 //check if the previous split was better balanced: float prevDifference = glm::abs(prevArea2 - prevArea1); float newDifference = glm::abs(area1 - area2); if (prevDifference > newDifference) { //they are NOW more evenly split prev1 = temp1; prev2 = temp2; } else { //they were previously more evenly split //current prev1 and prev2 contain ideal split break; //dont replace the return value with the new lists } }else { //they havent been replaced, make prev=curr area calcs prevArea1 = area1; prevArea2 = area2; } } *firstHalf = prev1; *secondHalf = prev2; }
void nsColorNames::AddRefTable(void) { NS_ASSERTION(!gColorTable, "pre existing array!"); if (!gColorTable) { gColorTable = new nsStaticCaseInsensitiveNameTable(); if (gColorTable) { #ifdef DEBUG { // let's verify the table... for (PRUint32 index = 0; index < eColorName_COUNT; ++index) { nsCAutoString temp1(kColorNames[index]); nsCAutoString temp2(kColorNames[index]); ToLowerCase(temp1); NS_ASSERTION(temp1.Equals(temp2), "upper case char in table"); } } #endif gColorTable->Init(kColorNames, eColorName_COUNT); } } }
void testCase2() { stdVec<int> temp1(10, 0); tsVec<int> temp2(10, 0); auto v1(temp1); auto v2(temp2); assert(TinySTL::Test::container_equal(v1, v2)); auto v3(std::move(temp1)); auto v4(std::move(temp2)); assert(TinySTL::Test::container_equal(v3, v4)); auto v5 = v1; auto v6 = v2; assert(TinySTL::Test::container_equal(v5, v6)); auto v7 = std::move(v3); auto v8 = std::move(v4); assert(TinySTL::Test::container_equal(v7, v8)); }
int main() { int number; while(scanf("%d",&number)!=EOF) { birthday temp1(2014,9,6); birthday temp2(1814,9,6); person person_temp; int valid_count=0; person old_person; person small_person; bool first=true; for(int i=0;i<number;++i) { scanf("%s %d/%d/%d",person_temp.name,&person_temp.birth.year, &person_temp.birth.month,&person_temp.birth.day); if(temp1<person_temp.birth||person_temp.birth<temp2) continue; ++valid_count; if(first) { small_person=person_temp; old_person=person_temp; first=false; } else { if(person_temp.birth<old_person.birth) old_person=person_temp; else if(small_person.birth<person_temp.birth) small_person=person_temp; } } if(valid_count!=0) printf("%u %s %s\n",valid_count,old_person.name,small_person.name); else printf("0\n"); } return 0; }
void Segmenter::initialize() { if (!initialized) { for (int i = 0; i < features.size(); i++) features[i]->getSegmentationParameters()->initialize(); createModeLogic(); createProbabilityTable(); int edges = getEdges(); modes = vector<int>(frames, 0); vector<double> cost_vector = vector<double>(edges, 0); costs = vector<vector<double> >(edges, cost_vector); oldCosts = vector<double>(edges, 0); vector<int> psi_row = vector<int>(edges, 0); psi = vector<vector<int> >(frames, psi_row); vector<ViterbiDistribution> temp1(edges); maxDistributions = vector<vector<ViterbiDistribution> >(features.size(), temp1); vector<vector<ViterbiDistribution> > temp2(edges, temp1); newDistributions = vector<vector<vector<ViterbiDistribution> > >(features.size(), temp2); for (int i = 0; i < features.size(); i++) { for (int a = 0; a < 2; a++) { maxDistributions[i][0].mean[a] = features[i]->getSegmentationParameters()->xInit[a]; for (int b = 0; b < 2; b++) maxDistributions[i][0].covariance[a][b] = features[i]->getSegmentationParameters()->pInit[a][b]; } } y = vector<double>(features.size(), 0); initialized = true; } }
inline bool is_permutation(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, command_queue &queue = system::default_queue()) { typedef typename std::iterator_traits<InputIterator1>::value_type value_type1; typedef typename std::iterator_traits<InputIterator2>::value_type value_type2; size_t count1 = detail::iterator_range_size(first1, last1); size_t count2 = detail::iterator_range_size(first2, last2); if(count1 != count2) return false; vector<value_type1> temp1(first1, last1, queue); vector<value_type2> temp2(first2, last2, queue); sort(temp1.begin(), temp1.end(), queue); sort(temp2.begin(), temp2.end(), queue); return equal(temp1.begin(), temp1.end(), temp2.begin(), queue); }
std::string Tower::getCurrentInfo() { std::string temp1(""); char temp2[200]; sprintf(temp2, "%s", descriptions[stats.type].c_str()); temp1 += temp2; if (stats.type == 3) //buff tower { sprintf(temp2, "Buff amount: %d\n", stats.damage); } else if (stats.type == 7) //aoe heal missile { sprintf(temp2, "Amount healed: %d\n", stats.damage); } else if (stats.type == 9) //splash slow { sprintf(temp2, "Slow: %d%%\n", stats.damage); } else if (stats.type == 10) //splash damage amp { sprintf(temp2, "Damage amplification:\n%d%%\n", stats.damage); } else { sprintf(temp2, "Damage: %d\n", stats.damage); } temp1 += temp2; sprintf(temp2, "Fire rate: %.1f / second\nRange: %d\n", (double)FPS / stats.fireRate, stats.range); temp1 += temp2; if (stats.type < 8) //not splash tower, put speed { sprintf(temp2, "Projectile speed: %.1f", stats.speed); temp1 += temp2; } return temp1; }