mirror of
https://github.com/BlackMATov/flat.hpp.git
synced 2025-12-15 02:12:23 +07:00
133
README.md
133
README.md
@@ -191,40 +191,61 @@ value_compare value_comp() const;
|
|||||||
### Non-member functions
|
### Non-member functions
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template < typename K, typename C, typename A >
|
template < typename Key
|
||||||
|
, typename Compare
|
||||||
|
, typename Allocator
|
||||||
|
, typename Container >
|
||||||
void swap(
|
void swap(
|
||||||
flat_set<K, C, A>& l,
|
flat_set<Key, Compare, Allocator, Container>& l,
|
||||||
flat_set<K, C, A>& r);
|
flat_set<Key, Compare, Allocator, Container>& r);
|
||||||
|
|
||||||
template < typename K, typename C, typename A >
|
template < typename Key
|
||||||
|
, typename Compare
|
||||||
|
, typename Allocator
|
||||||
|
, typename Container >
|
||||||
bool operator==(
|
bool operator==(
|
||||||
const flat_set<K, C, A>& l,
|
const flat_set<Key, Compare, Allocator, Container>& l,
|
||||||
const flat_set<K, C, A>& r);
|
const flat_set<Key, Compare, Allocator, Container>& r);
|
||||||
|
|
||||||
template < typename K, typename C, typename A >
|
template < typename Key
|
||||||
|
, typename Compare
|
||||||
|
, typename Allocator
|
||||||
|
, typename Container >
|
||||||
bool operator!=(
|
bool operator!=(
|
||||||
const flat_set<K, C, A>& l,
|
const flat_set<Key, Compare, Allocator, Container>& l,
|
||||||
const flat_set<K, C, A>& r);
|
const flat_set<Key, Compare, Allocator, Container>& r);
|
||||||
|
|
||||||
template < typename K, typename C, typename A >
|
template < typename Key
|
||||||
|
, typename Compare
|
||||||
|
, typename Allocator
|
||||||
|
, typename Container >
|
||||||
bool operator<(
|
bool operator<(
|
||||||
const flat_set<K, C, A>& l,
|
const flat_set<Key, Compare, Allocator, Container>& l,
|
||||||
const flat_set<K, C, A>& r);
|
const flat_set<Key, Compare, Allocator, Container>& r);
|
||||||
|
|
||||||
template < typename K, typename C, typename A >
|
template < typename Key
|
||||||
|
, typename Compare
|
||||||
|
, typename Allocator
|
||||||
|
, typename Container >
|
||||||
bool operator>(
|
bool operator>(
|
||||||
const flat_set<K, C, A>& l,
|
const flat_set<Key, Compare, Allocator, Container>& l,
|
||||||
const flat_set<K, C, A>& r);
|
const flat_set<Key, Compare, Allocator, Container>& r);
|
||||||
|
|
||||||
template < typename K, typename C, typename A >
|
template < typename Key
|
||||||
|
, typename Compare
|
||||||
|
, typename Allocator
|
||||||
|
, typename Container >
|
||||||
bool operator<=(
|
bool operator<=(
|
||||||
const flat_set<K, C, A>& l,
|
const flat_set<Key, Compare, Allocator, Container>& l,
|
||||||
const flat_set<K, C, A>& r);
|
const flat_set<Key, Compare, Allocator, Container>& r);
|
||||||
|
|
||||||
template < typename K, typename C, typename A >
|
template < typename Key
|
||||||
|
, typename Compare
|
||||||
|
, typename Allocator
|
||||||
|
, typename Container >
|
||||||
bool operator>=(
|
bool operator>=(
|
||||||
const flat_set<K, C, A>& l,
|
const flat_set<Key, Compare, Allocator, Container>& l,
|
||||||
const flat_set<K, C, A>& r);
|
const flat_set<Key, Compare, Allocator, Container>& r);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Flat Map
|
## Flat Map
|
||||||
@@ -402,40 +423,68 @@ value_compare value_comp() const;
|
|||||||
### Non-member functions
|
### Non-member functions
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
template < typename K, typename V, typename C, typename A >
|
template < typename Key
|
||||||
|
, typename Value
|
||||||
|
, typename Compare
|
||||||
|
, typename Allocator
|
||||||
|
, typename Container >
|
||||||
void swap(
|
void swap(
|
||||||
flat_map<K, V, C, A>& l,
|
flat_map<Key, Value, Compare, Allocator, Container>& l,
|
||||||
flat_map<K, V, C, A>& r);
|
flat_map<Key, Value, Compare, Allocator, Container>& r);
|
||||||
|
|
||||||
template < typename K, typename V, typename C, typename A >
|
template < typename Key
|
||||||
|
, typename Value
|
||||||
|
, typename Compare
|
||||||
|
, typename Allocator
|
||||||
|
, typename Container >
|
||||||
bool operator==(
|
bool operator==(
|
||||||
const flat_map<K, V, C, A>& l,
|
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
||||||
const flat_map<K, V, C, A>& r);
|
const flat_map<Key, Value, Compare, Allocator, Container>& r);
|
||||||
|
|
||||||
template < typename K, typename V, typename C, typename A >
|
template < typename Key
|
||||||
|
, typename Value
|
||||||
|
, typename Compare
|
||||||
|
, typename Allocator
|
||||||
|
, typename Container >
|
||||||
bool operator!=(
|
bool operator!=(
|
||||||
const flat_map<K, V, C, A>& l,
|
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
||||||
const flat_map<K, V, C, A>& r);
|
const flat_map<Key, Value, Compare, Allocator, Container>& r);
|
||||||
|
|
||||||
template < typename K, typename V, typename C, typename A >
|
template < typename Key
|
||||||
|
, typename Value
|
||||||
|
, typename Compare
|
||||||
|
, typename Allocator
|
||||||
|
, typename Container >
|
||||||
bool operator<(
|
bool operator<(
|
||||||
const flat_map<K, V, C, A>& l,
|
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
||||||
const flat_map<K, V, C, A>& r);
|
const flat_map<Key, Value, Compare, Allocator, Container>& r);
|
||||||
|
|
||||||
template < typename K, typename V, typename C, typename A >
|
template < typename Key
|
||||||
|
, typename Value
|
||||||
|
, typename Compare
|
||||||
|
, typename Allocator
|
||||||
|
, typename Container >
|
||||||
bool operator>(
|
bool operator>(
|
||||||
const flat_map<K, V, C, A>& l,
|
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
||||||
const flat_map<K, V, C, A>& r);
|
const flat_map<Key, Value, Compare, Allocator, Container>& r);
|
||||||
|
|
||||||
template < typename K, typename V, typename C, typename A >
|
template < typename Key
|
||||||
|
, typename Value
|
||||||
|
, typename Compare
|
||||||
|
, typename Allocator
|
||||||
|
, typename Container >
|
||||||
bool operator<=(
|
bool operator<=(
|
||||||
const flat_map<K, V, C, A>& l,
|
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
||||||
const flat_map<K, V, C, A>& r);
|
const flat_map<Key, Value, Compare, Allocator, Container>& r);
|
||||||
|
|
||||||
template < typename K, typename V, typename C, typename A >
|
template < typename Key
|
||||||
|
, typename Value
|
||||||
|
, typename Compare
|
||||||
|
, typename Allocator
|
||||||
|
, typename Container >
|
||||||
bool operator>=(
|
bool operator>=(
|
||||||
const flat_map<K, V, C, A>& l,
|
const flat_map<Key, Value, Compare, Allocator, Container>& l,
|
||||||
const flat_map<K, V, C, A>& r);
|
const flat_map<Key, Value, Compare, Allocator, Container>& r);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Flat Multiset
|
## Flat Multiset
|
||||||
|
|||||||
26
flat_map.hpp
26
flat_map.hpp
@@ -133,27 +133,11 @@ namespace flat_hpp
|
|||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
flat_map(flat_map&& other)
|
flat_map(flat_map&& other) = default;
|
||||||
: data_(std::move(other.data_))
|
flat_map(const flat_map& other) = default;
|
||||||
, compare_(std::move(other.compare_)) {}
|
|
||||||
|
|
||||||
flat_map(const flat_map& other)
|
flat_map& operator=(flat_map&& other) = default;
|
||||||
: data_(other.data_)
|
flat_map& operator=(const flat_map& other) = default;
|
||||||
, compare_(other.compare_) {}
|
|
||||||
|
|
||||||
flat_map& operator=(flat_map&& other) {
|
|
||||||
if ( this != &other ) {
|
|
||||||
flat_map(std::move(other)).swap(*this);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
flat_map& operator=(const flat_map& other) {
|
|
||||||
if ( this != &other ) {
|
|
||||||
flat_map(other).swap(*this);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
flat_map& operator=(std::initializer_list<value_type> ilist) {
|
flat_map& operator=(std::initializer_list<value_type> ilist) {
|
||||||
flat_map(ilist).swap(*this);
|
flat_map(ilist).swap(*this);
|
||||||
@@ -388,7 +372,7 @@ namespace flat_hpp
|
|||||||
const flat_map<Key, Value, Compare, Allocator, Container>& r)
|
const flat_map<Key, Value, Compare, Allocator, Container>& r)
|
||||||
{
|
{
|
||||||
return l.size() == r.size()
|
return l.size() == r.size()
|
||||||
&& std::equal(l.begin(), l.end(), r.begin(), r.end());
|
&& std::equal(l.begin(), l.end(), r.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
|
|||||||
37
flat_set.hpp
37
flat_set.hpp
@@ -22,15 +22,6 @@ namespace flat_hpp
|
|||||||
, typename Allocator = std::allocator<Key>
|
, typename Allocator = std::allocator<Key>
|
||||||
, typename Container = std::vector<Key, Allocator> >
|
, typename Container = std::vector<Key, Allocator> >
|
||||||
class flat_set final {
|
class flat_set final {
|
||||||
class uber_comparer_type : public Compare {
|
|
||||||
public:
|
|
||||||
uber_comparer_type() = default;
|
|
||||||
uber_comparer_type(const Compare& c) : Compare(c) {}
|
|
||||||
|
|
||||||
bool operator()(const Key& l, const Key& r) const {
|
|
||||||
return Compare::operator()(l, r);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
public:
|
public:
|
||||||
using key_type = Key;
|
using key_type = Key;
|
||||||
using value_type = Key;
|
using value_type = Key;
|
||||||
@@ -111,27 +102,11 @@ namespace flat_hpp
|
|||||||
insert(ilist);
|
insert(ilist);
|
||||||
}
|
}
|
||||||
|
|
||||||
flat_set(flat_set&& other)
|
flat_set(flat_set&& other) = default;
|
||||||
: data_(std::move(other.data_))
|
flat_set(const flat_set& other) = default;
|
||||||
, compare_(std::move(other.compare_)) {}
|
|
||||||
|
|
||||||
flat_set(const flat_set& other)
|
flat_set& operator=(flat_set&& other) = default;
|
||||||
: data_(other.data_)
|
flat_set& operator=(const flat_set& other) = default;
|
||||||
, compare_(other.compare_) {}
|
|
||||||
|
|
||||||
flat_set& operator=(flat_set&& other) {
|
|
||||||
if ( this != &other ) {
|
|
||||||
flat_set(std::move(other)).swap(*this);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
flat_set& operator=(const flat_set& other) {
|
|
||||||
if ( this != &other ) {
|
|
||||||
flat_set(other).swap(*this);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
flat_set& operator=(std::initializer_list<value_type> ilist) {
|
flat_set& operator=(std::initializer_list<value_type> ilist) {
|
||||||
flat_set(ilist).swap(*this);
|
flat_set(ilist).swap(*this);
|
||||||
@@ -308,7 +283,7 @@ namespace flat_hpp
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
container_type data_;
|
container_type data_;
|
||||||
uber_comparer_type compare_;
|
Compare compare_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,7 +309,7 @@ namespace flat_hpp
|
|||||||
const flat_set<Key, Compare, Allocator, Container>& r)
|
const flat_set<Key, Compare, Allocator, Container>& r)
|
||||||
{
|
{
|
||||||
return l.size() == r.size()
|
return l.size() == r.size()
|
||||||
&& std::equal(l.begin(), l.end(), r.begin(), r.end());
|
&& std::equal(l.begin(), l.end(), r.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename Key
|
template < typename Key
|
||||||
|
|||||||
Reference in New Issue
Block a user