Commit 9900b2a0 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Cut presorted and unsorted tags

Summary: [Folly] Cut `presorted` and `unsorted` tags; the `presorted` tag has  ambiguous meaning and is replaced by either `sorted_unique` or `sorted_equivalent`.

Reviewed By: vitaut

Differential Revision: D15196179

fbshipit-source-id: a2cdaa06c7c5a55147db67a877b29c5944039e6d
parent f5a52d63
......@@ -235,48 +235,6 @@ constexpr sorted_unique_t sorted_unique;
struct sorted_equivalent_t {};
constexpr sorted_equivalent_t sorted_equivalent;
/**
* A generic tag type to indicate that some constructor or method accepts a
* presorted container.
*
* Example:
*
* void takes_numbers(std::vector<int> alist) {
* std::sort(alist.begin(), alist.end());
* takes_numbers(folly::presorted, alist);
* }
*
* void takes_numbers(folly::presorted_t, std::vector<int> alist) {
* assert(std::is_sorted(alist.begin(), alist.end())); // debug mode only
* for (i : alist) {
* // some behavior which is defined and safe only when alist is sorted ...
* }
* }
*/
struct presorted_t {};
constexpr presorted_t presorted{};
/**
* A generic tag type to indicate that some constructor or method accepts an
* unsorted container. Useful in contexts which might have some reason to assume
* a container to be sorted.
*
* Example:
*
* void takes_numbers(std::vector<int> alist) {
* takes_numbers(folly::unsorted, alist);
* }
*
* void takes_numbers(folly::unsorted_t, std::vector<int> alist) {
* std::sort(alist.begin(), alist.end());
* for (i : alist) {
* // some behavior which is defined and safe only when alist is sorted ...
* }
* }
*/
struct unsorted_t {};
constexpr unsorted_t unsorted{};
template <typename T>
struct transparent : T {
using is_transparent = void;
......
......@@ -210,13 +210,8 @@ bool is_sorted_unique(Container const& container, Compare const& comp) {
}
template <typename Container, typename Compare>
Container&& as_sorted(Container&& container, Compare const& comp) {
Container&& as_sorted_unique(Container&& container, Compare const& comp) {
std::sort(container.begin(), container.end(), comp);
return static_cast<Container&&>(container);
}
template <typename Container, typename Compare>
Container&& as_unique(Container&& container, Compare const& comp) {
container.erase(
std::unique(
container.begin(),
......@@ -227,11 +222,6 @@ Container&& as_unique(Container&& container, Compare const& comp) {
container.end());
return static_cast<Container&&>(container);
}
template <typename Container, typename Compare>
Container&& as_sorted_unique(Container&& container, Compare const& comp) {
return as_unique(as_sorted(static_cast<Container&&>(container), comp), comp);
}
} // namespace detail
//////////////////////////////////////////////////////////////////////
......@@ -349,15 +339,6 @@ class sorted_vector_set : detail::growth_policy_wrapper<GrowthPolicy> {
m_.cont_.swap(container);
}
sorted_vector_set(
presorted_t,
Container&& container,
const Compare& comp = Compare())
: sorted_vector_set(
sorted_unique,
detail::as_unique(std::move(container), value_compare(comp)),
comp) {}
sorted_vector_set& operator=(std::initializer_list<value_type> ilist) {
clear();
insert(ilist.begin(), ilist.end());
......@@ -772,15 +753,6 @@ class sorted_vector_map : detail::growth_policy_wrapper<GrowthPolicy> {
m_.cont_.swap(container);
}
sorted_vector_map(
presorted_t,
Container&& container,
const Compare& comp = Compare())
: sorted_vector_map(
sorted_unique,
detail::as_unique(std::move(container), value_compare(comp)),
comp) {}
sorted_vector_map& operator=(std::initializer_list<value_type> ilist) {
clear();
insert(ilist.begin(), ilist.end());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment