#pragma once #include "RBTree.hpp" namespace Lenyiin { template class Set { struct SetKeyOfT { const K& operator()(const K& k) { return k; } }; public: // 这里RBTree::iterator还没有实例化, 系统找不到, typename告诉编译器现在先不着急找 typedef typename RBTree::iterator iterator; typedef typename RBTree::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 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 _tree; }; }