64 lines
1.6 KiB
Plaintext
64 lines
1.6 KiB
Plaintext
|
|
#pragma GCC system_header
|
||
|
|
|
||
|
|
#ifndef _LIBCXX_SET
|
||
|
|
#define _LIBCXX_SET
|
||
|
|
|
||
|
|
#include <__config>
|
||
|
|
#include <__rbtree>
|
||
|
|
#include <functional>
|
||
|
|
#include <memory>
|
||
|
|
#include <type_traits>
|
||
|
|
|
||
|
|
_LIBCXX_BEGIN_NAMESPACE_STD
|
||
|
|
|
||
|
|
template <class Key, class Compare = std::less<Key>, class Allocator = std::allocator<Key>>
|
||
|
|
class set {
|
||
|
|
private:
|
||
|
|
using __tree_type = __rbtree<Key, Compare, Allocator>;
|
||
|
|
|
||
|
|
public:
|
||
|
|
using key_type = Key;
|
||
|
|
using value_type = Key;
|
||
|
|
using size_type = std::size_t;
|
||
|
|
using difference_type = std::ptrdiff_t;
|
||
|
|
using key_compare = Compare;
|
||
|
|
using value_compare = Compare;
|
||
|
|
using allocator_type = Allocator;
|
||
|
|
using refernce = value_type&;
|
||
|
|
using const_reference = const value_type&;
|
||
|
|
using pointer = value_type*;
|
||
|
|
using const_pointer = const value_type*;
|
||
|
|
using node_type = typename __tree_type::node_type;
|
||
|
|
|
||
|
|
set()
|
||
|
|
: m_tree()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
set(const Compare& comp, const Allocator& alloc = Allocator())
|
||
|
|
: m_tree(comp, alloc)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
explicit set(const Allocator& alloc)
|
||
|
|
: m_tree(alloc)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
// TODO: Return std::pair<iterator, bool>
|
||
|
|
inline bool insert(const_reference value) { return m_tree.insert(value); }
|
||
|
|
inline bool insert(value_type&& value) { return m_tree.insert(std::move(value)); }
|
||
|
|
|
||
|
|
inline size_type erase(const_reference value) { return m_tree.erase(value); }
|
||
|
|
|
||
|
|
inline allocator_type get_allocator() const noexcept { return m_tree.get_allocator(); }
|
||
|
|
inline size_type size() const { return m_tree.size(); }
|
||
|
|
inline bool empty() const { return size() == 0; }
|
||
|
|
|
||
|
|
private:
|
||
|
|
__tree_type m_tree;
|
||
|
|
};
|
||
|
|
|
||
|
|
_LIBCXX_END_NAMESPACE_STD
|
||
|
|
|
||
|
|
#endif // _LIBCXX_SET
|