diff --git a/flat_map.hpp b/flat_map.hpp index f9d98f4..3ad42db 100644 --- a/flat_map.hpp +++ b/flat_map.hpp @@ -20,9 +20,9 @@ namespace flat_hpp template < typename Key , typename Value , typename Compare = std::less - , typename Allocator = std::allocator> > + , typename Allocator = std::allocator> > class flat_map final { - using data_type = std::vector, Allocator>; + using data_type = std::vector, Allocator>; public: using key_type = Key; using mapped_type = Value; @@ -154,8 +154,42 @@ namespace flat_hpp //TODO(BlackMat): implme return insert(value_type(std::forward(args)...)); } + + void clear() noexcept { + data_.clear(); + } + + iterator erase(const_iterator iter) { + //TODO(BlackMat): implme + return end(); + } + + iterator erase(const_iterator first, const_iterator last) { + //TODO(BlackMat): implme + return end(); + } + + iterator erase(const key_type& key) { + //TODO(BlackMat): implme + return end(); + } + + void swap(flat_map& other) { + //TODO(BlackMat): implme + } private: data_type data_; key_compare compare_; }; + + template < typename Key + , typename Value + , typename Compare + , typename Allocator > + void swap( + flat_map& l, + flat_map& r) + { + l.swap(r); + } } diff --git a/flat_map_tests.cpp b/flat_map_tests.cpp index 227af3e..0b8ef77 100644 --- a/flat_map_tests.cpp +++ b/flat_map_tests.cpp @@ -40,7 +40,7 @@ TEST_CASE("flat_map") { std::is_same::value, "unit test static error"); static_assert( - std::is_same>::value, + std::is_same>::value, "unit test static error"); static_assert( @@ -51,22 +51,22 @@ TEST_CASE("flat_map") { "unit test static error"); static_assert( - std::is_same&>::value, + std::is_same&>::value, "unit test static error"); static_assert( - std::is_same&>::value, + std::is_same&>::value, "unit test static error"); static_assert( - std::is_same*>::value, + std::is_same*>::value, "unit test static error"); static_assert( - std::is_same*>::value, + std::is_same*>::value, "unit test static error"); } SECTION("ctors") { using alloc_t = dummy_allocator< - std::pair>; + std::pair>; using map_t = flat_map< int, @@ -121,4 +121,17 @@ TEST_CASE("flat_map") { s0.emplace_hint(s0.cend(), 6, 100500); } } + SECTION("erasers") { + using map_t = flat_map; + map_t s0; + s0.clear(); + s0.erase(s0.begin()); + s0.erase(s0.cbegin()); + s0.erase(s0.begin(), s0.end()); + s0.erase(s0.cbegin(), s0.cend()); + s0.erase(42); + map_t s1; + s0.swap(s1); + swap(s0, s1); + } } diff --git a/flat_set.hpp b/flat_set.hpp index e11a9e4..0478ddf 100644 --- a/flat_set.hpp +++ b/flat_set.hpp @@ -153,8 +153,41 @@ namespace flat_hpp //TODO(BlackMat): implme return insert(hint, value_type(std::forward(args)...)); } + + void clear() noexcept { + data_.clear(); + } + + iterator erase(const_iterator iter) { + //TODO(BlackMat): implme + return end(); + } + + iterator erase(const_iterator first, const_iterator last) { + //TODO(BlackMat): implme + return end(); + } + + iterator erase(const key_type& key) { + //TODO(BlackMat): implme + return end(); + } + + void swap(flat_set& other) { + //TODO(BlackMat): implme + } private: data_type data_; key_compare compare_; }; + + template < typename Key + , typename Compare + , typename Allocator > + void swap( + flat_set& l, + flat_set& r) + { + l.swap(r); + } } diff --git a/flat_set_tests.cpp b/flat_set_tests.cpp index 7e57727..cea309e 100644 --- a/flat_set_tests.cpp +++ b/flat_set_tests.cpp @@ -112,4 +112,17 @@ TEST_CASE("flat_set") { s0.emplace_hint(s0.cend(), 100500); } } + SECTION("erasers") { + using set_t = flat_set; + set_t s0; + s0.clear(); + s0.erase(s0.begin()); + s0.erase(s0.cbegin()); + s0.erase(s0.begin(), s0.end()); + s0.erase(s0.cbegin(), s0.cend()); + s0.erase(42); + set_t s1; + s0.swap(s1); + swap(s0, s1); + } }