mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-27 10:07:19 +02:00
Enhancement - Sequence implemented
- Implemented a sequence object to handle ID sequences.
This commit is contained in:
parent
fbea29e27c
commit
3cdfb733de
2 changed files with 20 additions and 0 deletions
|
@ -25,7 +25,9 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "util.h"
|
||||||
#include "Sequence.h"
|
#include "Sequence.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -62,3 +64,20 @@ void Sequence::parse (const std::string& input)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void Sequence::combine (const Sequence& other)
|
||||||
|
{
|
||||||
|
// Create a map using the sequence elements as keys. This will create a
|
||||||
|
// unique list, with no duplicates.
|
||||||
|
std::map <int, int> both;
|
||||||
|
foreach (i, *this) both[*i] = 0;
|
||||||
|
foreach (i, other) both[*i] = 0;
|
||||||
|
|
||||||
|
// Now make a sequence out of the keys of the map.
|
||||||
|
this->clear ();
|
||||||
|
foreach (i, both)
|
||||||
|
this->push_back (i->first);
|
||||||
|
|
||||||
|
std::sort (this->begin (), this->end ());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -39,6 +39,7 @@ public:
|
||||||
~Sequence (); // Destructor
|
~Sequence (); // Destructor
|
||||||
|
|
||||||
void parse (const std::string&);
|
void parse (const std::string&);
|
||||||
|
void combine (const Sequence&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue