diff -r a3bab31c7e27 -r c4ad4e3c6839 src/types.h --- a/src/types.h Mon May 27 13:49:07 2013 +0300 +++ b/src/types.h Mon May 27 18:17:21 2013 +0300 @@ -106,6 +106,7 @@ bool operator== (const vertex& other) const; bool operator!= (const vertex& other) const; vertex operator- () const; + int operator< (const vertex& other) const; double& operator[] (const Axis ax); const double& operator[] (const Axis ax) const; double& operator[] (const int ax); @@ -158,6 +159,11 @@ m_vect.push_back (value); } + void push_back (const vector& vals) { + for (const T& val : vals) + push_back (val); + } + bool pop (T& val) { if (size () == 0) return false; @@ -172,6 +178,11 @@ return *this; } + vector& operator<< (const vector& vals) { + push_back (vals); + return *this; + } + bool operator>> (T& value) { return pop (value); } @@ -193,6 +204,14 @@ m_vect.insert (m_vect.begin () + pos, value); } + void makeUnique () { + // Remove duplicate entries. For this to be effective, the vector must be + // sorted first. + sort (); + it pos = std::unique (begin (), end ()); + resize (std::distance (begin (), pos)); + } + ulong size () const { return m_vect.size (); } @@ -211,11 +230,8 @@ m_vect.resize (size); } - template vector& operator= (T vals[N]) { - for (int i = 0; i < N; ++i) - push_back (vals[i]); - - return *this; + void sort () { + std::sort (begin (), end ()); } private: