mirror of
https://github.com/BlackMATov/flat.hpp.git
synced 2025-12-16 14:09:01 +07:00
add capacity interface
This commit is contained in:
12
flat_map.hpp
12
flat_map.hpp
@@ -110,6 +110,18 @@ namespace flat_hpp
|
|||||||
const_reverse_iterator rend() const noexcept { return data_.rend(); }
|
const_reverse_iterator rend() const noexcept { return data_.rend(); }
|
||||||
const_reverse_iterator crend() const noexcept { return data_.crend(); }
|
const_reverse_iterator crend() const noexcept { return data_.crend(); }
|
||||||
|
|
||||||
|
bool empty() const noexcept {
|
||||||
|
return data_.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_type size() const noexcept {
|
||||||
|
return data_.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_type max_size() const noexcept {
|
||||||
|
return data_.max_size();
|
||||||
|
}
|
||||||
|
|
||||||
template < typename P
|
template < typename P
|
||||||
, typename = std::enable_if_t<std::is_constructible<value_type, P>::value> >
|
, typename = std::enable_if_t<std::is_constructible<value_type, P>::value> >
|
||||||
std::pair<iterator, bool> insert(P&& p) {
|
std::pair<iterator, bool> insert(P&& p) {
|
||||||
|
|||||||
@@ -96,6 +96,13 @@ TEST_CASE("flat_map") {
|
|||||||
auto s3 = map_t({{0,1}, {1,2}}, std::less<int>(), alloc_t());
|
auto s3 = map_t({{0,1}, {1,2}}, std::less<int>(), alloc_t());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SECTION("capacity") {
|
||||||
|
using map_t = flat_map<int, unsigned>;
|
||||||
|
map_t s0;
|
||||||
|
s0.empty();
|
||||||
|
s0.size();
|
||||||
|
s0.max_size();
|
||||||
|
}
|
||||||
SECTION("inserts") {
|
SECTION("inserts") {
|
||||||
struct obj_t {
|
struct obj_t {
|
||||||
obj_t(int i) : i(i) {}
|
obj_t(int i) : i(i) {}
|
||||||
|
|||||||
12
flat_set.hpp
12
flat_set.hpp
@@ -109,6 +109,18 @@ namespace flat_hpp
|
|||||||
const_reverse_iterator rend() const noexcept { return data_.rend(); }
|
const_reverse_iterator rend() const noexcept { return data_.rend(); }
|
||||||
const_reverse_iterator crend() const noexcept { return data_.crend(); }
|
const_reverse_iterator crend() const noexcept { return data_.crend(); }
|
||||||
|
|
||||||
|
bool empty() const noexcept {
|
||||||
|
return data_.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_type size() const noexcept {
|
||||||
|
return data_.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_type max_size() const noexcept {
|
||||||
|
return data_.max_size();
|
||||||
|
}
|
||||||
|
|
||||||
template < typename P
|
template < typename P
|
||||||
, typename = std::enable_if_t<std::is_constructible<value_type, P>::value> >
|
, typename = std::enable_if_t<std::is_constructible<value_type, P>::value> >
|
||||||
std::pair<iterator, bool> insert(P&& p) {
|
std::pair<iterator, bool> insert(P&& p) {
|
||||||
|
|||||||
@@ -87,6 +87,13 @@ TEST_CASE("flat_set") {
|
|||||||
auto s3 = set_t({0,1,2}, std::less<int>(), alloc_t());
|
auto s3 = set_t({0,1,2}, std::less<int>(), alloc_t());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SECTION("capacity") {
|
||||||
|
using set_t = flat_set<int>;
|
||||||
|
set_t s0;
|
||||||
|
s0.empty();
|
||||||
|
s0.size();
|
||||||
|
s0.max_size();
|
||||||
|
}
|
||||||
SECTION("inserts") {
|
SECTION("inserts") {
|
||||||
struct obj_t {
|
struct obj_t {
|
||||||
obj_t(int i) : i(i) {}
|
obj_t(int i) : i(i) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user