Example #1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    connect(ui->clear,SIGNAL(released()), this,SLOT(clear()));
    connect(ui->add,SIGNAL(released()), this,SLOT(add()));
    connect(ui->sub,SIGNAL(released()),this,SLOT(substract()));
    connect(ui->mul,SIGNAL(released()),this,SLOT(multiply()));
    connect(ui->div,SIGNAL(released()),this,SLOT(divide()));
    connect(ui->push_but_0,SIGNAL(released()),this,SLOT(zero()));
    connect(ui->push_but_1,SIGNAL(released()),this,SLOT(one()));
    connect(ui->push_but_2,SIGNAL(released()),this,SLOT(two()));
    connect(ui->push_but_3,SIGNAL(released()),this,SLOT(tree()));
    connect(ui->push_but_4,SIGNAL(released()),this,SLOT(four()));
    connect(ui->push_but_5,SIGNAL(released()),this,SLOT(five()));
    connect(ui->push_but_6,SIGNAL(released()),this,SLOT(six()));
    connect(ui->push_but_7,SIGNAL(released()),this,SLOT(seven()));
    connect(ui->push_but_8,SIGNAL(released()),this,SLOT(eight()));
    connect(ui->push_but_9,SIGNAL(released()),this,SLOT(nine()));
    connect(ui->equal,SIGNAL(released()),this,SLOT(equal()));
    connect(ui->point,SIGNAL(released()),this,SLOT(point()));
    connect(ui->convertingto8,SIGNAL(released()),this,SLOT(converting8()));
    connect(ui->point,SIGNAL(released()),this,SLOT(converting10()));
}
 virtual void interpret(char *input, int &total)
 {
     // for internal use
     int index;
     index = 0;
     if (!strncmp(input, nine(), 2))
     {
         total += 9 * multiplier();
         index += 2;
     }
     else if (!strncmp(input, four(), 2))
     {
         total += 4 * multiplier();
         index += 2;
     }
     else
     {
         if (input[0] == five())
         {
             total += 5 * multiplier();
             index = 1;
         }
         else
             index = 0;
         for (int end = index + 3; index < end; index++)
             if (input[index] == one())
                 total += 1 * multiplier();
             else
                 break;
     }
     strcpy(input, &(input[index]));
 } // remove leading chars processed
Example #3
0
	Trigger::Trigger(  irr::scene::ISceneManager *smgr ) : triggered( false ), promptShown( false )
	{
		irr::video::ITexture* tex;

		this->smgr = smgr;
		GUIEnv = smgr->getGUIEnvironment();

		// get a random number for which popup to show:
		boost::mt19937 rng;
		unsigned int seed = static_cast<unsigned int>(std::time(0));
		rng.seed(seed);
		boost::uniform_int<>five(1, 5);
		boost::variate_generator<boost::mt19937&, boost::uniform_int<> > getrand(rng, five);
		int i = getrand();

		// get texture:
		std::string textureName = "PopUp";
		textureName.append(boost::lexical_cast<std::string>(i));
		textureName.append(".png");
		tex = smgr->getVideoDriver()->getTexture(textureName.c_str());
		
		// create the image:
		img = GUIEnv->addImage(irr::core::rect<irr::s32>(-2, -2, 1, 1) );
		img->setUseAlphaChannel(true);
		img->setImage(tex);
		img->setScaleImage( true );
		smgr->getVideoDriver()->removeTexture(tex);
	}
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;
}
Example #5
0
main()
{
 float nan = __builtin_nanf("");

 if(five(nan, nan)) return 1;
 if(five(5, nan)) return 2;
 if(five(nan, 5)) return 3;
 if(!five(3, 5)) return 4;

 if(!ne(nan, nan)) return 5;
 if(!ne(3, nan)) return 6;
 if(!ne(nan, 3)) return 7;
 if(ne(3, 3)) return 8;

 return 0;
}
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";

}
Example #7
0
void start(void)
{
	int size = 1000;
	while (s_loop) {
		five(size++);
		sleep(1);
	}
}
Example #8
0
void RESTChannelHandler::onMessageReceived(Channel &channel, std::string &payload) {

    try {
        Request request(payload, channel);

        bool done = false;

        boost::match_results<string::const_iterator> capture;

        for (unsigned int i = 0; i < (*mRequestMap)[request.method].size(); i++) {

            if (regex_search(request.path, capture, (*mRequestMap)[request.method][i].pathre) ) {

                // push all matches into parameters.

                for (unsigned int j = 0; j < (*mRequestMap)[request.method][i].names.size(); j++)
                    request.setParameter((*mRequestMap)[request.method][i].names[j], capture[j+1]);


                Response res(&channel);

                MethodHandler f;

                f = (*mRequestMap)[request.method][i].func;

                f(request, res);
             
                done = true;

                break;

            }
        }

        if (! done) {
            Response fof(&channel, 404);
            fof.write();
        }

    }
    catch(Exception e) {
        Response five(&channel, 500);
        five.write();
    }

    // done.  close connection
    channel.close();
}
Example #9
0
int level3()
{
	lcdFillWindow(0, 239, 0, 319, BACKGROUND_COLOUR);
	map m;
	m.putRectangle(1, 7, 0, 8, 2);
	m.putRectangle(7, 13, 0, 8, 2);
	m.putRectangle(5, 9, 8, 12, 2);
	m.putRectangle(1, 7, 12, 16, 2);
	m.putRectangle(7, 13, 12, 16, 2);
	m.putSpeedBonus(7, 8);
	m.setup();
	enemy one(1, 16, &m);
	enemy two(13, 16, &m);
	enemy three(7, 16, &m);
	pacman five(7, 0, &m);
	wait(2000000);
	return mainLoop(&five, &m, "SEHR GUT", "LEVEL 4", "SEHR SCHLECHT",
			"TRY AGAIN  ");
}
Example #10
0
    void RunTests()
    {
        Solution s;
        TreeNode one(1);
        TreeNode two(2);
        TreeNode four(4);
        TreeNode four_2(4);
        TreeNode five(5);
        TreeNode five_2(5);
        TreeNode seven(7);
        TreeNode eight(8);
        TreeNode eleven(11);
        TreeNode thirteen(13);

        // Simple problems
        _ASSERT(s.pathSum(nullptr, 1).size() == 0);
        _ASSERT(s.pathSum(&one, 1).size() == 1);

        // Sample problem
        five.left = &four;
        five.right = &eight;
        four.left = &eleven;
        four.right = nullptr;
        eleven.left = &seven;
        eleven.right = &two;
        seven.left = nullptr;
        seven.right = nullptr;
        two.left = nullptr;
        two.right = nullptr;
        eight.left = &thirteen;
        eight.right = &four_2;
        thirteen.left = nullptr;
        thirteen.right = nullptr;
        four_2.left = &five_2;
        four_2.right = &one;
        five_2.left = nullptr;
        five_2.right = nullptr;
        one.left = nullptr;
        one.right = nullptr;
        _ASSERT(s.pathSum(&five, 22).size() == 2);
    }
