17#ifndef TRINITYCORE_FLAT_SET_H
18#define TRINITYCORE_FLAT_SET_H
25template <
class Key,
class Compare = std::less<Key>,
class KeyContainer = std::vector<Key>>
29 using iterator =
typename KeyContainer::iterator;
41 auto find(Key
const& value)
const
44 auto itr = std::lower_bound(this->
begin(),
end, value, Compare());
45 if (itr !=
end && Compare()(value, *itr))
51 auto find(Key
const& value)
54 auto itr = std::lower_bound(this->
begin(),
end, value, Compare());
55 if (itr !=
end && Compare()(value, *itr))
61 template <
class... Args>
62 std::pair<iterator, bool>
emplace(Args&&... args)
64 Key newElement(std::forward<Args>(args)...);
66 auto itr = std::lower_bound(this->
begin(),
end, newElement, Compare());
67 if (itr !=
end && !Compare()(newElement, *itr))
68 return { itr,
false };
70 return {
_storage.emplace(itr, std::move(newElement)),
true };
73 std::pair<iterator, bool>
insert(Key
const& key) {
return emplace(key); }
75 std::size_t
erase(Key
const& key)
77 auto itr = this->
find(key);
78 if (itr == this->
end())
97 return !(left == right);
auto erase(const_iterator itr)
auto find(Key const &value) const
auto find(Key const &value)
std::pair< iterator, bool > emplace(Args &&... args)
friend bool operator==(FlatSet const &left, FlatSet const &right)
typename KeyContainer::iterator iterator
std::pair< iterator, bool > insert(Key const &key)
std::size_t erase(Key const &key)
typename KeyContainer::const_iterator const_iterator
friend bool operator!=(FlatSet const &left, FlatSet const &right)