diff options
author | cathook <b01902109@csie.ntu.edu.tw> | 2014-06-24 14:23:04 +0800 |
---|---|---|
committer | cathook <b01902109@csie.ntu.edu.tw> | 2014-06-24 14:23:04 +0800 |
commit | 0667012e725099e13045ebf4f2f2bee5bd049edc (patch) | |
tree | 62dd8fb100d493323f24f6e54cf403f2c8ad18c4 /meowpp/gra/IdentityPoints.h | |
parent | a9955a1a51df2b268da4d28f9ad10dbaf9815634 (diff) | |
download | meow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar meow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar.gz meow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar.bz2 meow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar.lz meow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar.xz meow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar.zst meow-0667012e725099e13045ebf4f2f2bee5bd049edc.zip |
add test code "feature"
Diffstat (limited to 'meowpp/gra/IdentityPoints.h')
-rw-r--r-- | meowpp/gra/IdentityPoints.h | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/meowpp/gra/IdentityPoints.h b/meowpp/gra/IdentityPoints.h index 1646bf7..edac56e 100644 --- a/meowpp/gra/IdentityPoints.h +++ b/meowpp/gra/IdentityPoints.h @@ -29,11 +29,12 @@ private: IdentityPointsMap points_; size_t dimension_; - Myself() { - dimension_ = 1; + Myself(): dimension_(1) { } + Myself(Myself const& m): points_(m.points_), dimension_(m.dimension_) { } + ~Myself() { } }; @@ -134,77 +135,77 @@ public: /*! * @brief 取得所有identity points */ - IdentityPointsMap const& identityPoints() const { - return self->points_; + IdentityPointsMap const& points() const { + return self()->points_; } /*! * @brief 設定所有identity points */ - IdentityPointsMap const& identityPoints(IdentityPointsMap const& points) { + IdentityPointsMap const& points(IdentityPointsMap const& points) { clear(); - return identityPointsAdd(points); + return pointsAdd(points); } /*! * @brief 加入identity Points */ - IdentityPointsMap const& identityPointsAdd(IdentityPointsMap const& points) { + IdentityPointsMap const& pointsAdd(IdentityPointsMap const& points) { for (IdentityPointsMapIterK it = points.begin(); it != points.end(); ++it) { - identityPointAdd(it.first, it.second); + pointAdd(it.first, it.second); } - return identityPoints(); + return points(); } /*! * @brief 移除identity Points */ - IdentityPointsMap const& identityPointsDel(std::set<ID> const& ids) { + IdentityPointsMap const& pointsDel(std::set<ID> const& ids) { for (typename std::set<ID>::const_iterator it = ids.begin(); it != ids.end(); ++it) { - identityPointDel(*it); + pointDel(*it); } - return identityPoints(); + return points(); } /*! * @brief 取得一個identity point */ - Vector<Scalar> identityPoint(ID const& id) const { + Vector<Scalar> point(ID const& id) const { return (exist(id) ? self->points_.find(id)->second : Vector<Scalar>()); } /*! * @brief 修改一個identity point */ - Vector<Scalar> identityPoint(ID const& id, Vector<Scalar> const& b) { + Vector<Scalar> point(ID const& id, Vector<Scalar> const& b) { if (b.dimension() == self->dimension_ && exist(id)) { self()->points_[id].copyFrom(b); } - return identityPoint(id); + return point(id); } /*! * @brief 新增一個identity point */ - Vector<Scalar> identityPointAdd(ID const& id, Vector<Scalar> const& b) { + Vector<Scalar> pointAdd(ID const& id, Vector<Scalar> const& b) { if (b.dimension() == self->dimension_ && !exist(id)) { self()->points_[id].copyFrom(b); } - return identityPoint(id); + return point(id); } /*! * @brief 刪除一個identity point */ - void identityPointDel(ID const& id) { + void pointDel(ID const& id) { self()->points_.erase(id); } /*! * @brief 取得一個identity point, non-constant reference */ - Vector<Scalar>& identityPointGet(ID const& id) { + Vector<Scalar>& pointGet(ID const& id) { return self()->points_[id]; } @@ -225,8 +226,7 @@ public: if (fwrite(&(dim = dimension()), sizeof(dim), 1, f) < 1) return false; if (fwrite(&(ct = size()), sizeof(ct), 1, f) < 1) return false; for (IdentityPointsMapIterK - it = identityPoints().begin(), ed = identityPoints().end(); - it != ed; ++it) { + it = points().begin(), ed = points().end(); it != ed; ++it) { double tmp; if (fwrite(&(tmp = it->first), sizeof(tmp), 1, f) < 1) return false; for (long i = 0; i < dim; ++i) { @@ -238,8 +238,7 @@ public: else { if (fprintf(f, "%ld %lu\n", dimension(), size()) < 1) return false; for (IdentityPointsMapIterK - it = identityPoints().begin(), ed = identityPoints().end(); - it != ed; ++it) { + it = points().begin(), ed = points().end(); it != ed; ++it) { if (fprintf(f, "%f ", (double)it->first) < 1) return false; for (long i = 0, I = dimension(); i < I; ++i) { if (fprintf(f, "%f ", (double)it->second(i)) < 1) return false; @@ -266,9 +265,9 @@ public: if (fread(&id, sizeof(id), 1, f) < 1) return false; for (size_t j = 0, J = dim; j < J; ++j) { if (fread(&tt, sizeof(tt), 1, f) < 1) return false; - tmp.entry(j, tt); + tmp.scalar(j, tt); } - identityPointAdd((ID)id, tmp); + pointAdd((ID)id, tmp); } } else { @@ -280,9 +279,9 @@ public: if (fscanf(f, "%lf", &id) < 1) return false; for (int j = 0, J = dim; j < J; ++j) { if (fscanf(f, "%lf", &tt) < 1) return false; - tmp.entry(j, tt); + tmp.scalar(j, tt); } - identityPointAdd((ID)id, tmp); + pointAdd((ID)id, tmp); } } return true; @@ -326,6 +325,6 @@ public: } }; -} +} // meow #endif // gra_IdentityPoints_H__ |