Example #11
0
void four(){
    if((sum-d40-d41-d44)%2 || (sum-d04-d14-d44)%2)return;
    lim5=sum-d40-d41-d44;
    for(d43=1;d43<10 && lim5-d43>0;d43++,d43++){
        if(lim5-d43>=10)continue;
        d42=lim5-d43;
        d23=sum-d03-d13-d33-d43;
        d32=sum-d02-d12-d22-d42;
        d24=sum-d20-d21-d22-d23;
        d34=sum-d30-d31-d32-d33;
        if(d24%2==0 || d34%2==0)continue;
        if(d23<0 || d32<0 || d24<1 || d34<1 || d23>9 || d32>9 || d24>9
        || d34>9)continue;
        if(!notp[d02*10000+d12*1000+d22*100+d32*10+d42] &&
           !notp[d03*10000+d13*1000+d23*100+d33*10+d43] &&
           !notp[d04*10000+d14*1000+d24*100+d34*10+d44] &&
           !notp[d20*10000+d21*1000+d22*100+d23*10+d24] &&
           !notp[d30*10000+d31*1000+d32*100+d33*10+d34] &&
           !notp[d40*10000+d41*1000+d42*100+d43*10+d44])
           five();
    }
}
Example #12
0
void Executor::waitForInput(double pidSetpoint) {
  PhysicalInput pio(_pioPin);
  DigitalPot digiPot(_csPin);
  FiveFiveFive five(_fivePin);
  VoltageMeter vMeter(_adsAddress);
  double InputRaw = 0;
  double OutputRaw = 0;
  double SetpointRaw = 0;
  PID myPIDRaw(&InputRaw, &OutputRaw, &SetpointRaw, _KpRaw, _KiRaw, _KdRaw, DIRECT);
  myPIDRaw.SetMode(AUTOMATIC);
  myPIDRaw.SetOutputLimits(0, 255);
  myPIDRaw.SetSampleTime(1);

  if(pio.readInput()) {
    Serial.print("after"); Serial.println(pio.readInput());
    // Used in order for raspberry pi monitoring device to get "up to speed"
    delay(500);
    while(pio.readInput()) {
      five.fiveEnable();
      InputRaw = vMeter.voltage(_probe);
      SetpointRaw = pidSetpoint;
      myPIDRaw.Compute();
      int intOutput = OutputRaw;
      digiPot.writeToPot(intOutput);
      // debuging led on arduino
      digitalWrite(13, 1);
    }
    digiPot.killPot();
    five.fiveKill();
    // debuging led on arduino
    digitalWrite(13, 0);
  }
  digiPot.killPot();
  five.fiveKill();
  // debuging led on arduino
  digitalWrite(13, 0);

}
Example #13
0
int level4()
{
	lcdFillWindow(0, 239, 0, 319, BACKGROUND_COLOUR);
	map m;
	m.putRectangle(1, 3, 1, 4, 2);
	m.putRectangle(3, 5, 1, 4, 2);
	m.putRectangle(5, 7, 1, 4, 2);
	m.putRectangle(7, 9, 1, 4, 2);
	m.putRectangle(9, 11, 1, 4, 2);
	m.putRectangle(11, 13, 1, 4, 2);
	m.putRectangle(1, 6, 4, 6, 2);
	m.putRectangle(6, 11, 4, 6, 2);
	m.putRectangle(1, 13, 6, 15, 2);
	m.putRectangle(4, 13, 6, 15, 2);
	m.putRectangle(1, 3, 15, 18, 2);
	m.putRectangle(3, 5, 15, 18, 2);
	m.putRectangle(5, 7, 15, 18, 2);
	m.putRectangle(7, 9, 15, 18, 2);
	m.putRectangle(9, 11, 15, 18, 2);
	m.putRectangle(11, 13, 15, 18, 2);

	m.putSpeedBonus(7, 2);
	m.putSpeedBonus(1, 10);
	m.putSpeedBonus(13, 18);
	m.putSpeedBonus(2, 1);
	m.putSpeedBonus(1, 3);
	m.setup();
	enemy one(1, 9, &m);
	enemy two(1, 12, &m);
	enemy three(4, 9, &m);
	enemy four(4, 12, &m);
	pacman five(1, 1, &m);
	wait(2000000);
	return mainLoop(&five, &m, "EVEN BETTER", "LEVEL 4",
			"SEHR SCHLECHT", "TRY AGAIN  ");
}
Example #14
0
int main()
{
    try {
        TestSection("StdTerms");
        TestSubsection("TermGarbage");
        {
            MyTestTerm *term1 = new MyTestTerm(10);
            MyTestTerm2 *term2 = new MyTestTerm2(20);
            SReference ref1(term1);
            SReference ref2(term2);
            SReference ref3(new MyTestTerm(30));
            SReference ref4(new MyTestTerm2(40));
            TEST("constructed", constructed, 4);
            TEST("noone-destructed", destructed, 0);
            ref4 = new MyTestTerm(300);
            TEST("assign_ptr", destructed, 1);
            ref4 = ref1;
            TEST("assign_ref", destructed, 2);
            ref3 = 0;
            TEST("assign_null", destructed, 3);
        }
        TEST("correctness", constructed, destructed);
        {
            constructed = destructed = 0;
            SReference ref1(new MyTestTerm(200));
            SReference ref2(new MyTestTerm(300));
            TESTB("before_assigning_refs",constructed == 2 && destructed == 0);
            ref1 = ref2;
            TEST("after_assigning_refs", destructed, 1);
        }
        TestSubsection("TermType");
        {
            SReference ref5(new MyTestTerm(50));
            TESTB("type-of", ref5->TermType() == MyTestTerm::TypeId);
            TESTB("not-type-of", ref5->TermType() != MyTestTerm2::TypeId);
            TESTB("subtype", ref5->TermType().IsSubtypeOf(SExpression::TypeId));
            TESTB("not-subtype",
                 !(ref5->TermType().IsSubtypeOf(MyTestTerm2::TypeId)));
            SReference ref6(new MyTestTerm22(60));
            TESTB("subtype2_", ref6->TermType() == MyTestTerm22::TypeId);
            TESTB("22subE",
                MyTestTerm22::TypeId.IsSubtypeOf(SExpression::TypeId));
            TESTB("22sub2",
                MyTestTerm22::TypeId.IsSubtypeOf(MyTestTerm2::TypeId));
            TESTB("2subE",
                MyTestTerm2::TypeId.IsSubtypeOf(SExpression::TypeId));
            TESTB("subtype2",
                ref6->TermType().IsSubtypeOf(SExpression::TypeId));
            TESTB("subtype22",
                ref6->TermType().IsSubtypeOf(MyTestTerm2::TypeId));
            TESTB("subtype22_self",
                 ref6->TermType().IsSubtypeOf(MyTestTerm22::TypeId));
            SReference ref7(new MyTestTerm2(70));
            TESTB("not-subtype22",
                 !(ref7->TermType().IsSubtypeOf(MyTestTerm22::TypeId)));
        }
        TestSubsection("TermCasts");
        {
            SReference ref(new MyTestTerm(50));
            SReference ref2(new MyTestTerm2(70));
            TESTB("cast_to_lterm", ref.DynamicCastGetPtr<SExpression>()
                 == ref.GetPtr());
            TESTB("cast_to_lterm2", ref.DynamicCastGetPtr<SExpression>()
                 == ref.GetPtr());
            TESTB("cast_to_itself", ref.DynamicCastGetPtr<MyTestTerm>() ==
                 ref.GetPtr());
            TESTB("failed_cast", ref.DynamicCastGetPtr<MyTestTerm2>()==0);
        }
        TestSubsection("SExpressionCasts");
        {
            SReference ref(new MyTestTerm(50));
            SReference ref2(new MyTestTerm2(70));
            TESTB("cast_to_lterm", ref.DynamicCastGetPtr<SExpression>()
                 == ref.GetPtr());
            TESTB("cast_to_lterm2", ref.DynamicCastGetPtr<SExpression>()
                 == ref.GetPtr());
            TESTB("cast_to_itself", ref.DynamicCastGetPtr<MyTestTerm>()
                 == ref.GetPtr());
            TESTB("failed_cast", ref.DynamicCastGetPtr<MyTestTerm2>()==0);
        }
        TestSubsection("BasicTerms");
        {
            SReference intref(25);
            TESTC("integer_term", intref->TermType(), SExpressionInt::TypeId);
            TEST("integer_value", intref.GetInt(), 25);
            SReference floatref(25.0);
            TESTC("float_term", floatref->TermType(), SExpressionFloat::TypeId);
            TESTC("float_value", floatref.GetFloat(), (intelib_float_t)25.0);
            SReference strref("A_STRING");
            TESTC("pchar_term", strref->TermType(), SExpressionString::TypeId);
            TESTC("pchar_value", strcmp((const char*)strref.GetString(),
                                        "A_STRING"),
                  0);
            SReference charref('a');
            TESTC("char_term", charref->TermType(), SExpressionChar::TypeId);
            TEST("char_value", charref.GetSingleChar(), 'a');

        }
        TestSubsection("SExpressionString");
        {
            SReference strref1(new SExpressionString("A", "B"));
            TEST("concatenation_1_1", strref1.GetString(), "AB");
            SReference strref2(new SExpressionString("AA", "BB"));
            TEST("concatenation_2_2", strref2.GetString(), "AABB");
            SReference strref3(new SExpressionString("AAA", "BBB"));
            TEST("concatenation_3_3", strref3.GetString(), "AAABBB");
            SReference strref4(new SExpressionString("AAAA", "BBBB"));
            TEST("concatenation_4_4", strref4.GetString(), "AAAABBBB");
            SReference strref5(new SExpressionString("AAAAA", "BBBBB"));
            TEST("concatenation_5_5", strref5.GetString(), "AAAAABBBBB");
            SReference strref6(new SExpressionString("A"));
            TEST("construction1", strref6.GetString(), "A");
            SReference strref7(new SExpressionString("AA"));
            TEST("construction2", strref7.GetString(), "AA");
            SReference strref8(new SExpressionString("AAA"));
            TEST("construction3", strref8.GetString(), "AAA");
            SReference strref9(new SExpressionString("AAAA"));
            TEST("construction4", strref9.GetString(), "AAAA");


        }
        TestSubsection("SString");
        {
            SString str1;
            TESTC("default_is_empty", str1.c_str()[0], '\0');
            SString str2("");
            TESTC("empty_strings", str1, str2);
            TESTC("empty_is_empty", str2.c_str()[0], '\0');
            SString str3("AAA");
            SString str4("BBB");
            SString str5 = str3 + str4;
            TEST("string_addition", str5.c_str(), "AAABBB");
            SString str6("CCC");
            str6 += "DDD";
            TEST("string_increment_by_pchar", str6.c_str(), "CCCDDD");
            SString str7("EEE");
            SString str8("FFF");
            str7 += str8;
            TEST("string_increment_by_string", str7.c_str(), "EEEFFF");

            SString str10("Final countdown");
            SString str11("Final");
            str11 += " countdown";
            TESTB("string_equals_itself", str10 == str10);
            TESTB("string_doesnt_differ_from_itself", !(str10 != str10));
            TESTB("two_equal_strings", str10 == str11);
            TESTB("equal_strings_dont_differ", !(str10 != str11));
            SString str12("Another string");
            TESTB("two_non_equal_strings", str11 != str12);
            TESTB("nonequals_non_equal", !(str11 == str12));
            SString str13;
            SString str14("");
            TESTB("empty_strings_equal", str13 == str14);
            TESTB("empty_strings_dont_differ", !(str13 != str14));
            SReference strref("my_string");
            SString str15(strref);
            TEST("string_from_lreference", str15.c_str(), "my_string");
            {
                int flag = 0;
                try {
                    SReference ref(25);
                    SString str(ref);
                }
                catch(IntelibX_not_a_string lx)
                {
                    flag = 0x56;
                }
                TESTB("string_from_int_fails", flag == 0x56);
            }
        }
        TestSubsection("TextRepresentation");
        {
            SReference intref(100);
            TEST("integer_text_rep", intref->TextRepresentation().c_str(),
                 "100");
            char buf[100];
            intelib_float_t fl;
            fl = 100.1;
            SReference fltref(fl);
            snprintf(buf, sizeof(buf), INTELIB_FLOAT_FORMAT, fl);
            TEST("float_text_rep", fltref->TextRepresentation().c_str(),
                 buf);
            fl = 100.0;
            SReference fltref2(fl);
            snprintf(buf, sizeof(buf), INTELIB_FLOAT_FORMAT, fl);
            TEST("float2_text_rep", fltref2->TextRepresentation().c_str(),
                 buf);
            SReference strref("mystring");
            TEST("string_text_rep", strref->TextRepresentation().c_str(),
                 "\"mystring\"");
            SReference unbound;
            SReference unbound2;
            SReference unblist(unbound, unbound2);
            TEST("unbound_text_representation",
                 unblist->TextRepresentation().c_str(),
                 "(#<UNBOUND> . #<UNBOUND>)");
        }
        TestSubsection("DottedPairs");
        {
            SReference pairref(25, 36);
            TEST("pair_25_36", pairref->TextRepresentation().c_str(),
                 "(25 . 36)");
            SReference dotlistref(25, SReference(36, 49));
            TEST("dotlist_25_36_49", dotlistref->TextRepresentation().c_str(),
                 "(25 36 . 49)");
            SReference empty_list_ref(*PTheEmptyList);
            TEST("empty_list_ref", empty_list_ref->TextRepresentation().c_str(),
                 (*PTheEmptyList)->TextRepresentation().c_str());
            TESTB("empty_list_equal_empty", empty_list_ref.GetPtr() ==
                 PTheEmptyList->GetPtr());
            TESTB("dot_list_notequal_empty", dotlistref.GetPtr() !=
                 PTheEmptyList->GetPtr());

            SReference list25ref(25, *PTheEmptyList);
            TEST("list_1_elem", list25ref->TextRepresentation().c_str(),
                 "(25)");
            SReference list_16_25_ref(16, list25ref);
            TEST("cons_with_list", list_16_25_ref->TextRepresentation().c_str(),
                 "(16 25)");
            SReference list_of_lists_ref(list25ref,
                                         SReference(list25ref, *PTheEmptyList));
            TEST("list_of_lists", list_of_lists_ref->TextRepresentation().c_str(),
                 "((25) (25))");

        }
        TestSubsection("SExpressionLabel");
        {
            SExpressionLabel *lab1 = new SExpressionLabel("lab1");
            SReference labref(lab1);
            TEST("label", labref->TextRepresentation().c_str(),
                 "lab1");
            TESTB("label_equality", labref == SReference(lab1));
            SReference labref2(lab1);
            TESTB("label_equality2", labref== labref2);
            SReference ref3(25);
            TESTB("label_non_eq", labref != ref3);

#if 0 // no support for booleans in sexpression core
            TEST("boolean_true", LTheLispBooleanTrue.TextRepresentation().c_str(),
           #if CLSTYLE_BOOLEANS == 0
                 "#T"
           #else
                 "T"
           #endif
                );
#endif
        }
        TestSubsection("SListConstructor");
        {
            SListConstructor L;
            SReference list_int((L|25));
            TEST("list_of_1_int", list_int->TextRepresentation().c_str(),
                 "(25)");
            SReference list_str((L|"abcd"));
            TEST("list_of_1_str", list_str->TextRepresentation().c_str(),
                 "(\"abcd\")");
            intelib_float_t fl = 1.1;
            SReference list_float((L|fl));
            char buf[128];
            snprintf(buf, sizeof(buf), "(" INTELIB_FLOAT_FORMAT ")", fl);
            TEST("list_of_1_float", list_float->TextRepresentation().c_str(),
                 buf);
        }
        TestSubsection("ListConstructionAlgebra");
        {
            SListConstructor L;
            SReference listref((L|25, 36, 49, "abcd", "efgh"));
            TEST("plain_list", listref->TextRepresentation().c_str(),
                 "(25 36 49 \"abcd\" \"efgh\")");
            SReference listref2((L|(L|25), 36, (L|(L|(L|49)))));
            TEST("list_with_lists", listref2->TextRepresentation().c_str(),
                 "((25) 36 (((49))))");
            SReference listref3((L|(L|(L|(L|(L))))));
            TEST("empty_buried_list", listref3->TextRepresentation().c_str(),
                 (SString("((((")+
                  (*PTheEmptyList)->
                  TextRepresentation().c_str()+
                  SString("))))")).c_str());
            SReference dotpairref((L|25 || 36));
            TEST("dotted_pair", dotpairref->TextRepresentation().c_str(),
                 "(25 . 36)");
            SReference dotlistref((L|9, 16, 25)||36);
            TEST("dotted_list", dotlistref->TextRepresentation().c_str(),
                 "(9 16 25 . 36)");
            SReference dotpairref2((L|25)^36);
            TEST("dotted_pair", dotpairref2->TextRepresentation().c_str(),
                 "((25) . 36)");
            SReference dotlistref2((L|9, 16, 25)^36);
            TEST("dotted_list", dotlistref2->TextRepresentation().c_str(),
                 "((9 16 25) . 36)");
            SReference just_a_cons(SReference("abc")^SReference(225));
            TEST("cons_with_^", just_a_cons->TextRepresentation().c_str(),
                 "(\"abc\" . 225)");
            SReference empty(L);
            empty,25;
            TEST("comma_on_empty_list", empty->TextRepresentation().c_str(),
                 "(25)");
        }
        TestSubsection("IsEql");
        {
            SReference five(5);
            TESTB("is_eql_numbers", five.IsEql(5));            
            TESTB("isnt_eql_numbers", !five.IsEql(3));            
            TESTB("isnt_eql_num_to_string", !five.IsEql("abc"));            
            SReference abc("abc");
            TESTB("is_eql_strings", abc.IsEql("abc"));            
            TESTB("isnt_eql_strings", !abc.IsEql("def"));            
            TESTB("isnt_eql_string_to_num", !abc.IsEql(5));            
        }
        TestSubsection("UnboundByDefault");
        {
            SReference unbound;
            TESTB("sreference_unbound", !unbound.GetPtr());

            GenericSReference<MyTestTerm22, IntelibX_wrong_expression_type> p;
            TESTB("gensref_unbound", !p.GetPtr());
        }

#if 0  // no support for booleans
        TestSubsection("Booleans");
        {
            SReference true_ref(LTheLispBooleanTrue);
            TESTB("boolean_true", true_ref->IsTrue());
            SReference false_ref(LTheLispBooleanFalse);
            TESTB("boolean_false", !(false_ref->IsTrue()));
            SReference some_ref(25);
            TESTB("boolean_some", some_ref->IsTrue());

        }
#endif
        TestSubsection("Epilogue");
        TEST("final-cleanup", destructed, constructed);
        TestScore();
    }
    catch(...) {
        printf("Something strange caught\n");
    }
    return 0;
}
Example #15
0
void VariableTestFixture::testSimpleExpression() {
 Datum six(M_INTEGER, 6);
	ConstantVariable c1(six);
 Datum five(M_INTEGER, 5);
	ConstantVariable c2(five);
	
	// boolean expressions
	shared_ptr<ExpressionVariable> e;
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_EQUAL));
	CPPUNIT_ASSERT(!e->getValue().getBool());

	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c2, &c2, M_IS_EQUAL));
	CPPUNIT_ASSERT(e->getValue().getBool());
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_NOT_EQUAL));
	CPPUNIT_ASSERT(e->getValue().getBool());
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c1, M_IS_NOT_EQUAL));
	CPPUNIT_ASSERT(!e->getValue().getBool());
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_GREATER_THAN));
	CPPUNIT_ASSERT(e->getValue().getBool());
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c2, &c1, M_IS_GREATER_THAN));
	CPPUNIT_ASSERT(!e->getValue().getBool());
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c1, M_IS_GREATER_THAN));
	CPPUNIT_ASSERT(!e->getValue().getBool());
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_GREATER_THAN_OR_EQUAL));
	CPPUNIT_ASSERT(e->getValue().getBool());
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c2, &c1, M_IS_GREATER_THAN_OR_EQUAL));
	CPPUNIT_ASSERT(!e->getValue().getBool());
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c1, M_IS_GREATER_THAN_OR_EQUAL));
	CPPUNIT_ASSERT(e->getValue().getBool());
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_LESS_THAN));
	CPPUNIT_ASSERT(!e->getValue().getBool());
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c2, &c1, M_IS_LESS_THAN));
	CPPUNIT_ASSERT(e->getValue().getBool());
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c1, M_IS_LESS_THAN));
	CPPUNIT_ASSERT(!e->getValue().getBool());
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_LESS_THAN_OR_EQUAL));
	CPPUNIT_ASSERT(!e->getValue().getBool());
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c2, &c1, M_IS_LESS_THAN_OR_EQUAL));
	CPPUNIT_ASSERT(e->getValue().getBool());
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c1, M_IS_LESS_THAN_OR_EQUAL));
	CPPUNIT_ASSERT(e->getValue().getBool());
	
	// arithmatic expressions
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_PLUS));
	CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six + five));
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_MINUS));
	CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six - five));
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_TIMES));
	CPPUNIT_ASSERT(e->getValue().getFloat() == (float)(six * five));
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_DIVIDE));
	CPPUNIT_ASSERT(e->getValue().getFloat() == (double)(six / five));
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_MOD));
	CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six % five));
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_INCREMENT));
	CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six + Datum(M_FLOAT,1)));
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_DECREMENT));
	CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six - Datum(M_FLOAT,1)));
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, NULL, M_INCREMENT));
	CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six + Datum(M_FLOAT,1)));
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, NULL, M_DECREMENT));
	CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six - Datum(M_FLOAT,1)));
	
 Datum seven(M_INTEGER, 0x7);
	ConstantVariable c3(seven);
 Datum eight(M_INTEGER, 0x8);
	ConstantVariable c4(eight);
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c3, &c4, M_AND));
	CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(seven && eight));
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c3, &c4, M_OR));
	CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(seven || eight));
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c3, &c4, M_NOT));
	CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(!seven));
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c3, NULL, M_NOT));
	CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(!seven));
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_UNARY_MINUS));
	CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six)*-1);
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, NULL, M_UNARY_MINUS));
	CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six)*-1);
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_UNARY_PLUS));
	CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six));
	
	e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, NULL, M_UNARY_PLUS));
	CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six));
}
Example #16
0
int main()
{
    printf("== one() ==\n");
    one(3, 4);
    one(10, 10);


    printf("== two() ==\n");
    const char* a = "20";
    two(a);
    const char* b = "100";
    two(b);

    printf("== three() ==\n");
    three();


    printf("== four() ==\n");
    four(0.5);
    four(1.5);


    printf("== five() ==\n");
    const int num1 = 3;
    const int num2 = 3;
    five(&num1, &num2);

    const int num3 = 4;
    five(&num1, &num3);


    printf("== six() ==\n");
    float *p_six;
    int i4 = 4, i432 = 432;

    p_six = six(&i4);
    printf("%d == %f\n", i4, *p_six);
    free(p_six);

    p_six = six(&i432);
    printf("%d == %f\n", i432, *p_six);
    free(p_six);


    printf("== seven() ==\n");
    const char s = 'S';
    seven(&s);
    const char t = '_';
    seven(&t);


    printf("== eight() ==\n");
    eight();


    printf("== nine() ==\n");
    nine();


    printf("== ten() ==\n");
    int i_ten = 100;
    ten(&i_ten);
    printf("%d == 0?\n", i_ten);


    printf("== eleven() ==\n");
    eleven();


    printf("== twelve() ==\n");
    twelve();


    printf("== thirteen() ==\n");
    thirteen(10);


    printf("== fourteen() ==\n");
    fourteen("red");
    fourteen("orange");
    fourteen("blue");
    fourteen("green");


    printf("== fifteen() ==\n");
    fifteen(1);
    fifteen(2);
    fifteen(3);


    printf("== sixteen() ==\n");
    char *str = sixteen();
    printf("%s\n", str);
    free(str);


    printf("== seventeen() ==\n");
    seventeen(35);
    seventeen(20);


    printf("== eighteen() ==\n");
    eighteen(3);
    eighteen(5);


    printf("== clear_bits() ==\n");
    long int result;

    result = clear_bits(0xFF, 0x55);
    printf("%ld\n", result);

    result = clear_bits(0x00, 0xF0);
    printf("%ld\n", result);

    result = clear_bits(0xAB, 0x00);
    printf("%ld\n", result);

    result = clear_bits(0xCA, 0xFE);
    printf("%ld\n", result);

    result = clear_bits(0x14, 0x00);
    printf("%ld\n", result);

    result = clear_bits(0xBB, 0xBB);
    printf("%ld\n", result);


    return 0;
}
Example #17
0
int main(void) {
    
    i=EEPROM_read(Address); // de vazut adresele cum sunt puse!
    
    //timer_1(1000); // set value in ms
    
    DDRD = 0xf8;
    DDRB = 0xff;
    
    // set external interrupt on digital PIN 2
    cli();
    
    PORTD |= (1 << PORTD2);    // turn On the Pull-up
    
    EICRA |= (1 << ISC00);    //
    EICRA |= (1 << ISC01);    // set INT0 to trigger on rising edge
    
    EIMSK |= (1 << INT0);     // Turns on INT0 - external interrupt mask register
    
    sei();
    
    clear(2);
    clear(1);
    
    while(1){
        
            if(i<100 && i>=1){
    
                nr_2=i%10;
                nr_1=i/10;
                
                if(nr_1>=1){
                    if(nr_1==0){
                        zero(1);
                    }
                    if(nr_1==1){
                        one(1);
                    }
                    if(nr_1==2){
                        two(1);
                    }
                    if(nr_1==3){
                        three(1);
                    }
                    if(nr_1==4){
                        four(1);
                    }
                    if(nr_1==5){
                        five(1);
                    }
                    if(nr_1==6){
                        six(1);
                    }
                    if(nr_1==7){
                        seven(1);
                    }
                    if(nr_1==8){
                        eight(1);
                    }
                    if(nr_1==9){
                        nine(1);
                    }
                }
                
                if(nr_2==0){
                    zero(2);
                }
                if(nr_2==1){
                    one(2);
                }
                if(nr_2==2){
                    two(2);
                }
                if(nr_2==3){
                    three(2);
                }
                if(nr_2==4){
                    four(2);
                }
                if(nr_2==5){
                    five(2);
                }
                if(nr_2==6){
                    six(2);
                }
                if(nr_2==7){
                    seven(2);
                }
                if(nr_2==8){
                    eight(2);
                }
                if(nr_2==9){
                    nine(2);
                }
                
            }
            else{
                i=0;
                clear(2);
                clear(1);
                
            }
        
            EEPROM_write(Address, i);
        
    }
    
	return 0;     
}
Example #18
0
void main()

{
    FILE*file;

    int cases;
    int i,j,k;
    char number[110];

    file=fopen("input.txt","r");

    fscanf(file,"%d",&cases);

    for(i=0; i<cases; i++)
    {
        fscanf(file,"%s",number);
        k=strlen(number);
        for(j=0; j<k; j++)
        {
            number[j]-='0';
        }
        printf("%d %d %d %d %d %d %d %d %d %d\n",two(number,k),three(number,k),four(number,k),five(number,k),six(number,k),seven(number,k),eight(number,k),nine(number,k),ten(number,k),eleven(number,k));
    }
}
Example #19
0
{
	seteuid(getuid());
	set_name(HIC"五转"HIW"聚"HIY"灵盘"NOR,({"five turn","five","turn"}));
	set("long", @LONG
    聚灵山庄的镇庄宝物,是聚灵庄主「凤翔天”随身携带的贴身宝
物,相传如果能获得五道灵魂注入此中,可以获得极大的能量,足以
提供攻击和防护的能力。而且若能配合一阴一阳的聚灵宝物,将是开
启天灵地界的最重要宝物。

    此宝物必需先将注入在身上的灵魂吸取入灵盘中,方有作用,还
可以将其他人身上所注入的魂魄吸取至灵盘中,但必需本身有一道魂
魄做为牵引,否则将无法作用。

吸取魂魄方式:  suck soul  (对自己)
                suck id    (从别人那吸取)
灵气运转方式:  turn five  (开启运转)
                stop five  (关闭运转)
LONG);

	set_weight(1000);
	set("value",100000);
	set("unit","块");
	set("magic-manor-f",1);
	set("no_put",1);
	set("no_drop",1);
	set("no_get",1);
	set("no_sell",1);
	set("no_auc",1);
	set("no_give",1);

	setup();
Example #20
0
int main()
{
	Node<std::string> six("6");
	Node<std::string> five("5");
	Node<std::string> four("4");
	Node<std::string> three("3");
	Node<std::string> two("2");
	Node<std::string> one("1");
	Node<std::string> zero("0");

	DAG<std::string> myGraph;

	myGraph.beginTransaction();

	myGraph.addEdge(four, one);
	myGraph.addEdge(two, three);
	myGraph.addEdge(three, one);
	myGraph.addEdge(five, two);
	myGraph.addEdge(five, zero);
	myGraph.addEdge(four, zero);

	myGraph.endTransaction();

	myGraph.report();

	Node<std::string> next;
	if (myGraph.next(next))
	{
		std::cout << "Next: " << next.value << std::endl;
		myGraph.remove(next);
	}
	if (myGraph.next(next))
	{
		std::cout << "Next: " << next.value << std::endl;
		myGraph.remove(next);
	}

	myGraph.addNode(six);

	if (myGraph.next(next))
	{
		std::cout << "Next: " << next.value << std::endl;
		myGraph.remove(next);
	}
	if (myGraph.next(next))
	{
		std::cout << "Next: " << next.value << std::endl;
		myGraph.remove(next);
	}
	if (myGraph.next(next))
	{
		std::cout << "Next: " << next.value << std::endl;
		myGraph.remove(next);
	}
	if (myGraph.next(next))
	{
		std::cout << "Next: " << next.value << std::endl;
		myGraph.remove(next);
	}
	if (myGraph.next(next))
	{
		std::cout << "Next: " << next.value << std::endl;
		myGraph.remove(next);
	}

	return 0;
}
Example #21
0
Limbs::Limbs(Encoding &g)
  :genome(g)
{
  //create Traits
  Trait spindly(1, -3, 3, "spindly");
  Trait thin(1, -2, 1, "thin");
  Trait thick(-2, 3, 0, "thick");
  Trait round(3, -1, -1, "round");

  Trait zero(0, 0, 3, "0");
  Trait one(1, 1, 3, "1");
  Trait two(3, 1, -3, "2");
  Trait three(-1, 1, 3, "3");
  Trait four(3, 1, -3, "4");
  Trait five(-1, 1, 3, "5");
  Trait six(2, 1, -3, "6");
  Trait seven(-2, 2, 3, "7");
  Trait eight(0, 3, 2, "8");
  Trait nine(-3, 2, 3, "9");
  Trait ten(-2, 3, 2, "10");
  Trait eleven(-3, 2, 3, "11");
  Trait twelve(-3, 3, 2, "12");
  Trait thirteen(-3, 2, 3, "13");
  Trait fourteen(-3, 3, 3, "14");
  Trait fifteen(-3, 2, 3, "15");



  //create all maps
  if (thicknessK.empty() ) {

    thicknessK["spindly"] = 0;
    thicknessK["thin"] = 1;
    thicknessK["thick"] = 2;
    thicknessK["round"] = 3;

    thicknessM[0] = spindly;
    thicknessM[1] = thin;
    thicknessM[2] = thick;
    thicknessM[3] = round;

    numM[0] = zero;
    numM[1] = one;
    numM[2] = two;
    numM[3] = three;
    numM[4] = four;
    numM[5] = five;
    numM[6] = six;
    numM[7] = seven;
    numM[8] = eight;
    numM[9] = nine;
    numM[10] = ten;
    numM[11] = eleven;
    numM[12] = twelve;
    numM[13] = thirteen;
    numM[14] = fourteen;
    numM[15] = fifteen;
  }

  //decode the number of limbs so that there can
  //only be a non-zero even number of them
  number = decodeNumber();
  int numValue = std::stoi(number);
  if (numValue % 2 != 0) {
    encodeNumber(numValue + 1);
    number = decodeNumber();
  }
  if (numValue == 0) {
    encodeNumber(2);
    number = decodeNumber();
  }

  thickness = decodeThickness();


}
Example #22
0
int main()
{
	/* part1.c  */
	printf("== one() ==\n");
	one(3, 4);
	one(10, 10);


	printf("== two() ==\n");
	two(50);
	two(100);


	printf("== three() ==\n");
	three();


	printf("== four() ==\n");
	four(0.5);
	four(1.5);


	printf("== five() ==\n");
	five(3, 3);
	five(3, 4);


	/* part2.c */
	printf("== six() ==\n");
	float *p_six;
	int i4 = 4, i432 = 432;

	p_six = six(&i4);
	printf("%d == %f\n", i4, *p_six);
	free(p_six);

	p_six = six(&i432);
	printf("%d == %f\n", i432, *p_six);
	free(p_six);


	printf("== seven() ==\n");
	seven(2, 12);
	seven(14, 20);


	printf("== eight() ==\n");
	eight();


	printf("== nine() ==\n");
	nine();


	printf("== ten() ==\n");
	int i_ten = 100;
	ten(&i_ten);
	printf("%d == 0?\n", i_ten);


	/* part3.c */
	printf("== eleven() ==\n");
	eleven();


	printf("== twelve() ==\n");
	twelve();


	printf("== thirteen() ==\n");
	thirteen();


	printf("== fourteen() ==\n");
	fourteen("red");
	fourteen("orange");
	fourteen("blue");
	fourteen("green");


	printf("== fifteen() ==\n");
	fifteen(1);
	fifteen(2);
	fifteen(3);


	/* part4.c */
	printf("== sixteen() ==\n");
	char *str = sixteen();
	printf("%s\n", str);
	free(str);


	printf("== seventeen() ==\n");
	seventeen(35);
	seventeen(20);


	printf("== eighteen() ==\n");
	eighteen(3);
	eighteen(5);


	printf("== clear_bits() ==\n");
	long int result;
	
	result = clear_bits(0xFF, 0x55);
	printf("%ld\n", result);

	result = clear_bits(0x00, 0xF0);
	printf("%ld\n", result);

	result = clear_bits(0xAB, 0x00);
	printf("%ld\n", result);

	result = clear_bits(0xCA, 0xFE);
	printf("%ld\n", result);

	result = clear_bits(0x14, 0x00);
	printf("%ld\n", result);

	result = clear_bits(0xBB, 0xBB);
	printf("%ld\n", result);


	return 0;
}
Example #23
0
void test_epsilon_deleting()
{
	std::cout << "Testing epsilon deleting..." << std::endl << std::endl;

	State zero("0", state_type::NONFINAL);
	State one("1", state_type::NONFINAL);
	State two("2", state_type::FINAL);
	State three("3", state_type::NONFINAL);
	State four("4", state_type::FINAL);
	State five("5", state_type::NONFINAL);

	std::vector<State*> states;

	std::set<State*> zeroStatesEps;
	std::set<State*> oneStatesA;
	std::set<State*> twoStatesEps;
	std::set<State*> twoStatesA;
	std::set<State*> threeStatesEps;
	std::set<State*> fourStates;
	std::set<State*> fiveStatesEps;
	std::set<State*> fiveStatesB;

	states.push_back(&zero);
	states.push_back(&one);
	states.push_back(&two);
	states.push_back(&three);
	states.push_back(&four);
	states.push_back(&five);

	zeroStatesEps.insert(&one);
	zeroStatesEps.insert(&two);
	zeroStatesEps.insert(&three);
	oneStatesA.insert(&four);
	twoStatesEps.insert(&four);
	twoStatesA.insert(&five);
	threeStatesEps.insert(&five);
	fiveStatesEps.insert(&three);
	fiveStatesB.insert(&four);

	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;
	std::unordered_map<char , std::set<State*> > fourTransitions;
	std::unordered_map<char , std::set<State*> > fiveTransitions;

	zeroTransitions[0] = zeroStatesEps;
	oneTransitions['a'] = oneStatesA;
	twoTransitions[0] = twoStatesEps;
	twoTransitions['a'] = twoStatesA;
	threeTransitions[0] = threeStatesEps;
	fiveTransitions[0] = fiveStatesEps;
	fiveTransitions['b'] = fiveStatesB;

	std::unordered_map< State*,  std::unordered_map<char , std::set<State*> > > transitions;

	transitions[&zero] = zeroTransitions;
	transitions[&one] = oneTransitions;
	transitions[&two] = twoTransitions;
	transitions[&three] = threeTransitions;
	transitions[&four] = fourTransitions;
	transitions[&five] = fiveTransitions;

	Automata automata(transitions);
	automata.setInitial(&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.removeEpsilonTransitions();

	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 * cbFunc(gpointer data)
{
	Shared *shared = static_cast<Shared*>(data);

	if(!shared)
	{
		throw std::runtime_error("Could not cast shared object.");
	}

	vector<DictionaryList<string> > insertList;

	while(1)
	{
		DBObject* obj = shared->queue.pop();

		if( obj->quit )
		{
			delete obj;
			break;
		}

		DictionaryList<string> dict;

		NameValuePair<string> one("key", obj->key);
		NameValuePair<string> two("value", obj->value);
		NameValuePair<string> three("source", obj->source);
		NameValuePair<string> four("time", boost::lexical_cast<string>(obj->time));
		NameValuePair<string> five("sequence", boost::lexical_cast<string>(obj->sequence));

		dict.push_back(one);
		dict.push_back(two);
		dict.push_back(three);
		dict.push_back(four);
		dict.push_back(five);

		insertList.push_back(dict);

		if(insertList.size() > bufferLength)
		{
			shared->db->exec("BEGIN IMMEDIATE TRANSACTION");
			for(int i=0; i< insertList.size(); i++)
			{
				DictionaryList<string> d = insertList[i];
				shared->db->insert(d);
			}
			shared->db->exec("END TRANSACTION");
			insertList.clear();
		}
		delete obj;
	}

	/// final flush of whatever is still in the queue:

	shared->db->exec("BEGIN IMMEDIATE TRANSACTION");
	for(int i=0; i< insertList.size(); i++)
	{
		DictionaryList<string> d = insertList[i];
		shared->db->insert(d);
	}
	shared->db->exec("END TRANSACTION");

	return NULL;
}