0001 #include "List/List.h" //引入列表 0002 #include "Entry/Entry.h" //引入词条 0003 #include "Quadlist.h" //引入Quadlist 0004 #include "Dictionary/Dictionary.h" //引入词典 0005 0006 template <typename K, typename V> //key、value 0007 //符合Dictionary接口的Skiplist模板类(但隐含假设元素之间可比较大小) 0008 class Skiplist : public Dictionary<K, V>, public List<Quadlist<Entry<K, V>>*> { 0009 protected: 0010 bool skipSearch ( 0011 ListNode<Quadlist<Entry<K, V>>*>* &qlist, 0012 QuadlistNode<Entry<K, V>>* &p, 0013 K& k ); 0014 public: 0015 int size() const { return empty() ? 0 : last()->data->size(); } //底层Quadlist的规模 0016 int level() { return List::size(); } //层高 == #Quadlist,不一定要开放 0017 bool put ( K, V ); //插入(注意与Map有别——Skiplist允许词条重复,故必然成功) 0018 V* get ( K k ); //读取 0019 bool remove ( K k ); //删除 0020 };