diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-05-13 23:22:54 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-05-13 23:22:54 +0100 |
| commit | 11d9b607668d56c8deaf9062d48d9ce7aa6f5928 (patch) | |
| tree | c7473586d11e33c2d2841ef459b3feed698be3d0 /src/selection.hh | |
| parent | a06094b00e92d34e9f0be6abf80e5f4ce64998b3 (diff) | |
Make it harder to have an invalid SelectionList
Diffstat (limited to 'src/selection.hh')
| -rw-r--r-- | src/selection.hh | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/selection.hh b/src/selection.hh index 9b3f747a..f8727b90 100644 --- a/src/selection.hh +++ b/src/selection.hh @@ -57,15 +57,11 @@ static bool compare_selections(const Selection& lhs, const Selection& rhs) struct SelectionList { - SelectionList(const Buffer& buffer); SelectionList(const Buffer& buffer, Selection s); SelectionList(const Buffer& buffer, Selection s, size_t timestamp); SelectionList(const Buffer& buffer, std::vector<Selection> s); SelectionList(const Buffer& buffer, std::vector<Selection> s, size_t timestamp); - void update_insert(ByteCoord begin, ByteCoord end, bool at_end); - void update_erase(ByteCoord begin, ByteCoord end, bool at_end); - void update(); void check_invariant() const; @@ -83,6 +79,15 @@ struct SelectionList Selection& operator[](size_t i) { return m_selections[i]; } const Selection& operator[](size_t i) const { return m_selections[i]; } + SelectionList& operator=(std::vector<Selection> list) + { + m_selections = std::move(list); + m_main = size()-1; + sort_and_merge_overlapping(); + check_invariant(); + return *this; + } + using iterator = std::vector<Selection>::iterator; iterator begin() { return m_selections.begin(); } iterator end() { return m_selections.end(); } @@ -148,6 +153,9 @@ private: size_t m_timestamp; }; +void update_insert(std::vector<Selection>& sels, ByteCoord begin, ByteCoord end, bool at_end); +void update_erase(std::vector<Selection>& sels, ByteCoord begin, ByteCoord end, bool at_end); + } #endif // selection_hh_INCLUDED |
