260:a3bab31c7e27 | 261:c4ad4e3c6839 |
---|---|
104 vertex operator/ (const double d) const; | 104 vertex operator/ (const double d) const; |
105 vertex& operator/= (const double d); | 105 vertex& operator/= (const double d); |
106 bool operator== (const vertex& other) const; | 106 bool operator== (const vertex& other) const; |
107 bool operator!= (const vertex& other) const; | 107 bool operator!= (const vertex& other) const; |
108 vertex operator- () const; | 108 vertex operator- () const; |
109 int operator< (const vertex& other) const; | |
109 double& operator[] (const Axis ax); | 110 double& operator[] (const Axis ax); |
110 const double& operator[] (const Axis ax) const; | 111 const double& operator[] (const Axis ax) const; |
111 double& operator[] (const int ax); | 112 double& operator[] (const int ax); |
112 const double& operator[] (const int ax) const; | 113 const double& operator[] (const int ax) const; |
113 | 114 |
154 m_vect.erase (m_vect.begin () + pos); | 155 m_vect.erase (m_vect.begin () + pos); |
155 } | 156 } |
156 | 157 |
157 void push_back (const T& value) { | 158 void push_back (const T& value) { |
158 m_vect.push_back (value); | 159 m_vect.push_back (value); |
160 } | |
161 | |
162 void push_back (const vector<T>& vals) { | |
163 for (const T& val : vals) | |
164 push_back (val); | |
159 } | 165 } |
160 | 166 |
161 bool pop (T& val) { | 167 bool pop (T& val) { |
162 if (size () == 0) | 168 if (size () == 0) |
163 return false; | 169 return false; |
170 vector<T>& operator<< (const T& value) { | 176 vector<T>& operator<< (const T& value) { |
171 push_back (value); | 177 push_back (value); |
172 return *this; | 178 return *this; |
173 } | 179 } |
174 | 180 |
181 vector<T>& operator<< (const vector<T>& vals) { | |
182 push_back (vals); | |
183 return *this; | |
184 } | |
185 | |
175 bool operator>> (T& value) { | 186 bool operator>> (T& value) { |
176 return pop (value); | 187 return pop (value); |
177 } | 188 } |
178 | 189 |
179 vector<T> reverse () const { | 190 vector<T> reverse () const { |
191 | 202 |
192 void insert (ulong pos, const T& value) { | 203 void insert (ulong pos, const T& value) { |
193 m_vect.insert (m_vect.begin () + pos, value); | 204 m_vect.insert (m_vect.begin () + pos, value); |
194 } | 205 } |
195 | 206 |
207 void makeUnique () { | |
208 // Remove duplicate entries. For this to be effective, the vector must be | |
209 // sorted first. | |
210 sort (); | |
211 it pos = std::unique (begin (), end ()); | |
212 resize (std::distance (begin (), pos)); | |
213 } | |
214 | |
196 ulong size () const { | 215 ulong size () const { |
197 return m_vect.size (); | 216 return m_vect.size (); |
198 } | 217 } |
199 | 218 |
200 T& operator[] (ulong n) { | 219 T& operator[] (ulong n) { |
209 | 228 |
210 void resize (std::ptrdiff_t size) { | 229 void resize (std::ptrdiff_t size) { |
211 m_vect.resize (size); | 230 m_vect.resize (size); |
212 } | 231 } |
213 | 232 |
214 template<int N> vector<T>& operator= (T vals[N]) { | 233 void sort () { |
215 for (int i = 0; i < N; ++i) | 234 std::sort (begin (), end ()); |
216 push_back (vals[i]); | |
217 | |
218 return *this; | |
219 } | 235 } |
220 | 236 |
221 private: | 237 private: |
222 std::vector<T> m_vect; | 238 std::vector<T> m_vect; |
223 }; | 239 }; |