50 #include <boost/serialization/access.hpp>
51 #include <boost/functional/hash.hpp>
53 #include "RepastErrors.h"
68 std::size_t operator()(
const Point<T>& pt)
const {
77 std::ostream& operator<<(std::ostream& os,
const Point<T>& pt);
90 friend std::ostream& operator<<<> (std::ostream& os,
const Point<T>& pt);
98 friend class boost::serialization::access;
100 template<
class Archive>
101 void serialize(Archive& ar,
const unsigned int version) {
108 typedef typename std::vector<T>::const_iterator const_iterator;
132 Point(T x, T y, T z);
140 Point(std::vector<T> coordinates);
189 void add(
const Point<T> &pt);
239 return point.begin();
247 const_iterator
end()
const {
257 void copy(std::vector<T>& out)
const;
261 bool operator==(
const Point<T> &one,
const Point<T> &two);
263 bool operator!=(
const Point<T> &one,
const Point<T> &two);
265 std::ostream& operator<<(std::ostream& os,
const Point<T>& pt);
290 point(coordinates.size(), 0) {
291 std::copy(coordinates.begin(), coordinates.end(), point.begin());
298 boost::hash<T> hasher;
299 for (
size_t i = 0; i < point.size(); i++) {
300 hash = 37 * hash + hasher(point[i]);
321 return point.at(coordIndex);
326 std::copy(point.begin(), point.end(), out.begin());
331 return one.point == two.point;
335 bool operator!=(
const Point<T> &one,
const Point<T> &two) {
336 return !(one == two);
341 if (pt.
dimensionCount() != dimensionCount())
throw Repast_Error_35<Point<T> >(*
this, pt);
343 for (
size_t i = 0; i < point.size(); i++) {
349 std::ostream& operator<<(std::ostream& os,
const Point<T>& pt) {
351 for (
size_t i = 0; i < pt.point.size(); i++) {
361 bool operator<(
const Point<T>& one,
const Point<T>& two) {
362 return std::lexicographical_compare(one.begin(), one.end(), two.begin(), two.end());