forked from microsoft/vcpkg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vcpkg] ImmutableSortedVector is actually Mutable via move.
Use fmap instead of construct/insert. Don't cache VS2015 instances since it is called once. Add ParagraphDataMap alias.
- Loading branch information
1 parent
bb865fb
commit b788c2b
Showing
11 changed files
with
90 additions
and
113 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include <algorithm> | ||
|
||
// Add more forwarding functions to the m_data std::vector as needed. | ||
namespace vcpkg | ||
{ | ||
template <class T> | ||
class SortedVector | ||
{ | ||
public: | ||
using size_type = typename std::vector<T>::size_type; | ||
using iterator = typename std::vector<T>::const_iterator; | ||
|
||
explicit SortedVector<T>(std::vector<T> v) : m_data(std::move(v)) | ||
{ | ||
if (!std::is_sorted(m_data.begin(), m_data.end())) | ||
{ | ||
std::sort(m_data.begin(), m_data.end()); | ||
} | ||
} | ||
template <class Compare> | ||
SortedVector<T>(std::vector<T> v, Compare comp) : m_data(std::move(v)) | ||
{ | ||
if (!std::is_sorted(m_data.cbegin(), m_data.cend(), comp)) | ||
{ | ||
std::sort(m_data.begin(), m_data.end(), comp); | ||
} | ||
} | ||
|
||
iterator begin() const | ||
{ | ||
return this->m_data.cbegin(); | ||
} | ||
|
||
iterator end() const | ||
{ | ||
return this->m_data.cend(); | ||
} | ||
|
||
bool empty() const | ||
{ | ||
return this->m_data.empty(); | ||
} | ||
|
||
size_type size() const | ||
{ | ||
return this->m_data.size(); | ||
} | ||
|
||
private: | ||
std::vector<T> m_data; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters