From 35b3b09ab81beafb96ce67609de707ebd7097a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9rik=20Paradis?= Date: Sat, 14 May 2016 14:28:51 -0400 Subject: [PATCH] Adding less-than operator (<) to Point_d --- Kernel_d/doc/Kernel_d/CGAL/Kernel_d/Point_d.h | 32 +++++++++++++++++++ Kernel_d/include/CGAL/Kernel_d/Point_d.h | 8 +++++ 2 files changed, 40 insertions(+) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Kernel_d/Point_d.h b/Kernel_d/doc/Kernel_d/CGAL/Kernel_d/Point_d.h index 772363a625b..b1493b3fda6 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Kernel_d/Point_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Kernel_d/Point_d.h @@ -241,6 +241,38 @@ the origin. */ bool operator==(const Origin&) ; +/*! +returns true iff `p` is lexicographically +smaller than `q` with respect to %Cartesian +lexicographic order of points. +\pre `p.dimension() == q.dimension()`. +*/ +bool operator<(const Point_d& q); + +/*! +returns true iff `p` is lexicographically +greater than `q` with respect to %Cartesian +lexicographic order of points. +\pre `p.dimension() == q.dimension()`. +*/ +bool operator>(const Point_d& q); + +/*! +returns true iff `p` is lexicographically +smaller than or equal to `q` with respect to %Cartesian +lexicographic order of points. +\pre `p.dimension() == q.dimension()`. +*/ +bool operator<=(const Point_d& q); + +/*! +returns true iff `p` is lexicographically +greater than or equal to `q` with respect to %Cartesian +lexicographic order of points. +\pre `p.dimension() == q.dimension()`. +*/ +bool operator>=(const Point_d& q); + /// @} }; /* end Point_d */ diff --git a/Kernel_d/include/CGAL/Kernel_d/Point_d.h b/Kernel_d/include/CGAL/Kernel_d/Point_d.h index 6f9434609b9..703a8202173 100644 --- a/Kernel_d/include/CGAL/Kernel_d/Point_d.h +++ b/Kernel_d/include/CGAL/Kernel_d/Point_d.h @@ -93,6 +93,14 @@ public: Self& operator-=(const Vector_d& v) { return static_cast(Base::operator-=(v)); } + inline bool operator<(const Self& q) const + { return R().less_lexicographically_d_object()(*this, q); } + inline bool operator>(const Self& q) const + { return R().less_lexicographically_d_object()(q, *this); } + inline bool operator<=(const Self& q) const + { return ! R().less_lexicographically_d_object()(q, *this); } + inline bool operator>=(const Self& q) const + { return ! R().less_lexicographically_d_object()(*this, q); } }; } //namespace CGAL