Set_Map/Linux/Set.hpp

66 lines
1.3 KiB
C++
Raw Normal View History

#pragma once
#include "RBTree.hpp"
namespace Lenyiin
{
template <class K>
class Set
{
struct SetKeyOfT
{
const K &operator()(const K &k)
{
return k;
}
};
public:
// 这里RBTree<K, K, SetKeyOfT>::iterator还没有实例化, 系统找不到, typename告诉编译器现在先不着急找
typedef typename RBTree<K, K, SetKeyOfT>::iterator iterator;
typedef typename RBTree<K, K, SetKeyOfT>::const_iterator const_iterator;
iterator begin()
{
return _tree.begin();
}
iterator end()
{
return _tree.end();
}
const_iterator begin() const
{
return _tree.begin();
}
const_iterator end() const
{
return _tree.end();
}
std::pair<iterator, bool> Insert(const K &key)
{
return _tree.Insert(key);
}
bool Erase(const K &key)
{
return _tree.Erase(key);
}
iterator &Find(const K &key)
{
return _tree.Find(key);
}
bool IsRBTree()
{
return _tree.IsRBTree();
}
private:
RBTree<K, K, SetKeyOfT> _tree;
};
}