diff options
author | vng <viktor.govako@gmail.com> | 2015-07-28 17:06:39 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:58:25 +0300 |
commit | e495039d778dbe6360b05f2b81cecc2efcb00bc3 (patch) | |
tree | 27e45af03e1b926ff0c68e6cfde6a61064ddc98a /geometry | |
parent | f911cf58e14bfe5585dd186e6524b90cb8e79c42 (diff) |
VNG review fixes.
Diffstat (limited to 'geometry')
-rw-r--r-- | geometry/region2d.hpp | 12 | ||||
-rw-r--r-- | geometry/tree4d.hpp | 28 |
2 files changed, 31 insertions, 9 deletions
diff --git a/geometry/region2d.hpp b/geometry/region2d.hpp index 71d3f6f53a..11897587fa 100644 --- a/geometry/region2d.hpp +++ b/geometry/region2d.hpp @@ -80,11 +80,15 @@ namespace m2 //@} public: - Region() {} + Region() = default; + + explicit Region(vector<PointD> && points) : m_points(move(points)) + { + CalcLimitRect(); + } template <class IterT> - Region(IterT first, IterT last) - : m_points(first, last) + Region(IterT first, IterT last) : m_points(first, last) { CalcLimitRect(); } @@ -119,7 +123,7 @@ namespace m2 for_each(m_points.begin(), m_points.end(), toDo); } - inline m2::Rect<CoordT> GetRect() const { return m_rect; } + inline m2::Rect<CoordT> const & GetRect() const { return m_rect; } inline size_t GetPointsCount() const { return m_points.size(); } inline bool IsValid() const { return GetPointsCount() > 2; } diff --git a/geometry/tree4d.hpp b/geometry/tree4d.hpp index caef044fbe..3b9ee92f1f 100644 --- a/geometry/tree4d.hpp +++ b/geometry/tree4d.hpp @@ -25,8 +25,17 @@ namespace m4 template <class T, typename Traits = TraitsDef<T> > class Tree { - struct ValueT + class ValueT { + void SetRect(m2::RectD const & r) + { + m_pts[0] = r.minX(); + m_pts[1] = r.minY(); + m_pts[2] = r.maxX(); + m_pts[3] = r.maxY(); + } + + public: T m_val; double m_pts[4]; @@ -34,10 +43,11 @@ namespace m4 ValueT(T const & t, m2::RectD const & r) : m_val(t) { - m_pts[0] = r.minX(); - m_pts[1] = r.minY(); - m_pts[2] = r.maxX(); - m_pts[3] = r.maxY(); + SetRect(r); + } + ValueT(T && t, m2::RectD const & r) : m_val(move(t)) + { + SetRect(r); } bool IsIntersect(m2::RectD const & r) const @@ -129,11 +139,19 @@ namespace m4 { Add(obj, GetLimitRect(obj)); } + void Add(T && obj) + { + Add(move(obj), GetLimitRect(obj)); + } void Add(T const & obj, m2::RectD const & rect) { m_tree.insert(ValueT(obj, rect)); } + void Add(T && obj, m2::RectD const & rect) + { + m_tree.insert(ValueT(move(obj), rect)); + } private: template <class CompareT> |