int main() { print(halfthree() + halfthree() == three()); print(halfthree() * two() == three()); print(halfthree() * two() == halfthree() + halfthree()); print(two() * halfthree() == three()); print(two() * halfthree() == halfthree() + halfthree()); }
int main() { typedef boost::intrusive::splaytree_algorithms<my_splaytree_node_traits> algo; my_node header, two(2), three(3); //Create an empty splaytree container: //"header" will be the header node of the tree algo::init_header(&header); //Now insert node "two" in the tree using the sorting functor algo::insert_equal_upper_bound(&header, &two, node_ptr_compare()); //Now insert node "three" in the tree using the sorting functor algo::insert_equal_lower_bound(&header, &three, node_ptr_compare()); //Now take the first node (the left node of the header) my_node *n = header.left_; assert(n == &two); //Now go to the next node n = algo::next_node(n); assert(n == &three); //Erase a node just using a pointer to it algo::unlink(&two); //Erase a node using also the header (faster) algo::erase(&header, &three); return 0; }
TEST(NAME, CONSTRUCTOR) { Stack<int> one(5); for (size_t i = 1; i < 11; ++i) { one.push(i * i); } Stack<int> two(one); EXPECT_EQ(5, two.getSize()); EXPECT_EQ(25, two.peek()); for (size_t i = 1; i < 6; ++i) { one.pop(); } EXPECT_EQ(0, one.getSize()); int* nums = new int[15]; for (int32 i = 0; i < 15; ++i) { nums[i] = i * i; } Stack<int> three(nums, 15); EXPECT_EQ(196, three.peek()); }
std::pair<int, int> Pokerhand::hand_value() { int val; if ((val = royal_flush())) return std::make_pair(10, val); if ((val = straight_flush())) return std::make_pair(9, val); if ((val = four())) return std::make_pair(8, val); if ((val = full_house())) return std::make_pair(7, val); if ((val = flush())) return std::make_pair(6, val); if ((val = straight())) return std::make_pair(5, val); if ((val = three())) return std::make_pair(4, val); if ((val = pairs())) return std::make_pair(3, val); if ((val = pair())) return std::make_pair(2, val); if ((val = high_card())) return std::make_pair(1, val); return std::make_pair(0, val); }
void test_determinisation() { std::cout << "Testing determinisation..." << std::endl << std::endl; State zero("0", state_type::NONFINAL); State one("1", state_type::NONFINAL); State two("2", state_type::NONFINAL); State three("3", state_type::FINAL); std::vector<State*> states; std::set<State*> zeroStatesA; std::set<State*> zeroStatesB; std::set<State*> oneStatesA; std::set<State*> twoStatesB; states.push_back(&zero); states.push_back(&one); states.push_back(&two); states.push_back(&three); zeroStatesA.insert(&zero); zeroStatesB.insert(&zero); zeroStatesB.insert(&one); oneStatesA.insert(&two); twoStatesB.insert(&three); std::unordered_map<char , std::set<State*> > zeroTransitions; std::unordered_map<char , std::set<State*> > oneTransitions; std::unordered_map<char , std::set<State*> > twoTransitions; std::unordered_map<char , std::set<State*> > threeTransitions; zeroTransitions['a'] = zeroStatesA; zeroTransitions['b'] = zeroStatesB; oneTransitions['a'] = oneStatesA; twoTransitions['b'] = twoStatesB; std::unordered_map< State*, std::unordered_map<char , std::set<State*> > > transitions; transitions[&zero] = zeroTransitions; transitions[&one] = oneTransitions; transitions[&two] = twoTransitions; transitions[&three] = threeTransitions; Automata automata(transitions); automata.setInitial(&zero); automata.setCurrentState(&zero); automata.setStates(states); std::cout << "Before:" << std::endl << automata << std::endl; std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now(); automata.determinise(); std::chrono::high_resolution_clock::time_point t2 = std::chrono::high_resolution_clock::now(); std::cout << "After: " << std::endl << automata << std::endl; auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count(); std::cout << "Execution time: " << duration << " milliseconds." << std::endl << std::endl; }
void ofxParametricSurface::reload(){ if (!isSetup) { ofLogError("ofxMathMesh") << "cannot reload if the surface is not setup"; return; } clear(); int uMinDomainPoint = round(ofMap(uMin, absUMin, absUMax, 0, uDomainPoints.size()-1)); int uMaxDomainPoint = round(ofMap(uMax, absUMin, absUMax, 0, uDomainPoints.size()-1)); int vMinDomainPoint = round(ofMap(vMin, absVMin, absVMax, 0, vDomainPoints.size()-1)); int vMaxDomianPoint = round(ofMap(vMax, absVMin, absVMax, 0, vDomainPoints.size()-1)); for (int u = uMinDomainPoint; u < uMaxDomainPoint; u++) { for (int v = vMinDomainPoint; v < vMaxDomianPoint; v++) { ofPoint value1 = valueForPoint(uDomainPoints[u], vDomainPoints[v]); ofPoint value2 = valueForPoint(uDomainPoints[u], vDomainPoints[v+1]); ofPoint value3 = valueForPoint(uDomainPoints[u+1], vDomainPoints[v+1]); ofPoint value4 = valueForPoint(uDomainPoints[u+1], vDomainPoints[v]); ParametricPosition one(uDomainPoints[u],vDomainPoints[v],value1); ParametricPosition two(uDomainPoints[u],vDomainPoints[v+1],value2); ParametricPosition three(uDomainPoints[u+1],vDomainPoints[v+1],value3); ParametricPosition four(uDomainPoints[u+1],vDomainPoints[v],value4); addQuad(one, two, three, four); } } }
void main () { Person one; Person two("Smythecraft"); Person three("Dimwiddy", "Sam"); cout << "First object: " << endl; cout << "Name Surname: " << endl; one.Show(); cout << "Surname, name" << endl; one.FormalShow(); cout << endl; cout << "Second object: " << endl; cout << "Name Surname: " << endl; two.Show(); cout << "Surname, name" << endl; two.FormalShow(); cout << endl; cout << "Third object: " << endl; cout << "Name Surname: " << endl; three.Show(); cout << "Surname, name" << endl; three.FormalShow(); cout << endl; system("pause"); }
int main() { //create four Port objects, one vintage Port one; Port two("Mason","Rose",10); Port three("Redtail","Red",4); Port four(three); VintagePort five("Vines",5,"Stomps",1988); cout << "Object one" << endl; one.Show(); one = three; //object one uses overloaded "=" to set one=three cout << "\nObject one = object three: " << one << endl << endl; cout << "Object two" << endl; two.Show(); two -= 5; //object two uses overloaded "-=" to subtract from bottles cout << "\nObject two bottles -= 5. Bottle count: " << two.BottleCount() << endl << endl; cout << "Object three" << endl; three.Show(); three += 6; //object three uses overloaded "+=" to add to bottles cout << "\nObject three bottles += 6. Bottle count: " << three.BottleCount() << endl << endl; cout << "Object four: " << four << endl; cout << "Object five: " << five << endl; cout << endl; return 0; }
signed int main(void) { type_one* one(nullptr); type_one* two(nullptr); type_one* three(nullptr); one = new type_one; two = new type_one; delete one; delete two; delete one; one = new type_one; two = new type_one; three = new type_one; std::cout << "one: " << one << " two: " << two << " three: " << three << std::endl; one->set_state(false); three->set_state(true); std::cout << "one: '" << one->get_state() << "'" << std::endl; std::cout << "two: '" << two->get_state() << "'" << std::endl; std::cout << "three: '" << three->get_state() << "'" << std::endl; return EXIT_SUCCESS; }
void one_three(void) { printf("starting now...\n"); one(); two(); three(); printf("done!\n"); }
TEST (kdbrestModelsEntryTest, SetAndGetAndHasTags) { kdb::Key key (kdbrest::Config::instance ().getConfig ().get<std::string> ("kdb.path.configs") + std::string ("/test/key1"), KEY_END); kdbrest::model::Entry entry (key); const char * taglist[] = { "one", "two", "three", "four", "five" }; std::vector<std::string> tags (taglist, std::end (taglist)); entry.setTags (tags); std::vector<std::string> retTags = entry.getTags (); for (int i = 0; i < 5; i++) { ASSERT_TRUE (std::find (retTags.begin (), retTags.end (), taglist[i]) != retTags.end ()); } std::string one (taglist[0]); std::string three (taglist[2]); ASSERT_TRUE (entry.hasTag (one)); ASSERT_TRUE (entry.hasTag (three)); std::string seven ("seven"); std::string fou ("fou"); std::string five_uc ("FIVE"); ASSERT_FALSE (entry.hasTag (seven)); ASSERT_FALSE (entry.hasTag (fou)); ASSERT_FALSE (entry.hasTag (five_uc)); }
int main(){ Solution sol; ListNode one(3); ListNode two(2); ListNode three(1); one.next = &two; two.next = &three;
void print_metrics(){ int i=0; ofstream unset; string nullstr(""); mse one(NULL, NULL, -1, -1, unset, nullstr); cout<<"\t"<<++i<<": "<<one.get_metric_name()<<"\n"; rmse two(NULL, NULL, -1, -1, unset, nullstr); cout<<"\t"<<++i<<": "<<two.get_metric_name()<<"\n"; scc three(NULL, NULL, -1, -1, unset, nullstr); cout<<"\t"<<++i<<": "<<three.get_metric_name()<<"\n"; difmap four(NULL, NULL, -1, -1, unset, nullstr); cout<<"\t"<<++i<<": "<<four.get_metric_name()<<"\n"; difmap_wkey five(NULL, NULL, -1, -1, unset, nullstr); cout<<"\t"<<++i<<": "<<five.get_metric_name()<<"\n"; colmap six(NULL, NULL, -1, -1, unset, nullstr); cout<<"\t"<<++i<<": "<<six.get_metric_name()<<"\n"; scorco seven(NULL, NULL, -1, -1, unset, nullstr); cout<<"\t"<<++i<<": "<<seven.get_metric_name()<<"\n"; modef eight(NULL, NULL, -1, -1, unset, nullstr); cout<<"\t"<<++i<<": "<<eight.get_metric_name()<<"\n"; }
Projectile::Projectile(): Body() { m_orient = matrix4x4d::Identity(); m_type = 1; m_age = 0; m_parent = 0; m_radius = 0; m_flags |= FLAG_DRAW_LAST; m_prog = new Render::Shader("flat", "#define TEXTURE0 1\n"); m_sideTex = Pi::textureCache->GetBillboardTexture(PIONEER_DATA_DIR "/textures/projectile_l.png"); m_glowTex = Pi::textureCache->GetBillboardTexture(PIONEER_DATA_DIR "/textures/projectile_w.png"); //zero at projectile position //+x down //+y right //+z forwards (or projectile direction) const float w = 0.5f; vector3f one(0.f, -w, 0.f); //top left vector3f two(0.f, w, 0.f); //top right vector3f three(0.f, w, -1.f); //bottom right vector3f four(0.f, -w, -1.f); //bottom left //add four intersecting planes to create a volumetric effect for (int i=0; i < 4; i++) { m_verts.push_back(Vertex(one, 0.f, 1.f)); m_verts.push_back(Vertex(two, 1.f, 1.f)); m_verts.push_back(Vertex(three, 1.f, 0.f)); m_verts.push_back(Vertex(three, 1.f, 0.f)); m_verts.push_back(Vertex(four, 0.f, 0.f)); m_verts.push_back(Vertex(one, 0.f, 1.f)); one.ArbRotate(vector3f(0.f, 0.f, 1.f), DEG2RAD(45.f)); two.ArbRotate(vector3f(0.f, 0.f, 1.f), DEG2RAD(45.f)); three.ArbRotate(vector3f(0.f, 0.f, 1.f), DEG2RAD(45.f)); four.ArbRotate(vector3f(0.f, 0.f, 1.f), DEG2RAD(45.f)); } //create quads for viewing on end //these are added in the same vertex array to avoid a //vertex pointer change float gw = 0.5f; float gz = -0.1f; for (int i=0; i < 4; i++) { m_verts.push_back(Vertex(vector3f(-gw, -gw, gz), 0.f, 1.f)); m_verts.push_back(Vertex(vector3f(-gw, gw, gz), 1.f, 1.f)); m_verts.push_back(Vertex(vector3f(gw, gw, gz),1.f, 0.f)); m_verts.push_back(Vertex(vector3f(gw, gw, gz), 1.f, 0.f)); m_verts.push_back(Vertex(vector3f(gw, -gw, gz), 0.f, 0.f)); m_verts.push_back(Vertex(vector3f(-gw, -gw, gz), 0.f, 1.f)); gw -= 0.1f; // they get smaller gz -= 0.2; // as they move back } }
int perthreadtestApp::main (void) { outputOne = outputTwo = outputThree = 0; __THREADED = true; testThread one (&outputOne, 18321); testThread two (&outputTwo, 33510); testThread three (&outputThree, 18495); one.sendevent ("shutdown"); two.sendevent ("shutdown"); three.sendevent ("shutdown"); threadStopped.wait (); ::printf ("%i %i %i\n", outputOne, outputTwo, outputThree); threadStopped.wait (); ::printf ("%i %i %i\n", outputOne, outputTwo, outputThree); threadStopped.wait (); ::printf ("%i %i %i\n", outputOne, outputTwo, outputThree); value out; out.newval() = outputOne; out.newval() = outputTwo; out.newval() = outputThree; out.savexml ("out.xml"); return 0; }
Graphics::VertexArray *Thruster::CreateGlowGeometry() { Graphics::VertexArray *verts = new Graphics::VertexArray(Graphics::ATTRIB_POSITION | Graphics::ATTRIB_UV0); //create glow billboard for linear thrusters const float w = 0.2; vector3f one(-w, -w, 0.f); //top left vector3f two(-w, w, 0.f); //top right vector3f three(w, w, 0.f); //bottom right vector3f four(w, -w, 0.f); //bottom left //uv coords const vector2f topLeft(0.f, 1.f); const vector2f topRight(1.f, 1.f); const vector2f botLeft(0.f, 0.f); const vector2f botRight(1.f, 0.f); for (int i = 0; i < 5; i++) { verts->Add(one, topLeft); verts->Add(two, topRight); verts->Add(three, botRight); verts->Add(three, botRight); verts->Add(four, botLeft); verts->Add(one, topLeft); one.z += .1f; two.z = three.z = four.z = one.z; } return verts; }
void object::test<3>() { Keyed one("one"), two("two"), three("three"); // We don't want to rely on the underlying container delivering keys // in any particular order. That allows us the flexibility to // reimplement LLInstanceTracker using, say, a hash map instead of a // std::map. We DO insist that every key appear exactly once. typedef std::vector<std::string> StringVector; StringVector keys(Keyed::beginKeys(), Keyed::endKeys()); std::sort(keys.begin(), keys.end()); StringVector::const_iterator ki(keys.begin()); ensure_equals(*ki++, "one"); ensure_equals(*ki++, "three"); ensure_equals(*ki++, "two"); // Use ensure() here because ensure_equals would want to display // mismatched values, and frankly that wouldn't help much. ensure("didn't reach end", ki == keys.end()); // Use a somewhat different approach to order independence with // beginInstances(): explicitly capture the instances we know in a // set, and delete them as we iterate through. typedef std::set<Keyed*> InstanceSet; InstanceSet instances; instances.insert(&one); instances.insert(&two); instances.insert(&three); for (Keyed::instance_iter ii(Keyed::beginInstances()), iend(Keyed::endInstances()); ii != iend; ++ii) { Keyed& ref = *ii; ensure_equals("spurious instance", instances.erase(&ref), 1); } ensure_equals("unreported instance", instances.size(), 0); }
//------------------------------update_ifg------------------------------------- void PhaseConservativeCoalesce::update_ifg(uint lr1, uint lr2, IndexSet *n_lr1, IndexSet *n_lr2) { // Some original neighbors of lr1 might have gone away // because the constrained register mask prevented them. // Remove lr1 from such neighbors. IndexSetIterator one(n_lr1); uint neighbor; LRG &lrg1 = lrgs(lr1); while ((neighbor = one.next()) != 0) if( !_ulr.member(neighbor) ) if( _phc._ifg->neighbors(neighbor)->remove(lr1) ) lrgs(neighbor).inc_degree( -lrg1.compute_degree(lrgs(neighbor)) ); // lr2 is now called (coalesced into) lr1. // Remove lr2 from the IFG. IndexSetIterator two(n_lr2); LRG &lrg2 = lrgs(lr2); while ((neighbor = two.next()) != 0) if( _phc._ifg->neighbors(neighbor)->remove(lr2) ) lrgs(neighbor).inc_degree( -lrg2.compute_degree(lrgs(neighbor)) ); // Some neighbors of intermediate copies now interfere with the // combined live range. IndexSetIterator three(&_ulr); while ((neighbor = three.next()) != 0) if( _phc._ifg->neighbors(neighbor)->insert(lr1) ) lrgs(neighbor).inc_degree( lrg1.compute_degree(lrgs(neighbor)) ); }
int main() { one(); atexit(one); atexit(two); three(); atexit(four); }
TEST_F(result, gives_number_of_rows_changed_on_a_modifying_statement) { sqlite::result one(db->execute( "UPDATE test SET name = 'test' WHERE id = 1;" )); EXPECT_EQ(1, one.row_modification_count()); sqlite::result three(db->execute( "UPDATE test SET name = 'test';" )); EXPECT_EQ(3, three.row_modification_count()); }
void start(void) { int i; for (i = 0; i < 5; i++) { free(three()); } for (i = 0; i < 3; i++) { free(two()); } }
int main(){ Point one(5,20),two(0,30),three(0,20),a(0,0),c(10,0),d(5,0),e(10,0); Robot MyRobot(10,20); WorldFrame wframe(a,0); JointFrame jframe1(a,0); JointFrame jframe2(c,0); TaskFrame tframe1(d,0); TaskFrame tframe2(e,90); MyRobot.PTPmove(tframe1,one); MyRobot.PTPmove(wframe,two); MyRobot.PTPmove(jframe1,three); }
void two(){ int i,lim=sum-d04-d40-d22; if(lim>18)return; for(i=0;i<10 && lim-i>=0;i++){ if(lim-i>=10)continue; d13=i;d31=lim-i; if(!notp[d04+d13*10+d22*100+d31*1000+d40*10000] && d10+d11+d13<sum && d30+d31+d33<sum && d01+d11+d31<sum && d03+d13+d33<sum)three(); } }
int six(char number[110], int k) { if(three(number,k)+two(number,k)==2) { return 1; } else { return 0; } }
int main(){ int year = 0; one_printalltypesize(); two_a(); two_b(); two_c(); do{ three(year); } while (year != 0); return 0; }
InfInt C(int n, int k) { if (k == 0 || n == 0) return 0; InfInt result1, result2, result3; std::thread one(fct, n, & result1); std::thread two(fct, k, & result2); std::thread three(fct, (n - k), & result3); one.join(); two.join(); three.join(); return result1 / (result2 * result3); }
int main() { Person one; Person two("Smythecraft"); Person three("Dimwiddy", "Sam"); one.Show(); cout << endl; one.FormalShow(); two.Show(); two.FormalShow(); cout << endl; three.Show(); three.FormalShow(); cout << endl; }
Thruster::Thruster(Graphics::Renderer *r, bool _linear, const vector3f &_pos, const vector3f &_dir) : Node(NODE_TRANSPARENT) , linearOnly(_linear) , dir(_dir) , pos(_pos) { m_tVerts.Reset(new Graphics::VertexArray(Graphics::ATTRIB_POSITION | Graphics::ATTRIB_UV0)); //zero at thruster center //+x down //+y right //+z backwards (or thrust direction) const float w = 0.5f; vector3f one(0.f, -w, 0.f); //top left vector3f two(0.f, w, 0.f); //top right vector3f three(0.f, w, 1.f); //bottom right vector3f four(0.f, -w, 1.f); //bottom left //uv coords const vector2f topLeft(0.f, 1.f); const vector2f topRight(1.f, 1.f); const vector2f botLeft(0.f, 0.f); const vector2f botRight(1.f, 0.f); //add four intersecting planes to create a volumetric effect for (int i=0; i < 4; i++) { m_tVerts->Add(one, topLeft); m_tVerts->Add(two, topRight); m_tVerts->Add(three, botRight); m_tVerts->Add(three, botRight); m_tVerts->Add(four, botLeft); m_tVerts->Add(one, topLeft); one.ArbRotate(vector3f(0.f, 0.f, 1.f), DEG2RAD(45.f)); two.ArbRotate(vector3f(0.f, 0.f, 1.f), DEG2RAD(45.f)); three.ArbRotate(vector3f(0.f, 0.f, 1.f), DEG2RAD(45.f)); four.ArbRotate(vector3f(0.f, 0.f, 1.f), DEG2RAD(45.f)); } //set up materials Graphics::MaterialDescriptor desc; desc.textures = 1; desc.twoSided = true; m_tMat.Reset(r->CreateMaterial(desc)); m_tMat->texture0 = Graphics::TextureBuilder::Billboard(thrusterTextureFilename).GetOrCreateTexture(r, "model"); m_tMat->diffuse = baseColor; }
int main() { MyStringClass one("String #1"); MyStringClass two("Mah string #2 #blessed"); MyStringClass three("#tres!"); MyStringClass four("too good 4 me"); Sub* sub = new Sub(std::move(one), std::move(two), std::move(three), std::move(four)); Mid* mid = sub; //Base* base = sub; //std::cout << "Field 1 is: " << base->field.get() << std::endl; //base->field = MyStringClass("Eyo, boy"); //delete base; delet(mid); return 0; }
void MainWindow::someSlot() { if((ui->lineEdit->text() == "move north") && (this->tiles.value(1).value(0) == 1)){ qDebug() << "north"; emit one(); }else if((ui->lineEdit->text() == "move east") && (this->tiles.value(1).value(1) == 1)){ qDebug() << "east"; emit two(); }else if((ui->lineEdit->text() == "move south") && (this->tiles.value(1).value(2) == 1)){ qDebug() << "south"; emit three(); }else if((ui->lineEdit->text() == "move west") && (this->tiles.value(1).value(3) == 1)){ qDebug() << "west"; emit four(); }else qDebug() << "ERROR: INVALID COMMAND"; }