CSSSkipList.h

Go to the documentation of this file.
00001 
00007 
00008 
00063 template <class T, class Pr = std::less<T>, class R = RNG >
00064 class SSkipList
00065 {
00066 public:
00067   class T0;
00068   class T1;
00069   friend class T0;
00070   friend class T1;
00072   typedef size_t size_type;
00074 
00077   typedef ptrdiff_t difference_type;
00079   typedef T value_type;
00081   typedef ForwardNode<value_type> node_type;
00083   typedef SSkipList<T,Pr,R> container_type;
00085   typedef T key_type;
00087 
00092   typedef T0 iterator;
00094   typedef T* pointer;
00096   typedef T& reference;
00098   typedef T mapped_type;
00100   typedef T& mapped_type_reference;
00102   typedef const T const_mapped_type;
00104   typedef const T& const_mapped_type_reference;
00106   typedef const T& const_reference;
00108   typedef T1 const_iterator;
00110 
00113   typedef std::reverse_iterator<iterator> reverse_iterator;
00115   typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
00117   typedef std::pair<iterator, bool> slpair;
00119   typedef std::pair<iterator, iterator> ipair;
00121   typedef std::pair<const_iterator, const_iterator> const_ipair;
00123   typedef Pr key_compare;
00125   typedef Pr value_compare;
00126 
00127 private:
00128   R rng; 
00129   Pr Compare; 
00130   unsigned int maxLevel; 
00131   unsigned int level;    
00132   node_type *head;  
00133   node_type *tail; 
00134   double probability; 
00135   size_type items; 
00136   mutable std::pair<size_type,node_type*> *update; 
00137 
00139 
00143   void Init(double probability, unsigned int maxLevel) {}
00144 
00146 
00151   node_type* Alloc(unsigned int level, const T &obj) {}
00152 
00154 
00158   node_type* Alloc(unsigned int level) {}
00159 
00161 
00164   void Free(node_type *item) {}
00165 
00167 
00170   unsigned int GenerateRandomLevel() const {}
00171 
00173   void adjust_levels() {}
00174 
00176 
00182   void scan(const value_type &val) const{}
00183 
00185 
00191   void scan(const node_type *nodex) const{}
00192 
00194 
00201   void scan(const iterator &where) const{}
00202 public:
00203 
00205 
00208   class T0 : public std::iterator<std::bidirectional_iterator_tag, value_type>
00209   {
00210   public:
00211     typedef std::iterator<std::bidirectional_iterator_tag, value_type> baseclass;
00212     typedef std::random_acces_iterator_tag iterator_category;
00213     typedef typename baseclass::value_type value_type;
00214     typedef typename baseclass::value_type* pointer;
00215     typedef typename baseclass::value_type& reference;
00216     typedef ptrdiff_t difference_type;
00217 
00218     friend T1;
00219     friend container_type;
00220   private:
00221     container_type *container; 
00222     node_type* node; 
00223   public:
00225     T0() {}
00226 
00228 
00231     T0(const T0 &t0){}
00232 
00234 
00237     T0(const T1 &t1){}
00238 
00240 
00244     T0(container_type *container, node_type* p){}
00245 
00247 
00250     bool operator==(const T0& other) const{}
00251 
00253 
00256     bool operator!=(const T0& other) const{}
00257 
00259 
00262     bool operator==(const T1& other) const{}
00263 
00265 
00268     bool operator!=(const T1& other) const{}
00269 
00271 
00276     T0& operator++(){}
00277 
00279 
00284     T0 operator++(int){}
00285 
00287 
00292     T0& operator--(){}
00293 
00295 
00300     T0 operator--(int){}
00301 
00303 
00308     reference operator*() const{}
00309 
00311 
00316     pointer operator->() const{}
00317 
00319 
00322     bool operator<(const T0 &other) const{}
00323 
00325 
00328     bool operator<=(const T0 &other) const{}
00329 
00331 
00334     bool operator>(const T0 &other) const{}
00335 
00337 
00340     bool operator>=(const T0 &other) const{}
00341 
00343 
00346     bool operator<(const T1 &other) const{}
00347 
00349 
00352     bool operator<=(const T1 &other) const{}
00353 
00355 
00358     bool operator>(const T1 &other) const{}
00359 
00361 
00364     bool operator>=(const T1 &other) const{}
00365   };
00366 
00368 
00371   class T1 : public std::iterator<std::bidirectional_iterator_tag, value_type, ptrdiff_t, const value_type*, const value_type&>
00372   {
00373   public:
00374     typedef std::iterator<std::bidirectional_iterator_tag, value_type> baseclass;
00375     typedef std::random_acces_iterator_tag iterator_category;
00376     typedef typename baseclass::value_type value_type;
00377     typedef typename const baseclass::value_type* pointer;
00378     typedef typename const baseclass::value_type& reference;
00379     typedef ptrdiff_t difference_type;
00380 
00381     friend T0;
00382     friend container_type;
00383   private:
00384     const container_type *container; 
00385     const node_type* node; 
00386   public:
00388     T1() {}
00389 
00391 
00394     T1(const T1 &t1){}
00395 
00397 
00400     T1(const T0 &t0){}
00401 
00403 
00407     T1(container_type *container, node_type* p){}
00408 
00410 
00413     bool operator==(const T0& other) const{}
00414 
00416 
00419     bool operator!=(const T0& other) const{}
00420 
00422 
00425     bool operator==(const T1& other) const{}
00426 
00428 
00431     bool operator!=(const T1& other) const{}
00432 
00434 
00439     T1& operator++(){}
00440 
00442 
00447     T1 operator++(int){}
00448 
00450 
00455     T1& operator--(){}
00456 
00458 
00463     T1 operator--(int){}
00464 
00466 
00471     reference operator*() const{}
00472 
00474 
00479     pointer operator->() const{}
00480 
00482 
00485     bool operator<(const T0 &other) const{}
00486 
00488 
00491     bool operator<=(const T0 &other) const{}
00492 
00494 
00497     bool operator>(const T0 &other) const{}
00498 
00500 
00503     bool operator>=(const T0 &other) const{}
00504 
00506 
00509     bool operator<(const T1 &other) const{}
00510 
00512 
00515     bool operator<=(const T1 &other) const{}
00516 
00518 
00521     bool operator>(const T1 &other) const{}
00522 
00524 
00527     bool operator>=(const T1 &other) const{}
00528   };
00529 
00531 
00535   SSkipList(){}
00536 
00538 
00544   explicit SSkipList(size_type maxNodes){}
00545 
00547 
00551   SSkipList(double probability, unsigned int maxLevel){}
00552 
00554 
00559   SSkipList(const container_type &source){}
00560 
00562 
00569   template<class InIt> SSkipList(InIt first, InIt last){}
00570 
00572 
00578   template<class InIt> SSkipList(InIt first, InIt last, double probability, unsigned int maxLevel){}
00579 
00581 
00589   template<class InIt> SSkipList(InIt first, InIt last, size_type maxNodes){}
00590 
00592 
00598   explicit SSkipList(const key_compare& comp){}
00599 
00601 
00609   template<class InIt> SSkipList(InIt first, InIt last, const key_compare& comp){}
00610 
00612 
00619   template<class InIt> SSkipList(InIt first, InIt last, const key_compare& comp, double probability, unsigned int maxLevel){}
00620 
00622 
00631   template<class InIt> SSkipList(InIt first, InIt last, const key_compare& comp, size_type maxNodes) : Compare(comp){}
00632 
00634 
00637   ~SSkipList(){}
00638 
00639 
00641 
00647   container_type& operator=(const container_type &source){}
00648 
00650 
00653   iterator begin(){}
00654 
00656 
00659   iterator end(){}
00660 
00662 
00665   const_iterator begin() const{}
00666 
00668 
00671   const_iterator end() const{}
00672 
00674 
00677   reverse_iterator rbegin(){}
00678 
00680 
00683   reverse_iterator rend(){}
00684 
00686 
00689   const_reverse_iterator rbegin() const{}
00690 
00692 
00695   const_reverse_iterator rend() const{}
00696 
00698 
00701   size_type size() const{}
00702 
00704 
00707   bool empty() const{}
00708 
00710 
00713   reference front(){}
00714 
00716 
00719   const_reference front() const{}
00720 
00722 
00725   reference back(){}
00726 
00728 
00731   const_reference back() const{}
00732 
00734   void pop_front(){}
00735 
00737   void destroy_front(){}
00738 
00740   void pop_back(){}
00741 
00743   void destroy_back(){}
00744 
00746 
00750   template<class InIt> void assign(InIt first, InIt last){}
00751 
00753 
00763   slpair insert(const value_type& val){}
00764 
00766 
00772   iterator insert(const iterator &where, const value_type& val) {}
00773 
00775 
00779   template<class InIt> void insert(InIt first, InIt last) {}
00780 
00782   void clear(){}
00783 
00785   void destroy(){}
00786 
00788   iterator erase(const iterator &where){}
00789 
00791   iterator destroy(const iterator &where){}
00792 
00794 
00801   iterator erase(const iterator &first, const iterator &last){}
00802 
00804 
00811   iterator destroy(const iterator &first, const iterator &last){}
00812 
00814 
00818   size_type erase(const key_type &keyval){}
00819 
00821 
00825   size_type destroy(const key_type &keyval){}
00826 
00828 
00831   void swap(container_type& right) {}
00832 
00834 
00837   template<class Pr1> void erase_if(Pr1 pred);
00838 
00840 
00843   template<class Pr4> void destroy_if(Pr4 pred);
00844 
00846 
00857   void cut(const iterator &first, const iterator &last, container_type& right);
00858 
00860   key_compare key_comp() const { }
00861 
00863   value_compare value_comp() const { }
00864 
00866   size_type max_size() const{}
00867 
00869 
00875   const key_type& key(const value_type& value) const {}
00876 
00878 
00884   mapped_type& value(value_type& value) {}
00885 
00887 
00891   iterator find(const key_type& keyval) {}
00892 
00894 
00898   const_iterator find(const key_type& keyval) const {}
00899 
00901 
00905   size_type count(const key_type& keyval) const {}
00906 
00907 
00909 
00913   iterator lower_bound(const key_type& keyval) {}
00914 
00916 
00920   const_iterator lower_bound(const key_type& keyval) const {}
00921 
00923 
00927   iterator upper_bound(const key_type& keyval) {}
00928 
00930 
00934   const_iterator upper_bound(const key_type& keyval) const {}
00935 
00937 
00941   ipair equal_range(const key_type& keyval) {}
00942 
00944 
00948   const_ipair equal_range(const key_type& keyval) const {}
00949 };
00950 
00952 
00957 template <class T, class Pr, class R>
00958 bool operator==(const SSkipList<T,Pr,R> &left, const SSkipList<T,Pr,R> &right)
00959 {
00960   return ((left.size() == right.size()) &&
00961           (std::equal(left.begin(), left.end(), right.begin())));
00962 
00963 }
00964 
00966 
00971 template <class T, class Pr, class R>
00972 bool operator!=(const SSkipList<T,Pr,R> &left, const SSkipList<T,Pr,R> &right)
00973 {
00974   return !(left==right);
00975 }
00976 
00978 
00983 template <class T, class Pr, class R>
00984 bool operator<(const SSkipList<T,Pr,R> &left, const SSkipList<T,Pr,R> &right)
00985 {
00986   return lexicographical_compare(left.begin(),left.end(),right.begin(),right.end(),left.value_comp());
00987 }
00988 
00990 
00995 template <class T, class Pr, class R>
00996 bool operator<=(const SSkipList<T,Pr,R> &left, const SSkipList<T,Pr,R> &right)
00997 {
00998   return !(right < left);
00999 }
01000 
01002 
01007 template <class T, class Pr, class R>
01008 bool operator>(const SSkipList<T,Pr,R> &left, const SSkipList<T,Pr,R> &right)
01009 {
01010   return (right < left);
01011 }
01012 
01014 
01019 template <class T, class Pr, class R>
01020 bool operator>=(const SSkipList<T,Pr,R> &left, const SSkipList<T,Pr,R> &right)
01021 {
01022   return !(left < right);
01023 }
01024 
01025 /*#define csarg1 template <class T, class Pr, class R>
01026 #define csarg2 SSkipList<T,Pr,R>
01027 CSDefineCompOps(csarg1, csarg2)
01028 #undef csarg1
01029 #undef csarg2
01030 
01031 #undef CSUNIQUE
01032 #define CSUNIQUE(a,b) b
01033 */
01034 
01036 
01091 template <class T, class Pr = std::less<T>, class R = RNG >
01092 class MultiSSkipList
01093 {
01094 public:
01095   class T0;
01096   class T1;
01097   friend class T0;
01098   friend class T1;
01100   typedef size_t size_type;
01102 
01105   typedef ptrdiff_t difference_type;
01107   typedef T value_type;
01109   typedef ForwardNode<value_type> node_type;
01111   typedef MultiSSkipList<T,Pr,R> container_type;
01113   typedef T key_type;
01115 
01120   typedef T0 iterator;
01122   typedef T* pointer;
01124   typedef T& reference;
01126   typedef T mapped_type;
01128   typedef T& mapped_type_reference;
01130   typedef const T const_mapped_type;
01132   typedef const T& const_mapped_type_reference;
01134   typedef const T& const_reference;
01136   typedef T1 const_iterator;
01138 
01141   typedef std::reverse_iterator<iterator> reverse_iterator;
01143   typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
01145   typedef std::pair<iterator, iterator> ipair;
01147   typedef std::pair<const_iterator, const_iterator> const_ipair;
01149   typedef Pr key_compare;
01151   typedef Pr value_compare;
01152 
01153 private:
01154   R rng; 
01155   Pr Compare; 
01156   unsigned int maxLevel; 
01157   unsigned int level;    
01158   node_type *head;  
01159   node_type *tail; 
01160   double probability; 
01161   size_type items; 
01162   mutable std::pair<size_type,node_type*> *update; 
01163 
01165 
01169   void Init(double probability, unsigned int maxLevel) {}
01170 
01172 
01177   node_type* Alloc(unsigned int level, const T &obj) {}
01178 
01180 
01184   node_type* Alloc(unsigned int level) {}
01185 
01187 
01190   void Free(node_type *item) {}
01191 
01193 
01196   unsigned int GenerateRandomLevel() const {}
01197 
01199   void adjust_levels() {}
01200 
01202 
01208   void scan(const value_type &val) const{}
01209 
01211 
01217   void scan(const node_type *nodex) const{}
01218 
01220 
01227   void scan(const iterator &where) const{}
01228 
01229 public:
01231 
01234   class T0 : public std::iterator<std::bidirectional_iterator_tag, value_type>
01235   {
01236   public:
01237     typedef std::iterator<std::bidirectional_iterator_tag, value_type> baseclass;
01238     typedef std::random_acces_iterator_tag iterator_category;
01239     typedef typename baseclass::value_type value_type;
01240     typedef typename baseclass::value_type* pointer;
01241     typedef typename baseclass::value_type& reference;
01242     typedef ptrdiff_t difference_type;
01243 
01244     friend T1;
01245     friend container_type;
01246   private:
01247     container_type *container; 
01248     node_type* node; 
01249   public:
01251     T0() {}
01252 
01254 
01257     T0(const T0 &t0){}
01258 
01260 
01263     T0(const T1 &t1){}
01264 
01266 
01270     T0(container_type *container, node_type* p){}
01271 
01273 
01276     bool operator==(const T0& other) const{}
01277 
01279 
01282     bool operator!=(const T0& other) const{}
01283 
01285 
01288     bool operator==(const T1& other) const{}
01289 
01291 
01294     bool operator!=(const T1& other) const{}
01295 
01297 
01302     T0& operator++(){}
01303 
01305 
01310     T0 operator++(int){}
01311 
01313 
01318     T0& operator--(){}
01319 
01321 
01326     T0 operator--(int){}
01327 
01329 
01334     reference operator*() const{}
01335 
01337 
01342     pointer operator->() const{}
01343 
01345 
01348     bool operator<(const T0 &other) const{}
01349 
01351 
01354     bool operator<=(const T0 &other) const{}
01355 
01357 
01360     bool operator>(const T0 &other) const{}
01361 
01363 
01366     bool operator>=(const T0 &other) const{}
01367 
01369 
01372     bool operator<(const T1 &other) const{}
01373 
01375 
01378     bool operator<=(const T1 &other) const{}
01379 
01381 
01384     bool operator>(const T1 &other) const{}
01385 
01387 
01390     bool operator>=(const T1 &other) const{}
01391   };
01392 
01394 
01397   class T1 : public std::iterator<std::bidirectional_iterator_tag, value_type, ptrdiff_t, const value_type*, const value_type&>
01398   {
01399   public:
01400     typedef std::iterator<std::bidirectional_iterator_tag, value_type> baseclass;
01401     typedef std::random_acces_iterator_tag iterator_category;
01402     typedef typename baseclass::value_type value_type;
01403     typedef typename const baseclass::value_type* pointer;
01404     typedef typename const baseclass::value_type& reference;
01405     typedef ptrdiff_t difference_type;
01406 
01407     friend T0;
01408     friend container_type;
01409   private:
01410     const container_type *container; 
01411     const node_type* node; 
01412   public:
01414     T1() {}
01415 
01417 
01420     T1(const T1 &t1){}
01421 
01423 
01426     T1(const T0 &t0){}
01427 
01429 
01433     T1(container_type *container, node_type* p){}
01434 
01436 
01439     bool operator==(const T0& other) const{}
01440 
01442 
01445     bool operator!=(const T0& other) const{}
01446 
01448 
01451     bool operator==(const T1& other) const{}
01452 
01454 
01457     bool operator!=(const T1& other) const{}
01458 
01460 
01465     T1& operator++(){}
01466 
01468 
01473     T1 operator++(int){}
01474 
01476 
01481     T1& operator--(){}
01482 
01484 
01489     T1 operator--(int){}
01490 
01492 
01497     reference operator*() const{}
01498 
01500 
01505     pointer operator->() const{}
01506 
01508 
01511     bool operator<(const T0 &other) const{}
01512 
01514 
01517     bool operator<=(const T0 &other) const{}
01518 
01520 
01523     bool operator>(const T0 &other) const{}
01524 
01526 
01529     bool operator>=(const T0 &other) const{}
01530 
01532 
01535     bool operator<(const T1 &other) const{}
01536 
01538 
01541     bool operator<=(const T1 &other) const{}
01542 
01544 
01547     bool operator>(const T1 &other) const{}
01548 
01550 
01553     bool operator>=(const T1 &other) const{}
01554   };
01555 
01556 
01558 
01562   MultiSSkipList(){}
01563 
01565 
01571   explicit MultiSSkipList(size_type maxNodes){}
01572 
01574 
01578   MultiSSkipList(double probability, unsigned int maxLevel){}
01579 
01581 
01586   MultiSSkipList(const container_type &source){}
01587 
01589 
01596   template<class InIt> MultiSSkipList(InIt first, InIt last){}
01597 
01599 
01605   template<class InIt> MultiSSkipList(InIt first, InIt last, double probability, unsigned int maxLevel){}
01606 
01608 
01616   template<class InIt> MultiSSkipList(InIt first, InIt last, size_type maxNodes){}
01617 
01619 
01625   explicit MultiSSkipList(const key_compare& comp){}
01626 
01628 
01636   template<class InIt> MultiSSkipList(InIt first, InIt last, const key_compare& comp){}
01637 
01639 
01646   template<class InIt> MultiSSkipList(InIt first, InIt last, const key_compare& comp, double probability, unsigned int maxLevel){}
01647 
01649 
01658   template<class InIt> MultiSSkipList(InIt first, InIt last, const key_compare& comp, size_type maxNodes) : Compare(comp){}
01659 
01661 
01664   ~MultiSSkipList(){}
01665 
01666 
01668 
01674   container_type& operator=(const container_type &source){}
01675 
01677 
01680   iterator begin(){}
01681 
01683 
01686   iterator end(){}
01687 
01689 
01692   const_iterator begin() const{}
01693 
01695 
01698   const_iterator end() const{}
01699 
01701 
01704   reverse_iterator rbegin(){}
01705 
01707 
01710   reverse_iterator rend(){}
01711 
01713 
01716   const_reverse_iterator rbegin() const{}
01717 
01719 
01722   const_reverse_iterator rend() const{}
01723 
01725 
01728   size_type size() const{}
01729 
01731 
01734   bool empty() const{}
01735 
01737 
01740   reference front(){}
01741 
01743 
01746   const_reference front() const{}
01747 
01749 
01752   reference back(){}
01753 
01755 
01758   const_reference back() const{}
01759 
01761   void pop_front(){}
01762 
01764   void destroy_front(){}
01765 
01767   void pop_back(){}
01768 
01770   void destroy_back(){}
01771 
01773 
01777   template<class InIt> void assign(InIt first, InIt last){}
01778 
01780 
01784   iterator insert(const value_type& val){}
01785 
01787 
01793   iterator insert(const iterator &where, const value_type& val) {}
01794 
01796 
01800   template<class InIt> void insert(InIt first, InIt last) {}
01801 
01803   void clear(){}
01804 
01806   void destroy(){}
01807 
01809   iterator erase(const iterator &where){}
01810 
01812   iterator destroy(const iterator &where){}
01813 
01815 
01822   iterator erase(const iterator &first, const iterator &last){}
01823 
01825 
01832   iterator destroy(const iterator &first, const iterator &last){}
01833 
01835 
01839   size_type erase(const key_type &keyval){}
01840 
01842 
01846   size_type destroy(const key_type &keyval){}
01847 
01849 
01852   void swap(container_type& right) {}
01853 
01855 
01858   template<class Pr1> void erase_if(Pr1 pred);
01859 
01861 
01864   template<class Pr4> void destroy_if(Pr4 pred);
01865 
01867 
01878   void cut(const iterator &first, const iterator &last, container_type& right);
01879 
01881   key_compare key_comp() const { }
01882 
01884   value_compare value_comp() const { }
01885 
01887   size_type max_size() const{}
01888 
01890 
01896   const key_type& key(const value_type& value) const {}
01897 
01899 
01905   mapped_type& value(value_type& value) {}
01906 
01908 
01912   iterator find(const key_type& keyval) {}
01913 
01915 
01919   const_iterator find(const key_type& keyval) const {}
01920 
01922 
01926   size_type count(const key_type& keyval) const {}
01927 
01928 
01930 
01934   iterator lower_bound(const key_type& keyval) {}
01935 
01937 
01941   const_iterator lower_bound(const key_type& keyval) const {}
01942 
01944 
01948   iterator upper_bound(const key_type& keyval) {}
01949 
01951 
01955   const_iterator upper_bound(const key_type& keyval) const {}
01956 
01958 
01962   ipair equal_range(const key_type& keyval) {}
01963 
01965 
01969   const_ipair equal_range(const key_type& keyval) const {}
01970 };
01971 
01973 
01978 template <class T, class Pr, class R>
01979 bool operator==(const MultiSSkipList<T,Pr,R> &left, const MultiSSkipList<T,Pr,R> &right)
01980 {
01981   return ((left.size() == right.size()) &&
01982           (std::equal(left.begin(), left.end(), right.begin())));
01983 }
01984 
01986 
01991 template <class T, class Pr, class R>
01992 bool operator!=(const MultiSSkipList<T,Pr,R> &left, const MultiSSkipList<T,Pr,R> &right)
01993 {
01994   return !(left==right);
01995 }
01996 
01998 
02003 template <class T, class Pr, class R>
02004 bool operator<(const MultiSSkipList<T,Pr,R> &left, const MultiSSkipList<T,Pr,R> &right)
02005 {
02006   return lexicographical_compare(left.begin(),left.end(),right.begin(),right.end(),left.value_comp());
02007 }
02008 
02010 
02015 template <class T, class Pr, class R>
02016 bool operator<=(const MultiSSkipList<T,Pr,R> &left, const MultiSSkipList<T,Pr,R> &right)
02017 {
02018   return !(right < left);
02019 }
02020 
02022 
02027 template <class T, class Pr, class R>
02028 bool operator>(const MultiSSkipList<T,Pr,R> &left, const MultiSSkipList<T,Pr,R> &right)
02029 {
02030   return (right < left);
02031 }
02032 
02034 
02039 template <class T, class Pr, class R>
02040 bool operator>=(const MultiSSkipList<T,Pr,R> &left, const MultiSSkipList<T,Pr,R> &right)
02041 {
02042   return !(left < right);
02043 }
02044 
02045 
02046 /*#define csarg1 template <class T, class Pr, class R>
02047 #define csarg2 MultiSSkipList<T,Pr,R>
02048 CSDefineCompOps(csarg1, csarg2)
02049 #undef csarg1
02050 #undef csarg2
02051 */
 All Classes Files Functions Variables Typedefs