diff options
author | Yuri Gorshenin <y@maps.me> | 2015-02-04 11:24:30 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:37:10 +0300 |
commit | 994873c081cf1a0e37f19d3544c2487f2ee13ab8 (patch) | |
tree | d81c7f5335c3f0f580b255afc065b1cd616c4135 /map/user_mark_container.cpp | |
parent | 7fd7b95f35f9720c8636b8959f056d6d2f6f9ec7 (diff) |
Fixed bookmarks order: least recently added bookmark is displayed first in the list.
Diffstat (limited to 'map/user_mark_container.cpp')
-rw-r--r-- | map/user_mark_container.cpp | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/map/user_mark_container.cpp b/map/user_mark_container.cpp index 6ed109aba5..9a8c665c22 100644 --- a/map/user_mark_container.cpp +++ b/map/user_mark_container.cpp @@ -202,8 +202,9 @@ MyPositionMarkPoint * UserMarkContainer::UserMarkForMyPostion() UserMark * UserMarkContainer::CreateUserMark(m2::PointD const & ptOrg) { - m_userMarks.push_back(AllocateUserMark(ptOrg)); - return m_userMarks.back(); + unique_ptr<UserMark> mark(AllocateUserMark(ptOrg)); + m_userMarks.push_front(mark.get()); + return mark.release(); } size_t UserMarkContainer::GetUserMarkCount() const @@ -223,37 +224,33 @@ UserMark * UserMarkContainer::GetUserMark(size_t index) return m_userMarks[index]; } -namespace -{ - -template <class T> void DeleteItem(vector<T> & v, size_t i) +void UserMarkContainer::DeleteUserMark(size_t index) { - if (i < v.size()) + ASSERT_LESS(index, m_userMarks.size(), ()); + if (index < m_userMarks.size()) { - delete v[i]; - v.erase(v.begin() + i); + delete m_userMarks[index]; + m_userMarks.erase(m_userMarks.begin() + index); } else { - LOG(LWARNING, ("Trying to delete non-existing item at index", i)); + LOG(LWARNING, ("Trying to delete non-existing item at index", index)); } } -} - -void UserMarkContainer::DeleteUserMark(size_t index) -{ - ASSERT_LESS(index, m_userMarks.size(), ()); - DeleteItem(m_userMarks, index); -} - void UserMarkContainer::DeleteUserMark(UserMark const * mark) { - vector<UserMark *>::iterator it = find(m_userMarks.begin(), m_userMarks.end(), mark); + UserMarksListT::iterator it = find(m_userMarks.begin(), m_userMarks.end(), mark); if (it != m_userMarks.end()) DeleteUserMark(distance(m_userMarks.begin(), it)); } +size_t UserMarkContainer::FindUserMark(UserMark const * mark) +{ + return distance(m_userMarks.begin(), + find(m_userMarks.begin(), m_userMarks.end(), mark)); +} + SearchUserMarkContainer::SearchUserMarkContainer(double layerDepth, Framework & framework) : UserMarkContainer(layerDepth, framework) { |