diff --git a/src/objects/Sequence.cpp b/src/objects/Sequence.cpp index 4c6bcf7f7..ca06f3be4 100644 --- a/src/objects/Sequence.cpp +++ b/src/objects/Sequence.cpp @@ -25,7 +25,9 @@ // //////////////////////////////////////////////////////////////////////////////// +#include #include +#include "util.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 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 ()); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/objects/Sequence.h b/src/objects/Sequence.h index eb2abbee6..85f417a2f 100644 --- a/src/objects/Sequence.h +++ b/src/objects/Sequence.h @@ -39,6 +39,7 @@ public: ~Sequence (); // Destructor void parse (const std::string&); + void combine (const Sequence&); }; #endif