Пример #1
0
PartyHistory check_party()
{
    GuestSetT mary_harry; 
    mary_harry.insert("Mary");
    mary_harry.insert("Harry");

    GuestSetT diana_susan; 
    diana_susan.insert("Diana");
    diana_susan.insert("Susan");

    GuestSetT peter; 
    peter.insert("Peter");

    GuestSetT Diana_Harry_Mary_Susan       = mary_harry + diana_susan;
    GuestSetT Diana_Harry_Mary_Peter_Susan = Diana_Harry_Mary_Susan + peter;
    GuestSetT Diana_Peter_Susan            = Diana_Harry_Mary_Peter_Susan - mary_harry;

    PartyHistory party;

    party += episode("2008-05-20 19:30", "2008-05-20 20:10", mary_harry);
    party += episode("2008-05-20 20:10", "2008-05-20 22:15", Diana_Harry_Mary_Susan);
    party += episode("2008-05-20 22:15", "2008-05-20 23:00", Diana_Harry_Mary_Peter_Susan);
    party += episode("2008-05-20 23:00", "2008-05-21 00:00", Diana_Peter_Susan);
    party += episode("2008-05-21 00:00", "2008-05-21 00:30", peter);

    return party;
}
Пример #2
0
void party()
{
    GuestSetT mary_harry; 
    mary_harry.insert("Mary");
    mary_harry.insert("Harry");

    GuestSetT diana_susan; 
    diana_susan.insert("Diana");
    diana_susan.insert("Susan");

    GuestSetT peter; 
    peter.insert("Peter");

    interval_map<Time, GuestSetT> party;

    party += make_pair( interval<Time>::right_open(Time(19,30), Time(23,00)), mary_harry);
    party += make_pair( interval<Time>::right_open(Time(20,10), Time(monday,0,0)), diana_susan);
    party += make_pair( interval<Time>::right_open(Time(22,15), Time(monday,0,30)), peter);

    interval_map<Time, GuestSetT>::iterator it = party.begin();
    while(it != party.end())
    {
        discrete_interval<Time> when = it->first;
        // Who is at the party within the time interval 'when' ?
        GuestSetT who = (*it++).second;
        cout << when << ": " << who << endl;
    }
}
Пример #3
0
void testICL() {
	cout << setw(60) << setfill('=') << ">testICL" << endl;
	using namespace boost::posix_time;
	using namespace boost::icl;
	typedef std::set<string> GuestSetT;

    GuestSetT mary_harry;
    mary_harry.insert("Mary");
    mary_harry.insert("Harry");

    GuestSetT diana_susan;
    diana_susan.insert("Diana");
    diana_susan.insert("Susan");

    GuestSetT peter;
    peter.insert("Peter");

    // A party is an interval map that maps time intervals to sets of guests
    interval_map<ptime, GuestSetT> party;

    party.add( // add and element
      make_pair(
        interval<ptime>::right_open(
          time_from_string("2008-05-20 19:30"),
          time_from_string("2008-05-20 23:00")),
        mary_harry));

    party += // element addition can also be done via operator +=
      make_pair(
        interval<ptime>::right_open(
          time_from_string("2008-05-20 20:10"),
          time_from_string("2008-05-21 00:00")),
        diana_susan);

    party +=
      make_pair(
        interval<ptime>::right_open(
          time_from_string("2008-05-20 22:15"),
          time_from_string("2008-05-21 00:30")),
        peter);


    interval_map<ptime, GuestSetT>::iterator it = party.begin();
    cout << "----- History of party guests -------------------------\n";
    while(it != party.end())
    {
        interval<ptime>::type when = it->first;
        // Who is at the party within the time interval 'when' ?
        GuestSetT who = (*it++).second;
        cout << when << ": " << who << endl;
    }
}
Пример #4
0
void boost_party()
{
    GuestSetT mary_harry; 
    mary_harry.insert("Mary");
    mary_harry.insert("Harry");

    GuestSetT diana_susan; 
    diana_susan.insert("Diana");
    diana_susan.insert("Susan");

    GuestSetT peter; 
    peter.insert("Peter");

    // A party is an interval map that maps time intervals to sets of guests
    interval_map<ptime, GuestSetT> party;

    party.add( // add and element
      make_pair( 
        interval<ptime>::rightopen(
          time_from_string("2008-05-20 19:30"), 
          time_from_string("2008-05-20 23:00")), 
        mary_harry));

    party += // element addition can also be done via operator +=
      make_pair( 
        interval<ptime>::rightopen(
          time_from_string("2008-05-20 20:10"), 
          time_from_string("2008-05-21 00:00")), 
        diana_susan);

    party +=
      make_pair( 
        interval<ptime>::rightopen(
          time_from_string("2008-05-20 22:15"), 
          time_from_string("2008-05-21 00:30")), 
        peter);


    interval_map<ptime, GuestSetT>::iterator it = party.begin();
    cout << "----- History of party guests -------------------------\n";
    while(it != party.end())
    {
        interval<ptime> when = it->first;
        // Who is at the party within the time interval 'when' ?
        GuestSetT who = (*it++).second;
        cout << "[" << when.first() << " - " << when.upper() << ")"
             << ": " << who << endl;
    }

}
Пример #5
0
void boost_party()
{
    GuestSetT mary_harry; 
    mary_harry.insert("Mary");
    mary_harry.insert("Harry");

    GuestSetT diana_susan; 
    diana_susan.insert("Diana");
    diana_susan.insert("Susan");

    GuestSetT peter; 
    peter.insert("Peter");

    BoostPartyAttendenceHistoryT party;

    party.add( // add and element
      make_pair( 
        rightopen_interval<ptime>(
          time_from_string("2008-05-20 19:30"), 
          time_from_string("2008-05-20 23:00")), 
          mary_harry));

    party += // element addition can also be done via operator +=
      make_pair( 
        rightopen_interval<ptime>(
          time_from_string("2008-05-20 20:10"), 
          time_from_string("2008-05-21 00:00")), 
          diana_susan);
    party +=
      make_pair( 
        rightopen_interval<ptime>(
          time_from_string("2008-05-20 22:15"), 
          time_from_string("2008-05-21 00:30")), 
          peter);

    //-------------------------------------------------------------------------
    BoostPartyHeightHistoryT tallest_guest;

    // adding an element can be done wrt. simple aggregate functions
    // like e.g. min, max etc. in their 'inplace' or op= incarnation
    tallest_guest.add<inplace_max>(
      make_pair( 
        rightopen_interval<ptime>(
          time_from_string("2008-05-20 19:30"), 
          time_from_string("2008-05-20 23:00")), 
          180));

    tallest_guest.add<inplace_max>(
      make_pair( 
        rightopen_interval<ptime>(
          time_from_string("2008-05-20 20:10"), 
          time_from_string("2008-05-21 00:00")), 
          170));

    tallest_guest.add<inplace_max>(
      make_pair( 
        rightopen_interval<ptime>(
          time_from_string("2008-05-20 22:15"), 
          time_from_string("2008-05-21 00:30")), 
          200));


    BoostPartyAttendenceHistoryT::iterator it = party.begin();
    cout << "----- Histrory of party guests ------------------------\n";
    while(it != party.end())
    {
        interval<ptime> when = (*it).first;
        // Who is at the party within the time interval 'when' ?
        GuestSetT who = (*it++).second;
        cout << "[" << when.first() << " - " << when.upper() << ")"
             << ": " << who.as_string() << endl;
    }

    BoostPartyHeightHistoryT::iterator height_ = tallest_guest.begin();
    cout << "----- Histrory of maximum guest height ----------------\n";
    while(height_ != tallest_guest.end())
    {
        interval<ptime> when = height_->first;
        // Of what height are the tallest guests within the time interval 'when' ?
        int height = (*height_++).second;
        cout << "[" << when.first() << " - " << when.upper() << ")"
             << ": " << height <<" cm = " << height/30.48 << " ft" << endl;
    }
}