mirror of
https://github.com/BlackMATov/flat.hpp.git
synced 2025-12-13 17:48:14 +07:00
add insert sorted ranges optimization #23
This commit is contained in:
100
README.md
100
README.md
@@ -95,25 +95,53 @@ flat_set(const Compare& c, const Allocator& a);
|
|||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_set(InputIter first, InputIter last);
|
flat_set(InputIter first, InputIter last);
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_set(sorted_range_t, InputIter first, InputIter last);
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_set(sorted_unique_range_t, InputIter first, InputIter last);
|
||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_set(InputIter first, InputIter last, const Compare& c);
|
flat_set(InputIter first, InputIter last, const Compare& c);
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_set(sorted_range_t, InputIter first, InputIter last, const Compare& c);
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_set(sorted_unique_range_t, InputIter first, InputIter last, const Compare& c);
|
||||||
|
|
||||||
template < typename InputIter, typename Allocator >
|
template < typename InputIter, typename Allocator >
|
||||||
flat_set(InputIter first, InputIter last, const Allocator& a);
|
flat_set(InputIter first, InputIter last, const Allocator& a);
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_set(sorted_range_t, InputIter first, InputIter last, const Allocator& a);
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_set(sorted_unique_range_t, InputIter first, InputIter last, const Allocator& a);
|
||||||
|
|
||||||
template < typename InputIter, typename Allocator >
|
template < typename InputIter, typename Allocator >
|
||||||
flat_set(InputIter first, InputIter last, const Compare& c, const Allocator& a);
|
flat_set(InputIter first, InputIter last, const Compare& c, const Allocator& a);
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_set(sorted_range_t, InputIter first, InputIter last, const Compare& c, const Allocator& a);
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_set(sorted_unique_range_t, InputIter first, InputIter last, const Compare& c, const Allocator& a);
|
||||||
|
|
||||||
flat_set(std::initializer_list<value_type> ilist);
|
flat_set(std::initializer_list<value_type> ilist);
|
||||||
|
flat_set(sorted_range_t, std::initializer_list<value_type> ilist);
|
||||||
|
flat_set(sorted_unique_range_t, std::initializer_list<value_type> ilist);
|
||||||
|
|
||||||
flat_set(std::initializer_list<value_type> ilist, const Compare& c);
|
flat_set(std::initializer_list<value_type> ilist, const Compare& c);
|
||||||
|
flat_set(sorted_range_t, std::initializer_list<value_type> ilist, const Compare& c);
|
||||||
|
flat_set(sorted_unique_range_t, std::initializer_list<value_type> ilist, const Compare& c);
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_set(std::initializer_list<value_type> ilist, const Allocator& a);
|
flat_set(std::initializer_list<value_type> ilist, const Allocator& a);
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_set(sorted_range_t, std::initializer_list<value_type> ilist, const Allocator& a);
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_set(sorted_unique_range_t, std::initializer_list<value_type> ilist, const Allocator& a);
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_set(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);
|
flat_set(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_set(sorted_range_t, std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_set(sorted_unique_range_t, std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_set(flat_set&& other, const Allocator& a);
|
flat_set(flat_set&& other, const Allocator& a);
|
||||||
@@ -172,7 +200,11 @@ iterator insert(const_iterator hint, const value_type& value);
|
|||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
void insert(InputIter first, InputIter last);
|
void insert(InputIter first, InputIter last);
|
||||||
|
template < typename InputIter >
|
||||||
|
void insert(sorted_range_t, InputIter first, InputIter last);
|
||||||
|
|
||||||
void insert(std::initializer_list<value_type> ilist);
|
void insert(std::initializer_list<value_type> ilist);
|
||||||
|
void insert(sorted_range_t, std::initializer_list<value_type> ilist);
|
||||||
|
|
||||||
template < typename... Args >
|
template < typename... Args >
|
||||||
std::pair<iterator, bool> emplace(Args&&... args);
|
std::pair<iterator, bool> emplace(Args&&... args);
|
||||||
@@ -329,25 +361,53 @@ flat_map(const Compare& c, const Allocator& a);
|
|||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_map(InputIter first, InputIter last);
|
flat_map(InputIter first, InputIter last);
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_map(sorted_range_t, InputIter first, InputIter last);
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_map(sorted_unique_range_t, InputIter first, InputIter last);
|
||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_map(InputIter first, InputIter last, const Compare& c);
|
flat_map(InputIter first, InputIter last, const Compare& c);
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_map(sorted_range_t, InputIter first, InputIter last, const Compare& c);
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_map(sorted_unique_range_t, InputIter first, InputIter last, const Compare& c);
|
||||||
|
|
||||||
template < typename InputIter, typename Allocator >
|
template < typename InputIter, typename Allocator >
|
||||||
flat_map(InputIter first, InputIter last, const Allocator& a);
|
flat_map(InputIter first, InputIter last, const Allocator& a);
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_map(sorted_range_t, InputIter first, InputIter last, const Allocator& a);
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_map(sorted_unique_range_t, InputIter first, InputIter last, const Allocator& a);
|
||||||
|
|
||||||
template < typename InputIter , typename Allocator >
|
template < typename InputIter , typename Allocator >
|
||||||
flat_map(InputIter first, InputIter last, const Compare& c, const Allocator& a);
|
flat_map(InputIter first, InputIter last, const Compare& c, const Allocator& a);
|
||||||
|
template < typename InputIter , typename Allocator >
|
||||||
|
flat_map(sorted_range_t, InputIter first, InputIter last, const Compare& c, const Allocator& a);
|
||||||
|
template < typename InputIter , typename Allocator >
|
||||||
|
flat_map(sorted_unique_range_t, InputIter first, InputIter last, const Compare& c, const Allocator& a);
|
||||||
|
|
||||||
flat_map(std::initializer_list<value_type> ilist);
|
flat_map(std::initializer_list<value_type> ilist);
|
||||||
|
flat_map(sorted_range_t, std::initializer_list<value_type> ilist);
|
||||||
|
flat_map(sorted_unique_range_t, std::initializer_list<value_type> ilist);
|
||||||
|
|
||||||
flat_map(std::initializer_list<value_type> ilist, const Compare& c);
|
flat_map(std::initializer_list<value_type> ilist, const Compare& c);
|
||||||
|
flat_map(sorted_range_t, std::initializer_list<value_type> ilist, const Compare& c);
|
||||||
|
flat_map(sorted_unique_range_t, std::initializer_list<value_type> ilist, const Compare& c);
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_map(std::initializer_list<value_type> ilist, const Allocator& a);
|
flat_map(std::initializer_list<value_type> ilist, const Allocator& a);
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_map(sorted_range_t, std::initializer_list<value_type> ilist, const Allocator& a);
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_map(sorted_unique_range_t, std::initializer_list<value_type> ilist, const Allocator& a);
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_map(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);
|
flat_map(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_map(sorted_range_t, std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_map(sorted_unique_range_t, std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_map(flat_map&& other, const Allocator& a);
|
flat_map(flat_map&& other, const Allocator& a);
|
||||||
@@ -419,7 +479,11 @@ iterator insert(const_iterator hint, const value_type& value);
|
|||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
void insert(InputIter first, InputIter last);
|
void insert(InputIter first, InputIter last);
|
||||||
|
template < typename InputIter >
|
||||||
|
void insert(sorted_range_t, InputIter first, InputIter last);
|
||||||
|
|
||||||
void insert(std::initializer_list<value_type> ilist);
|
void insert(std::initializer_list<value_type> ilist);
|
||||||
|
void insert(sorted_range_t, std::initializer_list<value_type> ilist);
|
||||||
|
|
||||||
template < typename... Args >
|
template < typename... Args >
|
||||||
std::pair<iterator, bool> emplace(Args&&... args);
|
std::pair<iterator, bool> emplace(Args&&... args);
|
||||||
@@ -576,25 +640,39 @@ flat_multiset(const Compare& c, const Allocator& a);
|
|||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_multiset(InputIter first, InputIter last);
|
flat_multiset(InputIter first, InputIter last);
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_multiset(sorted_range_t, InputIter first, InputIter last);
|
||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_multiset(InputIter first, InputIter last, const Compare& c);
|
flat_multiset(InputIter first, InputIter last, const Compare& c);
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_multiset(sorted_range_t, InputIter first, InputIter last, const Compare& c);
|
||||||
|
|
||||||
template < typename InputIter, typename Allocator >
|
template < typename InputIter, typename Allocator >
|
||||||
flat_multiset(InputIter first, InputIter last, const Allocator& a);
|
flat_multiset(InputIter first, InputIter last, const Allocator& a);
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_multiset(sorted_range_t, InputIter first, InputIter last, const Allocator& a);
|
||||||
|
|
||||||
template < typename InputIter, typename Allocator >
|
template < typename InputIter, typename Allocator >
|
||||||
flat_multiset(InputIter first, InputIter last, const Compare& c, const Allocator& a);
|
flat_multiset(InputIter first, InputIter last, const Compare& c, const Allocator& a);
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_multiset(sorted_range_t, InputIter first, InputIter last, const Compare& c, const Allocator& a);
|
||||||
|
|
||||||
flat_multiset(std::initializer_list<value_type> ilist);
|
flat_multiset(std::initializer_list<value_type> ilist);
|
||||||
|
flat_multiset(sorted_range_t, std::initializer_list<value_type> ilist);
|
||||||
|
|
||||||
flat_multiset(std::initializer_list<value_type> ilist, const Compare& c);
|
flat_multiset(std::initializer_list<value_type> ilist, const Compare& c);
|
||||||
|
flat_multiset(sorted_range_t, std::initializer_list<value_type> ilist, const Compare& c);
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_multiset(std::initializer_list<value_type> ilist, const Allocator& a);
|
flat_multiset(std::initializer_list<value_type> ilist, const Allocator& a);
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_multiset(sorted_range_t, std::initializer_list<value_type> ilist, const Allocator& a);
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_multiset(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);
|
flat_multiset(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_multiset(sorted_range_t, std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_multiset(flat_multiset&& other, const Allocator& a);
|
flat_multiset(flat_multiset&& other, const Allocator& a);
|
||||||
@@ -653,7 +731,11 @@ iterator insert(const_iterator hint, const value_type& value);
|
|||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
void insert(InputIter first, InputIter last);
|
void insert(InputIter first, InputIter last);
|
||||||
|
template < typename InputIter >
|
||||||
|
void insert(sorted_range_t, InputIter first, InputIter last);
|
||||||
|
|
||||||
void insert(std::initializer_list<value_type> ilist);
|
void insert(std::initializer_list<value_type> ilist);
|
||||||
|
void insert(sorted_range_t, std::initializer_list<value_type> ilist);
|
||||||
|
|
||||||
template < typename... Args >
|
template < typename... Args >
|
||||||
iterator emplace(Args&&... args);
|
iterator emplace(Args&&... args);
|
||||||
@@ -810,25 +892,39 @@ flat_multimap(const Compare& c, const Allocator& a);
|
|||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_multimap(InputIter first, InputIter last);
|
flat_multimap(InputIter first, InputIter last);
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_multimap(sorted_range_t, InputIter first, InputIter last);
|
||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_multimap(InputIter first, InputIter last, const Compare& c);
|
flat_multimap(InputIter first, InputIter last, const Compare& c);
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_multimap(sorted_range_t, InputIter first, InputIter last, const Compare& c);
|
||||||
|
|
||||||
template < typename InputIter, typename Allocator >
|
template < typename InputIter, typename Allocator >
|
||||||
flat_multimap(InputIter first, InputIter last, const Allocator& a);
|
flat_multimap(InputIter first, InputIter last, const Allocator& a);
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_multimap(sorted_range_t, InputIter first, InputIter last, const Allocator& a);
|
||||||
|
|
||||||
template < typename InputIter , typename Allocator >
|
template < typename InputIter , typename Allocator >
|
||||||
flat_multimap(InputIter first, InputIter last, const Compare& c, const Allocator& a);
|
flat_multimap(InputIter first, InputIter last, const Compare& c, const Allocator& a);
|
||||||
|
template < typename InputIter , typename Allocator >
|
||||||
|
flat_multimap(sorted_range_t, InputIter first, InputIter last, const Compare& c, const Allocator& a);
|
||||||
|
|
||||||
flat_multimap(std::initializer_list<value_type> ilist);
|
flat_multimap(std::initializer_list<value_type> ilist);
|
||||||
|
flat_multimap(sorted_range_t, std::initializer_list<value_type> ilist);
|
||||||
|
|
||||||
flat_multimap(std::initializer_list<value_type> ilist, const Compare& c);
|
flat_multimap(std::initializer_list<value_type> ilist, const Compare& c);
|
||||||
|
flat_multimap(sorted_range_t, std::initializer_list<value_type> ilist, const Compare& c);
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_multimap(std::initializer_list<value_type> ilist, const Allocator& a);
|
flat_multimap(std::initializer_list<value_type> ilist, const Allocator& a);
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_multimap(sorted_range_t, std::initializer_list<value_type> ilist, const Allocator& a);
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_multimap(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);
|
flat_multimap(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_multimap(sorted_range_t, std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_multimap(flat_multimap&& other, const Allocator& a);
|
flat_multimap(flat_multimap&& other, const Allocator& a);
|
||||||
@@ -900,7 +996,11 @@ iterator insert(const_iterator hint, const value_type& value);
|
|||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
void insert(InputIter first, InputIter last);
|
void insert(InputIter first, InputIter last);
|
||||||
|
template < typename InputIter >
|
||||||
|
void insert(sorted_range_t, InputIter first, InputIter last);
|
||||||
|
|
||||||
void insert(std::initializer_list<value_type> ilist);
|
void insert(std::initializer_list<value_type> ilist);
|
||||||
|
void insert(sorted_range_t, std::initializer_list<value_type> ilist);
|
||||||
|
|
||||||
template < typename... Args >
|
template < typename... Args >
|
||||||
iterator emplace(Args&&... args);
|
iterator emplace(Args&&... args);
|
||||||
|
|||||||
26
headers/flat.hpp/detail/is_sorted.hpp
Normal file
26
headers/flat.hpp/detail/is_sorted.hpp
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "https://github.com/blackmatov/flat.hpp"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace flat_hpp::detail
|
||||||
|
{
|
||||||
|
template < typename Iter, typename Compare >
|
||||||
|
bool is_sorted(Iter first, Iter last, Compare comp) {
|
||||||
|
(void)first;
|
||||||
|
(void)last;
|
||||||
|
(void)comp;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename Iter, typename Compare >
|
||||||
|
bool is_sorted_unique(Iter first, Iter last, Compare comp) {
|
||||||
|
(void)first;
|
||||||
|
(void)last;
|
||||||
|
(void)comp;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,12 +14,19 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
|
||||||
|
#include "detail/is_sorted.hpp"
|
||||||
#include "detail/eq_compare.hpp"
|
#include "detail/eq_compare.hpp"
|
||||||
#include "detail/pair_compare.hpp"
|
#include "detail/pair_compare.hpp"
|
||||||
#include "detail/is_transparent.hpp"
|
#include "detail/is_transparent.hpp"
|
||||||
|
|
||||||
namespace flat_hpp
|
namespace flat_hpp
|
||||||
{
|
{
|
||||||
|
struct sorted_range_t {};
|
||||||
|
inline constexpr sorted_range_t sorted_range = sorted_range_t();
|
||||||
|
|
||||||
|
struct sorted_unique_range_t : public sorted_range_t {};
|
||||||
|
inline constexpr sorted_unique_range_t sorted_unique_range = sorted_unique_range_t();
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
, typename Compare = std::less<Key>
|
, typename Compare = std::less<Key>
|
||||||
, typename Container = std::vector<Key> >
|
, typename Container = std::vector<Key> >
|
||||||
|
|||||||
@@ -75,18 +75,52 @@ namespace flat_hpp
|
|||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_map(sorted_range_t, InputIter first, InputIter last) {
|
||||||
|
insert(sorted_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_map(sorted_unique_range_t, InputIter first, InputIter last) {
|
||||||
|
insert(sorted_unique_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_map(InputIter first, InputIter last, const Compare& c)
|
flat_map(InputIter first, InputIter last, const Compare& c)
|
||||||
: base_type(c) {
|
: base_type(c) {
|
||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_map(sorted_range_t, InputIter first, InputIter last, const Compare& c)
|
||||||
|
: base_type(c) {
|
||||||
|
insert(sorted_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_map(sorted_unique_range_t, InputIter first, InputIter last, const Compare& c)
|
||||||
|
: base_type(c) {
|
||||||
|
insert(sorted_unique_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename InputIter, typename Allocator >
|
template < typename InputIter, typename Allocator >
|
||||||
flat_map(InputIter first, InputIter last, const Allocator& a)
|
flat_map(InputIter first, InputIter last, const Allocator& a)
|
||||||
: data_(a) {
|
: data_(a) {
|
||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_map(sorted_range_t, InputIter first, InputIter last, const Allocator& a)
|
||||||
|
: data_(a) {
|
||||||
|
insert(sorted_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_map(sorted_unique_range_t, InputIter first, InputIter last, const Allocator& a)
|
||||||
|
: data_(a) {
|
||||||
|
insert(sorted_unique_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename InputIter , typename Allocator >
|
template < typename InputIter , typename Allocator >
|
||||||
flat_map(InputIter first, InputIter last, const Compare& c, const Allocator& a)
|
flat_map(InputIter first, InputIter last, const Compare& c, const Allocator& a)
|
||||||
: base_type(c)
|
: base_type(c)
|
||||||
@@ -94,21 +128,65 @@ namespace flat_hpp
|
|||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter , typename Allocator >
|
||||||
|
flat_map(sorted_range_t, InputIter first, InputIter last, const Compare& c, const Allocator& a)
|
||||||
|
: base_type(c)
|
||||||
|
, data_(a) {
|
||||||
|
insert(sorted_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename InputIter , typename Allocator >
|
||||||
|
flat_map(sorted_unique_range_t, InputIter first, InputIter last, const Compare& c, const Allocator& a)
|
||||||
|
: base_type(c)
|
||||||
|
, data_(a) {
|
||||||
|
insert(sorted_unique_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
flat_map(std::initializer_list<value_type> ilist) {
|
flat_map(std::initializer_list<value_type> ilist) {
|
||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flat_map(sorted_range_t, std::initializer_list<value_type> ilist) {
|
||||||
|
insert(sorted_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
|
flat_map(sorted_unique_range_t, std::initializer_list<value_type> ilist) {
|
||||||
|
insert(sorted_unique_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
flat_map(std::initializer_list<value_type> ilist, const Compare& c)
|
flat_map(std::initializer_list<value_type> ilist, const Compare& c)
|
||||||
: base_type(c) {
|
: base_type(c) {
|
||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flat_map(sorted_range_t, std::initializer_list<value_type> ilist, const Compare& c)
|
||||||
|
: base_type(c) {
|
||||||
|
insert(sorted_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
|
flat_map(sorted_unique_range_t, std::initializer_list<value_type> ilist, const Compare& c)
|
||||||
|
: base_type(c) {
|
||||||
|
insert(sorted_unique_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_map(std::initializer_list<value_type> ilist, const Allocator& a)
|
flat_map(std::initializer_list<value_type> ilist, const Allocator& a)
|
||||||
: data_(a) {
|
: data_(a) {
|
||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_map(sorted_range_t, std::initializer_list<value_type> ilist, const Allocator& a)
|
||||||
|
: data_(a) {
|
||||||
|
insert(sorted_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_map(sorted_unique_range_t, std::initializer_list<value_type> ilist, const Allocator& a)
|
||||||
|
: data_(a) {
|
||||||
|
insert(sorted_unique_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_map(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a)
|
flat_map(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a)
|
||||||
: base_type(c)
|
: base_type(c)
|
||||||
@@ -116,6 +194,20 @@ namespace flat_hpp
|
|||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_map(sorted_range_t, std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a)
|
||||||
|
: base_type(c)
|
||||||
|
, data_(a) {
|
||||||
|
insert(sorted_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_map(sorted_unique_range_t, std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a)
|
||||||
|
: base_type(c)
|
||||||
|
, data_(a) {
|
||||||
|
insert(sorted_unique_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_map(flat_map&& other, const Allocator& a)
|
flat_map(flat_map&& other, const Allocator& a)
|
||||||
: base_type(static_cast<base_type&&>(other))
|
: base_type(static_cast<base_type&&>(other))
|
||||||
@@ -318,10 +410,25 @@ namespace flat_hpp
|
|||||||
data_.end());
|
data_.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter >
|
||||||
|
void insert(sorted_range_t, InputIter first, InputIter last) {
|
||||||
|
assert(detail::is_sorted(first, last, value_comp()));
|
||||||
|
const auto mid_iter = data_.insert(data_.end(), first, last);
|
||||||
|
std::inplace_merge(data_.begin(), mid_iter, data_.end());
|
||||||
|
data_.erase(
|
||||||
|
std::unique(data_.begin(), data_.end(),
|
||||||
|
detail::eq_compare<value_compare>(value_comp())),
|
||||||
|
data_.end());
|
||||||
|
}
|
||||||
|
|
||||||
void insert(std::initializer_list<value_type> ilist) {
|
void insert(std::initializer_list<value_type> ilist) {
|
||||||
insert(ilist.begin(), ilist.end());
|
insert(ilist.begin(), ilist.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void insert(sorted_range_t, std::initializer_list<value_type> ilist) {
|
||||||
|
insert(sorted_range, ilist.begin(), ilist.end());
|
||||||
|
}
|
||||||
|
|
||||||
template < typename... Args >
|
template < typename... Args >
|
||||||
std::pair<iterator, bool> emplace(Args&&... args) {
|
std::pair<iterator, bool> emplace(Args&&... args) {
|
||||||
return insert(value_type(std::forward<Args>(args)...));
|
return insert(value_type(std::forward<Args>(args)...));
|
||||||
|
|||||||
@@ -75,18 +75,35 @@ namespace flat_hpp
|
|||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_multimap(sorted_range_t, InputIter first, InputIter last) {
|
||||||
|
insert(sorted_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_multimap(InputIter first, InputIter last, const Compare& c)
|
flat_multimap(InputIter first, InputIter last, const Compare& c)
|
||||||
: base_type(c) {
|
: base_type(c) {
|
||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_multimap(sorted_range_t, InputIter first, InputIter last, const Compare& c)
|
||||||
|
: base_type(c) {
|
||||||
|
insert(sorted_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename InputIter, typename Allocator >
|
template < typename InputIter, typename Allocator >
|
||||||
flat_multimap(InputIter first, InputIter last, const Allocator& a)
|
flat_multimap(InputIter first, InputIter last, const Allocator& a)
|
||||||
: data_(a) {
|
: data_(a) {
|
||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_multimap(sorted_range_t, InputIter first, InputIter last, const Allocator& a)
|
||||||
|
: data_(a) {
|
||||||
|
insert(sorted_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename InputIter , typename Allocator >
|
template < typename InputIter , typename Allocator >
|
||||||
flat_multimap(InputIter first, InputIter last, const Compare& c, const Allocator& a)
|
flat_multimap(InputIter first, InputIter last, const Compare& c, const Allocator& a)
|
||||||
: base_type(c)
|
: base_type(c)
|
||||||
@@ -94,21 +111,43 @@ namespace flat_hpp
|
|||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter , typename Allocator >
|
||||||
|
flat_multimap(sorted_range_t, InputIter first, InputIter last, const Compare& c, const Allocator& a)
|
||||||
|
: base_type(c)
|
||||||
|
, data_(a) {
|
||||||
|
insert(sorted_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
flat_multimap(std::initializer_list<value_type> ilist) {
|
flat_multimap(std::initializer_list<value_type> ilist) {
|
||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flat_multimap(sorted_range_t, std::initializer_list<value_type> ilist) {
|
||||||
|
insert(sorted_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
flat_multimap(std::initializer_list<value_type> ilist, const Compare& c)
|
flat_multimap(std::initializer_list<value_type> ilist, const Compare& c)
|
||||||
: base_type(c) {
|
: base_type(c) {
|
||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flat_multimap(sorted_range_t, std::initializer_list<value_type> ilist, const Compare& c)
|
||||||
|
: base_type(c) {
|
||||||
|
insert(sorted_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_multimap(std::initializer_list<value_type> ilist, const Allocator& a)
|
flat_multimap(std::initializer_list<value_type> ilist, const Allocator& a)
|
||||||
: data_(a) {
|
: data_(a) {
|
||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_multimap(sorted_range_t, std::initializer_list<value_type> ilist, const Allocator& a)
|
||||||
|
: data_(a) {
|
||||||
|
insert(sorted_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_multimap(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a)
|
flat_multimap(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a)
|
||||||
: base_type(c)
|
: base_type(c)
|
||||||
@@ -116,6 +155,13 @@ namespace flat_hpp
|
|||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_multimap(sorted_range_t, std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a)
|
||||||
|
: base_type(c)
|
||||||
|
, data_(a) {
|
||||||
|
insert(sorted_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_multimap(flat_multimap&& other, const Allocator& a)
|
flat_multimap(flat_multimap&& other, const Allocator& a)
|
||||||
: base_type(static_cast<base_type&&>(other))
|
: base_type(static_cast<base_type&&>(other))
|
||||||
@@ -310,10 +356,21 @@ namespace flat_hpp
|
|||||||
std::inplace_merge(data_.begin(), mid_iter, data_.end());
|
std::inplace_merge(data_.begin(), mid_iter, data_.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter >
|
||||||
|
void insert(sorted_range_t, InputIter first, InputIter last) {
|
||||||
|
assert(detail::is_sorted(first, last, value_comp()));
|
||||||
|
const auto mid_iter = data_.insert(data_.end(), first, last);
|
||||||
|
std::inplace_merge(data_.begin(), mid_iter, data_.end());
|
||||||
|
}
|
||||||
|
|
||||||
void insert(std::initializer_list<value_type> ilist) {
|
void insert(std::initializer_list<value_type> ilist) {
|
||||||
insert(ilist.begin(), ilist.end());
|
insert(ilist.begin(), ilist.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void insert(sorted_range_t, std::initializer_list<value_type> ilist) {
|
||||||
|
insert(sorted_range, ilist.begin(), ilist.end());
|
||||||
|
}
|
||||||
|
|
||||||
template < typename... Args >
|
template < typename... Args >
|
||||||
iterator emplace(Args&&... args) {
|
iterator emplace(Args&&... args) {
|
||||||
return insert(value_type(std::forward<Args>(args)...));
|
return insert(value_type(std::forward<Args>(args)...));
|
||||||
|
|||||||
@@ -57,18 +57,35 @@ namespace flat_hpp
|
|||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_multiset(sorted_range_t, InputIter first, InputIter last) {
|
||||||
|
insert(sorted_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_multiset(InputIter first, InputIter last, const Compare& c)
|
flat_multiset(InputIter first, InputIter last, const Compare& c)
|
||||||
: base_type(c) {
|
: base_type(c) {
|
||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_multiset(sorted_range_t, InputIter first, InputIter last, const Compare& c)
|
||||||
|
: base_type(c) {
|
||||||
|
insert(sorted_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename InputIter, typename Allocator >
|
template < typename InputIter, typename Allocator >
|
||||||
flat_multiset(InputIter first, InputIter last, const Allocator& a)
|
flat_multiset(InputIter first, InputIter last, const Allocator& a)
|
||||||
: data_(a) {
|
: data_(a) {
|
||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_multiset(sorted_range_t, InputIter first, InputIter last, const Allocator& a)
|
||||||
|
: data_(a) {
|
||||||
|
insert(sorted_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename InputIter, typename Allocator >
|
template < typename InputIter, typename Allocator >
|
||||||
flat_multiset(InputIter first, InputIter last, const Compare& c, const Allocator& a)
|
flat_multiset(InputIter first, InputIter last, const Compare& c, const Allocator& a)
|
||||||
: base_type(c)
|
: base_type(c)
|
||||||
@@ -76,21 +93,43 @@ namespace flat_hpp
|
|||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_multiset(sorted_range_t, InputIter first, InputIter last, const Compare& c, const Allocator& a)
|
||||||
|
: base_type(c)
|
||||||
|
, data_(a) {
|
||||||
|
insert(sorted_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
flat_multiset(std::initializer_list<value_type> ilist) {
|
flat_multiset(std::initializer_list<value_type> ilist) {
|
||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flat_multiset(sorted_range_t, std::initializer_list<value_type> ilist) {
|
||||||
|
insert(sorted_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
flat_multiset(std::initializer_list<value_type> ilist, const Compare& c)
|
flat_multiset(std::initializer_list<value_type> ilist, const Compare& c)
|
||||||
: base_type(c) {
|
: base_type(c) {
|
||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flat_multiset(sorted_range_t, std::initializer_list<value_type> ilist, const Compare& c)
|
||||||
|
: base_type(c) {
|
||||||
|
insert(sorted_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_multiset(std::initializer_list<value_type> ilist, const Allocator& a)
|
flat_multiset(std::initializer_list<value_type> ilist, const Allocator& a)
|
||||||
: data_(a) {
|
: data_(a) {
|
||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_multiset(sorted_range_t, std::initializer_list<value_type> ilist, const Allocator& a)
|
||||||
|
: data_(a) {
|
||||||
|
insert(sorted_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_multiset(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a)
|
flat_multiset(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a)
|
||||||
: base_type(c)
|
: base_type(c)
|
||||||
@@ -98,6 +137,13 @@ namespace flat_hpp
|
|||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_multiset(sorted_range_t, std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a)
|
||||||
|
: base_type(c)
|
||||||
|
, data_(a) {
|
||||||
|
insert(sorted_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_multiset(flat_multiset&& other, const Allocator& a)
|
flat_multiset(flat_multiset&& other, const Allocator& a)
|
||||||
: base_type(static_cast<base_type&&>(other))
|
: base_type(static_cast<base_type&&>(other))
|
||||||
@@ -238,10 +284,21 @@ namespace flat_hpp
|
|||||||
std::inplace_merge(data_.begin(), mid_iter, data_.end());
|
std::inplace_merge(data_.begin(), mid_iter, data_.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter >
|
||||||
|
void insert(sorted_range_t, InputIter first, InputIter last) {
|
||||||
|
assert(detail::is_sorted(first, last, value_comp()));
|
||||||
|
const auto mid_iter = data_.insert(data_.end(), first, last);
|
||||||
|
std::inplace_merge(data_.begin(), mid_iter, data_.end());
|
||||||
|
}
|
||||||
|
|
||||||
void insert(std::initializer_list<value_type> ilist) {
|
void insert(std::initializer_list<value_type> ilist) {
|
||||||
insert(ilist.begin(), ilist.end());
|
insert(ilist.begin(), ilist.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void insert(sorted_range_t, std::initializer_list<value_type> ilist) {
|
||||||
|
insert(sorted_range, ilist.begin(), ilist.end());
|
||||||
|
}
|
||||||
|
|
||||||
template < typename... Args >
|
template < typename... Args >
|
||||||
iterator emplace(Args&&... args) {
|
iterator emplace(Args&&... args) {
|
||||||
return insert(value_type(std::forward<Args>(args)...));
|
return insert(value_type(std::forward<Args>(args)...));
|
||||||
|
|||||||
@@ -57,18 +57,52 @@ namespace flat_hpp
|
|||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_set(sorted_range_t, InputIter first, InputIter last) {
|
||||||
|
insert(sorted_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_set(sorted_unique_range_t, InputIter first, InputIter last) {
|
||||||
|
insert(sorted_unique_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename InputIter >
|
template < typename InputIter >
|
||||||
flat_set(InputIter first, InputIter last, const Compare& c)
|
flat_set(InputIter first, InputIter last, const Compare& c)
|
||||||
: base_type(c) {
|
: base_type(c) {
|
||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_set(sorted_range_t, InputIter first, InputIter last, const Compare& c)
|
||||||
|
: base_type(c) {
|
||||||
|
insert(sorted_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename InputIter >
|
||||||
|
flat_set(sorted_unique_range_t, InputIter first, InputIter last, const Compare& c)
|
||||||
|
: base_type(c) {
|
||||||
|
insert(sorted_unique_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename InputIter, typename Allocator >
|
template < typename InputIter, typename Allocator >
|
||||||
flat_set(InputIter first, InputIter last, const Allocator& a)
|
flat_set(InputIter first, InputIter last, const Allocator& a)
|
||||||
: data_(a) {
|
: data_(a) {
|
||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_set(sorted_range_t, InputIter first, InputIter last, const Allocator& a)
|
||||||
|
: data_(a) {
|
||||||
|
insert(sorted_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_set(sorted_unique_range_t, InputIter first, InputIter last, const Allocator& a)
|
||||||
|
: data_(a) {
|
||||||
|
insert(sorted_unique_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename InputIter, typename Allocator >
|
template < typename InputIter, typename Allocator >
|
||||||
flat_set(InputIter first, InputIter last, const Compare& c, const Allocator& a)
|
flat_set(InputIter first, InputIter last, const Compare& c, const Allocator& a)
|
||||||
: base_type(c)
|
: base_type(c)
|
||||||
@@ -76,21 +110,65 @@ namespace flat_hpp
|
|||||||
insert(first, last);
|
insert(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_set(sorted_range_t, InputIter first, InputIter last, const Compare& c, const Allocator& a)
|
||||||
|
: base_type(c)
|
||||||
|
, data_(a) {
|
||||||
|
insert(sorted_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename InputIter, typename Allocator >
|
||||||
|
flat_set(sorted_unique_range_t, InputIter first, InputIter last, const Compare& c, const Allocator& a)
|
||||||
|
: base_type(c)
|
||||||
|
, data_(a) {
|
||||||
|
insert(sorted_unique_range, first, last);
|
||||||
|
}
|
||||||
|
|
||||||
flat_set(std::initializer_list<value_type> ilist) {
|
flat_set(std::initializer_list<value_type> ilist) {
|
||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flat_set(sorted_range_t, std::initializer_list<value_type> ilist) {
|
||||||
|
insert(sorted_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
|
flat_set(sorted_unique_range_t, std::initializer_list<value_type> ilist) {
|
||||||
|
insert(sorted_unique_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
flat_set(std::initializer_list<value_type> ilist, const Compare& c)
|
flat_set(std::initializer_list<value_type> ilist, const Compare& c)
|
||||||
: base_type(c) {
|
: base_type(c) {
|
||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flat_set(sorted_range_t, std::initializer_list<value_type> ilist, const Compare& c)
|
||||||
|
: base_type(c) {
|
||||||
|
insert(sorted_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
|
flat_set(sorted_unique_range_t, std::initializer_list<value_type> ilist, const Compare& c)
|
||||||
|
: base_type(c) {
|
||||||
|
insert(sorted_unique_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_set(std::initializer_list<value_type> ilist, const Allocator& a)
|
flat_set(std::initializer_list<value_type> ilist, const Allocator& a)
|
||||||
: data_(a) {
|
: data_(a) {
|
||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_set(sorted_range_t, std::initializer_list<value_type> ilist, const Allocator& a)
|
||||||
|
: data_(a) {
|
||||||
|
insert(sorted_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_set(sorted_unique_range_t, std::initializer_list<value_type> ilist, const Allocator& a)
|
||||||
|
: data_(a) {
|
||||||
|
insert(sorted_unique_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_set(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a)
|
flat_set(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a)
|
||||||
: base_type(c)
|
: base_type(c)
|
||||||
@@ -98,6 +176,20 @@ namespace flat_hpp
|
|||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_set(sorted_range_t, std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a)
|
||||||
|
: base_type(c)
|
||||||
|
, data_(a) {
|
||||||
|
insert(sorted_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename Allocator >
|
||||||
|
flat_set(sorted_unique_range_t, std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a)
|
||||||
|
: base_type(c)
|
||||||
|
, data_(a) {
|
||||||
|
insert(sorted_unique_range, ilist);
|
||||||
|
}
|
||||||
|
|
||||||
template < typename Allocator >
|
template < typename Allocator >
|
||||||
flat_set(flat_set&& other, const Allocator& a)
|
flat_set(flat_set&& other, const Allocator& a)
|
||||||
: base_type(static_cast<base_type&&>(other))
|
: base_type(static_cast<base_type&&>(other))
|
||||||
@@ -246,10 +338,25 @@ namespace flat_hpp
|
|||||||
data_.end());
|
data_.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename InputIter >
|
||||||
|
void insert(sorted_range_t, InputIter first, InputIter last) {
|
||||||
|
assert(detail::is_sorted(first, last, value_comp()));
|
||||||
|
const auto mid_iter = data_.insert(data_.end(), first, last);
|
||||||
|
std::inplace_merge(data_.begin(), mid_iter, data_.end());
|
||||||
|
data_.erase(
|
||||||
|
std::unique(data_.begin(), data_.end(),
|
||||||
|
detail::eq_compare<value_compare>(value_comp())),
|
||||||
|
data_.end());
|
||||||
|
}
|
||||||
|
|
||||||
void insert(std::initializer_list<value_type> ilist) {
|
void insert(std::initializer_list<value_type> ilist) {
|
||||||
insert(ilist.begin(), ilist.end());
|
insert(ilist.begin(), ilist.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void insert(sorted_range_t, std::initializer_list<value_type> ilist) {
|
||||||
|
insert(sorted_range, ilist.begin(), ilist.end());
|
||||||
|
}
|
||||||
|
|
||||||
template < typename... Args >
|
template < typename... Args >
|
||||||
std::pair<iterator, bool> emplace(Args&&... args) {
|
std::pair<iterator, bool> emplace(Args&&... args) {
|
||||||
return insert(value_type(std::forward<Args>(args)...));
|
return insert(value_type(std::forward<Args>(args)...));
|
||||||
|
|||||||
@@ -350,6 +350,16 @@ TEST_CASE("flat_map") {
|
|||||||
s0.insert({{9,3},{7,5},{3,9},{5,3},{5,3}});
|
s0.insert({{9,3},{7,5},{3,9},{5,3},{5,3}});
|
||||||
REQUIRE(s0 == map_t{{2,4},{3,9},{4,6},{5,3},{6,2},{7,5},{9,3}});
|
REQUIRE(s0 == map_t{{2,4},{3,9},{4,6},{5,3},{6,2},{7,5},{9,3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
map_t s0;
|
||||||
|
s0.insert(sorted_unique_range, {{1,3},{2,2},{3,1}});
|
||||||
|
REQUIRE(s0 == map_t{{1,3},{2,2},{3,1}});
|
||||||
|
|
||||||
|
map_t s1;
|
||||||
|
s1.insert(sorted_range, {{1,3},{2,2},{2,2},{3,1}});
|
||||||
|
REQUIRE(s1 == map_t{{1,3},{2,2},{3,1}});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SECTION("erasers") {
|
SECTION("erasers") {
|
||||||
using map_t = flat_map<int, unsigned>;
|
using map_t = flat_map<int, unsigned>;
|
||||||
|
|||||||
@@ -350,6 +350,16 @@ TEST_CASE("flat_multimap") {
|
|||||||
s0.insert({{9,3},{7,5},{3,9},{5,3},{5,3}});
|
s0.insert({{9,3},{7,5},{3,9},{5,3},{5,3}});
|
||||||
REQUIRE(s0 == map_t{{2,4},{3,9},{4,6},{4,2},{5,3},{5,3},{6,2},{7,5},{9,3}});
|
REQUIRE(s0 == map_t{{2,4},{3,9},{4,6},{4,2},{5,3},{5,3},{6,2},{7,5},{9,3}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
map_t s0;
|
||||||
|
s0.insert(sorted_unique_range, {{1,3},{2,2},{3,1}});
|
||||||
|
REQUIRE(s0 == map_t{{1,3},{2,2},{3,1}});
|
||||||
|
|
||||||
|
map_t s1;
|
||||||
|
s1.insert(sorted_range, {{1,3},{2,2},{2,2},{3,1}});
|
||||||
|
REQUIRE(s1 == map_t{{1,3},{2,2},{2,2},{3,1}});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SECTION("erasers") {
|
SECTION("erasers") {
|
||||||
using map_t = flat_multimap<int, unsigned>;
|
using map_t = flat_multimap<int, unsigned>;
|
||||||
|
|||||||
@@ -326,6 +326,16 @@ TEST_CASE("flat_multiset") {
|
|||||||
s0.insert({9,7,3,5,5});
|
s0.insert({9,7,3,5,5});
|
||||||
REQUIRE(s0 == set_t{2,3,4,4,5,5,6,7,9});
|
REQUIRE(s0 == set_t{2,3,4,4,5,5,6,7,9});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
set_t s0;
|
||||||
|
s0.insert(sorted_unique_range, {1,2,3});
|
||||||
|
REQUIRE(s0 == set_t{1,2,3});
|
||||||
|
|
||||||
|
set_t s1;
|
||||||
|
s1.insert(sorted_range, {1,2,2,3});
|
||||||
|
REQUIRE(s1 == set_t{1,2,2,3});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SECTION("erasers") {
|
SECTION("erasers") {
|
||||||
using set_t = flat_multiset<int>;
|
using set_t = flat_multiset<int>;
|
||||||
|
|||||||
@@ -326,6 +326,16 @@ TEST_CASE("flat_set") {
|
|||||||
s0.insert({9,7,3,5,5});
|
s0.insert({9,7,3,5,5});
|
||||||
REQUIRE(s0 == set_t{2,3,4,5,6,7,9});
|
REQUIRE(s0 == set_t{2,3,4,5,6,7,9});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
set_t s0;
|
||||||
|
s0.insert(sorted_unique_range, {1,2,3});
|
||||||
|
REQUIRE(s0 == set_t{1,2,3});
|
||||||
|
|
||||||
|
set_t s1;
|
||||||
|
s1.insert(sorted_range, {1,2,2,3});
|
||||||
|
REQUIRE(s1 == set_t{1,2,3});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SECTION("erasers") {
|
SECTION("erasers") {
|
||||||
using set_t = flat_set<int>;
|
using set_t = flat_set<int>;
|
||||||
|
|||||||
Reference in New Issue
Block a user