手打 splay_tree 模板类 支持 find, rank, 前驱后继, iterator
迭代器中序遍历整棵树,++或--为前驱后继 可重复插入,查找,排名(<或<=),删除,大小,相同元素个数 功能超全的 stl-like splay 平衡树,摈弃平板电视,还不快收入囊中! 插入删除的方式为new/delete,不喜勿喷~ #include <algorithm> using namespace std; template<typename T> class splay_tree_iterator; template<typename T, typename _Less = less<T>, typename _Equ = equal_to<T>> class splay_tree { public: friend class splay_tree_iterator<T>; typedef _Less lesscmp; typedef _Equ equcmp; typedef splay_tree_iterator<T> iterator; splay_tree() : _r(nullptr) { } iterator root() { return iterator(_r); } iterator begin() { _node *p = _r; if(!p) return iterator(nullptr); while(p->s[0]) p = p->s[0];