00001
00007
00008
00055 template <class T, class Pr = std::less<T>, class R = RNG >
00056 class SkipList
00057 {
00058 public:
00059 class T0;
00060 class T1;
00061 friend class T0;
00062 friend class T1;
00064 typedef size_t size_type;
00066
00069 typedef ptrdiff_t difference_type;
00071 typedef T value_type;
00073 typedef BidiNode<value_type> node_type;
00075 typedef SkipList<T,Pr,R> container_type;
00077 typedef T key_type;
00079
00084 typedef T0 iterator;
00086 typedef T* pointer;
00088 typedef T& reference;
00090 typedef T mapped_type;
00092 typedef T& mapped_type_reference;
00094 typedef const T const_mapped_type;
00096 typedef const T& const_mapped_type_reference;
00098 typedef const T& const_reference;
00100 typedef T1 const_iterator;
00102
00105 typedef std::reverse_iterator<iterator> reverse_iterator;
00107 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
00109 typedef std::pair<iterator, bool> slpair;
00111 typedef std::pair<iterator, iterator> ipair;
00113 typedef std::pair<const_iterator, const_iterator> const_ipair;
00115 typedef Pr key_compare;
00117 typedef Pr value_compare;
00118
00119 private:
00120 R rng;
00121 Pr Compare;
00122 unsigned int maxLevel;
00123 unsigned int level;
00124 node_type *head;
00125 node_type *tail;
00126 double probability;
00127 size_type items;
00128 mutable std::pair<size_type,node_type*> *update;
00129
00131
00135 void Init(double probability, unsigned int maxLevel) {}
00136
00138
00143 node_type* Alloc(unsigned int level, const T &obj) {}
00144
00146
00150 node_type* Alloc(unsigned int level) {}
00151
00153
00156 void Free(node_type *item) {}
00157
00159
00162 unsigned int GenerateRandomLevel() const {}
00163
00165 void adjust_levels() {}
00166
00168
00174 void scan(const value_type &val) const{}
00175
00177
00183 void scan(const node_type *nodex) const{}
00184
00186
00193 void scan(const iterator &where) const{}
00194 public:
00195
00197
00200 class T0 : public std::iterator<std::bidirectional_iterator_tag, value_type>
00201 {
00202 public:
00203 typedef std::iterator<std::bidirectional_iterator_tag, value_type> baseclass;
00204 typedef std::random_acces_iterator_tag iterator_category;
00205 typedef typename baseclass::value_type value_type;
00206 typedef typename baseclass::value_type* pointer;
00207 typedef typename baseclass::value_type& reference;
00208 typedef ptrdiff_t difference_type;
00209
00210 friend T1;
00211 friend container_type;
00212 private:
00213 container_type *container;
00214 node_type* node;
00215 public:
00217 T0() {}
00218
00220
00223 T0(const T0 &t0){}
00224
00226
00229 T0(const T1 &t1){}
00230
00232
00236 T0(container_type *container, node_type* p){}
00237
00239
00242 bool operator==(const T0& other) const{}
00243
00245
00248 bool operator!=(const T0& other) const{}
00249
00251
00254 bool operator==(const T1& other) const{}
00255
00257
00260 bool operator!=(const T1& other) const{}
00261
00263
00268 T0& operator++(){}
00269
00271
00276 T0 operator++(int){}
00277
00279
00284 T0& operator--(){}
00285
00287
00292 T0 operator--(int){}
00293
00295
00300 reference operator*() const{}
00301
00303
00308 pointer operator->() const{}
00309
00311
00314 bool operator<(const T0 &other) const{}
00315
00317
00320 bool operator<=(const T0 &other) const{}
00321
00323
00326 bool operator>(const T0 &other) const{}
00327
00329
00332 bool operator>=(const T0 &other) const{}
00333
00335
00338 bool operator<(const T1 &other) const{}
00339
00341
00344 bool operator<=(const T1 &other) const{}
00345
00347
00350 bool operator>(const T1 &other) const{}
00351
00353
00356 bool operator>=(const T1 &other) const{}
00357 };
00358
00360
00363 class T1 : public std::iterator<std::bidirectional_iterator_tag, value_type, ptrdiff_t, const value_type*, const value_type&>
00364 {
00365 public:
00366 typedef std::iterator<std::bidirectional_iterator_tag, value_type> baseclass;
00367 typedef std::random_acces_iterator_tag iterator_category;
00368 typedef typename baseclass::value_type value_type;
00369 typedef typename const baseclass::value_type* pointer;
00370 typedef typename const baseclass::value_type& reference;
00371 typedef ptrdiff_t difference_type;
00372
00373 friend T0;
00374 friend container_type;
00375 private:
00376 const container_type *container;
00377 const node_type* node;
00378 public:
00380 T1() {}
00381
00383
00386 T1(const T1 &t1){}
00387
00389
00392 T1(const T0 &t0){}
00393
00395
00399 T1(container_type *container, node_type* p){}
00400
00402
00405 bool operator==(const T0& other) const{}
00406
00408
00411 bool operator!=(const T0& other) const{}
00412
00414
00417 bool operator==(const T1& other) const{}
00418
00420
00423 bool operator!=(const T1& other) const{}
00424
00426
00431 T1& operator++(){}
00432
00434
00439 T1 operator++(int){}
00440
00442
00447 T1& operator--(){}
00448
00450
00455 T1 operator--(int){}
00456
00458
00463 reference operator*() const{}
00464
00466
00471 pointer operator->() const{}
00472
00474
00477 bool operator<(const T0 &other) const{}
00478
00480
00483 bool operator<=(const T0 &other) const{}
00484
00486
00489 bool operator>(const T0 &other) const{}
00490
00492
00495 bool operator>=(const T0 &other) const{}
00496
00498
00501 bool operator<(const T1 &other) const{}
00502
00504
00507 bool operator<=(const T1 &other) const{}
00508
00510
00513 bool operator>(const T1 &other) const{}
00514
00516
00519 bool operator>=(const T1 &other) const{}
00520 };
00521
00523
00527 SkipList(){}
00528
00530
00536 explicit SkipList(size_type maxNodes){}
00537
00539
00543 SkipList(double probability, unsigned int maxLevel){}
00544
00546
00551 SkipList(const container_type &source){}
00552
00554
00561 template<class InIt> SkipList(InIt first, InIt last){}
00562
00564
00570 template<class InIt> SkipList(InIt first, InIt last, double probability, unsigned int maxLevel){}
00571
00573
00581 template<class InIt> SkipList(InIt first, InIt last, size_type maxNodes){}
00582
00584
00590 explicit SkipList(const key_compare& comp){}
00591
00593
00601 template<class InIt> SkipList(InIt first, InIt last, const key_compare& comp){}
00602
00604
00611 template<class InIt> SkipList(InIt first, InIt last, const key_compare& comp, double probability, unsigned int maxLevel){}
00612
00614
00623 template<class InIt> SkipList(InIt first, InIt last, const key_compare& comp, size_type maxNodes) : Compare(comp){}
00624
00626
00629 ~SkipList(){}
00630
00631
00633
00639 container_type& operator=(const container_type &source){}
00640
00642
00645 iterator begin(){}
00646
00648
00651 iterator end(){}
00652
00654
00657 const_iterator begin() const{}
00658
00660
00663 const_iterator end() const{}
00664
00666
00669 reverse_iterator rbegin(){}
00670
00672
00675 reverse_iterator rend(){}
00676
00678
00681 const_reverse_iterator rbegin() const{}
00682
00684
00687 const_reverse_iterator rend() const{}
00688
00690
00693 size_type size() const{}
00694
00696
00699 bool empty() const{}
00700
00702
00705 reference front(){}
00706
00708
00711 const_reference front() const{}
00712
00714
00717 reference back(){}
00718
00720
00723 const_reference back() const{}
00724
00726 void pop_front(){}
00727
00729 void destroy_front(){}
00730
00732 void pop_back(){}
00733
00735 void destroy_back(){}
00736
00738
00742 template<class InIt> void assign(InIt first, InIt last){}
00743
00745
00755 slpair insert(const value_type& val){}
00756
00758
00764 iterator insert(const iterator &where, const value_type& val) {}
00765
00767
00771 template<class InIt> void insert(InIt first, InIt last) {}
00772
00774 void clear(){}
00775
00777 void destroy(){}
00778
00780 iterator erase(const iterator &where){}
00781
00783 iterator destroy(const iterator &where){}
00784
00786
00793 iterator erase(const iterator &first, const iterator &last){}
00794
00796
00803 iterator destroy(const iterator &first, const iterator &last){}
00804
00806
00810 size_type erase(const key_type &keyval){}
00811
00813
00817 size_type destroy(const key_type &keyval){}
00818
00820
00823 void swap(container_type& right) {}
00824
00826
00829 template<class Pr1> void erase_if(Pr1 pred);
00830
00832
00835 template<class Pr4> void destroy_if(Pr4 pred);
00836
00838
00849 void cut(const iterator &first, const iterator &last, container_type& right);
00850
00852 key_compare key_comp() const { }
00853
00855 value_compare value_comp() const { }
00856
00858 size_type max_size() const{}
00859
00861
00867 const key_type& key(const value_type& value) const {}
00868
00870
00876 mapped_type& value(value_type& value) {}
00877
00879
00883 iterator find(const key_type& keyval) {}
00884
00886
00890 const_iterator find(const key_type& keyval) const {}
00891
00893
00897 size_type count(const key_type& keyval) const {}
00898
00899
00901
00905 iterator lower_bound(const key_type& keyval) {}
00906
00908
00912 const_iterator lower_bound(const key_type& keyval) const {}
00913
00915
00919 iterator upper_bound(const key_type& keyval) {}
00920
00922
00926 const_iterator upper_bound(const key_type& keyval) const {}
00927
00929
00933 ipair equal_range(const key_type& keyval) {}
00934
00936
00940 const_ipair equal_range(const key_type& keyval) const {}
00941 };
00942
00944
00949 template <class T, class Pr, class R>
00950 bool operator==(const SkipList<T,Pr,R> &left, const SkipList<T,Pr,R> &right)
00951 {
00952 return ((left.size() == right.size()) &&
00953 (std::equal(left.begin(), left.end(), right.begin())));
00954
00955 }
00956
00958
00963 template <class T, class Pr, class R>
00964 bool operator!=(const SkipList<T,Pr,R> &left, const SkipList<T,Pr,R> &right)
00965 {
00966 return !(left==right);
00967 }
00968
00970
00975 template <class T, class Pr, class R>
00976 bool operator<(const SkipList<T,Pr,R> &left, const SkipList<T,Pr,R> &right)
00977 {
00978 return lexicographical_compare(left.begin(),left.end(),right.begin(),right.end(),left.value_comp());
00979 }
00980
00982
00987 template <class T, class Pr, class R>
00988 bool operator<=(const SkipList<T,Pr,R> &left, const SkipList<T,Pr,R> &right)
00989 {
00990 return !(right < left);
00991 }
00992
00994
00999 template <class T, class Pr, class R>
01000 bool operator>(const SkipList<T,Pr,R> &left, const SkipList<T,Pr,R> &right)
01001 {
01002 return (right < left);
01003 }
01004
01006
01011 template <class T, class Pr, class R>
01012 bool operator>=(const SkipList<T,Pr,R> &left, const SkipList<T,Pr,R> &right)
01013 {
01014 return !(left < right);
01015 }
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01028
01076 template <class T, class Pr = std::less<T>, class R = RNG >
01077 class MultiSkipList
01078 {
01079 public:
01080 class T0;
01081 class T1;
01082 friend class T0;
01083 friend class T1;
01085 typedef size_t size_type;
01087
01090 typedef ptrdiff_t difference_type;
01092 typedef T value_type;
01094 typedef BidiNode<value_type> node_type;
01096 typedef MultiSkipList<T,Pr,R> container_type;
01098 typedef T key_type;
01100
01105 typedef T0 iterator;
01107 typedef T* pointer;
01109 typedef T& reference;
01111 typedef T mapped_type;
01113 typedef T& mapped_type_reference;
01115 typedef const T const_mapped_type;
01117 typedef const T& const_mapped_type_reference;
01119 typedef const T& const_reference;
01121 typedef T1 const_iterator;
01123
01126 typedef std::reverse_iterator<iterator> reverse_iterator;
01128 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
01130 typedef std::pair<iterator, iterator> ipair;
01132 typedef std::pair<const_iterator, const_iterator> const_ipair;
01134 typedef Pr key_compare;
01136 typedef Pr value_compare;
01137
01138 private:
01139 R rng;
01140 Pr Compare;
01141 unsigned int maxLevel;
01142 unsigned int level;
01143 node_type *head;
01144 node_type *tail;
01145 double probability;
01146 size_type items;
01147 mutable std::pair<size_type,node_type*> *update;
01148
01150
01154 void Init(double probability, unsigned int maxLevel) {}
01155
01157
01162 node_type* Alloc(unsigned int level, const T &obj) {}
01163
01165
01169 node_type* Alloc(unsigned int level) {}
01170
01172
01175 void Free(node_type *item) {}
01176
01178
01181 unsigned int GenerateRandomLevel() const {}
01182
01184 void adjust_levels() {}
01185
01187
01193 void scan(const value_type &val) const{}
01194
01196
01202 void scan(const node_type *nodex) const{}
01203
01205
01212 void scan(const iterator &where) const{}
01213
01214 public:
01216
01219 class T0 : public std::iterator<std::bidirectional_iterator_tag, value_type>
01220 {
01221 public:
01222 typedef std::iterator<std::bidirectional_iterator_tag, value_type> baseclass;
01223 typedef std::random_acces_iterator_tag iterator_category;
01224 typedef typename baseclass::value_type value_type;
01225 typedef typename baseclass::value_type* pointer;
01226 typedef typename baseclass::value_type& reference;
01227 typedef ptrdiff_t difference_type;
01228
01229 friend T1;
01230 friend container_type;
01231 private:
01232 container_type *container;
01233 node_type* node;
01234 public:
01236 T0() {}
01237
01239
01242 T0(const T0 &t0){}
01243
01245
01248 T0(const T1 &t1){}
01249
01251
01255 T0(container_type *container, node_type* p){}
01256
01258
01261 bool operator==(const T0& other) const{}
01262
01264
01267 bool operator!=(const T0& other) const{}
01268
01270
01273 bool operator==(const T1& other) const{}
01274
01276
01279 bool operator!=(const T1& other) const{}
01280
01282
01287 T0& operator++(){}
01288
01290
01295 T0 operator++(int){}
01296
01298
01303 T0& operator--(){}
01304
01306
01311 T0 operator--(int){}
01312
01314
01319 value_type& operator*() const{}
01320
01322
01327 value_type* operator->() const{}
01328
01330
01333 bool operator<(const T0 &other) const{}
01334
01336
01339 bool operator<=(const T0 &other) const{}
01340
01342
01345 bool operator>(const T0 &other) const{}
01346
01348
01351 bool operator>=(const T0 &other) const{}
01352
01354
01357 bool operator<(const T1 &other) const{}
01358
01360
01363 bool operator<=(const T1 &other) const{}
01364
01366
01369 bool operator>(const T1 &other) const{}
01370
01372
01375 bool operator>=(const T1 &other) const{}
01376 };
01377
01379
01382 class T1 : public std::iterator<std::bidirectional_iterator_tag, value_type, ptrdiff_t, const value_type*, const value_type&>
01383 {
01384 public:
01385 typedef std::iterator<std::bidirectional_iterator_tag, value_type> baseclass;
01386 typedef std::random_acces_iterator_tag iterator_category;
01387 typedef typename baseclass::value_type value_type;
01388 typedef typename const baseclass::value_type* pointer;
01389 typedef typename const baseclass::value_type& reference;
01390 typedef ptrdiff_t difference_type;
01391
01392 friend T0;
01393 friend container_type;
01394 private:
01395 const container_type *container;
01396 const node_type* node;
01397 public:
01399 T1() {}
01400
01402
01405 T1(const T1 &t1){}
01406
01408
01411 T1(const T0 &t0){}
01412
01414
01418 T1(container_type *container, node_type* p){}
01419
01421
01424 bool operator==(const T0& other) const{}
01425
01427
01430 bool operator!=(const T0& other) const{}
01431
01433
01436 bool operator==(const T1& other) const{}
01437
01439
01442 bool operator!=(const T1& other) const{}
01443
01445
01450 T1& operator++(){}
01451
01453
01458 T1 operator++(int){}
01459
01461
01466 T1& operator--(){}
01467
01469
01474 T1 operator--(int){}
01475
01477
01482 value_type& operator*() const{}
01483
01485
01490 value_type* operator->() const{}
01491
01493
01496 bool operator<(const T0 &other) const{}
01497
01499
01502 bool operator<=(const T0 &other) const{}
01503
01505
01508 bool operator>(const T0 &other) const{}
01509
01511
01514 bool operator>=(const T0 &other) const{}
01515
01517
01520 bool operator<(const T1 &other) const{}
01521
01523
01526 bool operator<=(const T1 &other) const{}
01527
01529
01532 bool operator>(const T1 &other) const{}
01533
01535
01538 bool operator>=(const T1 &other) const{}
01539 };
01540
01541
01543
01547 MultiSkipList(){}
01548
01550
01556 explicit MultiSkipList(size_type maxNodes){}
01557
01559
01563 MultiSkipList(double probability, unsigned int maxLevel){}
01564
01566
01571 MultiSkipList(const container_type &source){}
01572
01574
01581 template<class InIt> MultiSkipList(InIt first, InIt last){}
01582
01584
01590 template<class InIt> MultiSkipList(InIt first, InIt last, double probability, unsigned int maxLevel){}
01591
01593
01601 template<class InIt> MultiSkipList(InIt first, InIt last, size_type maxNodes){}
01602
01604
01610 explicit MultiSkipList(const key_compare& comp){}
01611
01613
01621 template<class InIt> MultiSkipList(InIt first, InIt last, const key_compare& comp){}
01622
01624
01631 template<class InIt> MultiSkipList(InIt first, InIt last, const key_compare& comp, double probability, unsigned int maxLevel){}
01632
01634
01643 template<class InIt> MultiSkipList(InIt first, InIt last, const key_compare& comp, size_type maxNodes) : Compare(comp){}
01644
01646
01649 ~MultiSkipList(){}
01650
01651
01653
01659 container_type& operator=(const container_type &source){}
01660
01662
01665 iterator begin(){}
01666
01668
01671 iterator end(){}
01672
01674
01677 const_iterator begin() const{}
01678
01680
01683 const_iterator end() const{}
01684
01686
01689 reverse_iterator rbegin(){}
01690
01692
01695 reverse_iterator rend(){}
01696
01698
01701 const_reverse_iterator rbegin() const{}
01702
01704
01707 const_reverse_iterator rend() const{}
01708
01710
01713 size_type size() const{}
01714
01716
01719 bool empty() const{}
01720
01722
01725 reference front(){}
01726
01728
01731 const_reference front() const{}
01732
01734
01737 reference back(){}
01738
01740
01743 const_reference back() const{}
01744
01746 void pop_front(){}
01747
01749 void destroy_front(){}
01750
01752 void pop_back(){}
01753
01755 void destroy_back(){}
01756
01758
01762 template<class InIt> void assign(InIt first, InIt last){}
01763
01765
01769 iterator insert(const value_type& val){}
01770
01772
01778 iterator insert(const iterator &where, const value_type& val) {}
01779
01781
01785 template<class InIt> void insert(InIt first, InIt last) {}
01786
01788 void clear(){}
01789
01791 void destroy(){}
01792
01794 iterator erase(const iterator &where){}
01795
01797 iterator destroy(const iterator &where){}
01798
01800
01807 iterator erase(const iterator &first, const iterator &last){}
01808
01810
01817 iterator destroy(const iterator &first, const iterator &last){}
01818
01820
01824 size_type erase(const key_type &keyval){}
01825
01827
01831 size_type destroy(const key_type &keyval){}
01832
01834
01837 void swap(container_type& right) {}
01838
01840
01843 template<class Pr1> void erase_if(Pr1 pred);
01844
01846
01849 template<class Pr4> void destroy_if(Pr4 pred);
01850
01852
01863 void cut(const iterator &first, const iterator &last, container_type& right);
01864
01866 key_compare key_comp() const { }
01867
01869 value_compare value_comp() const { }
01870
01872 size_type max_size() const{}
01873
01875
01881 const key_type& key(const value_type& value) const {}
01882
01884
01890 mapped_type& value(value_type& value) {}
01891
01893
01897 iterator find(const key_type& keyval) {}
01898
01900
01904 const_iterator find(const key_type& keyval) const {}
01905
01907
01911 size_type count(const key_type& keyval) const {}
01912
01913
01915
01919 iterator lower_bound(const key_type& keyval) {}
01920
01922
01926 const_iterator lower_bound(const key_type& keyval) const {}
01927
01929
01933 iterator upper_bound(const key_type& keyval) {}
01934
01936
01940 const_iterator upper_bound(const key_type& keyval) const {}
01941
01943
01947 ipair equal_range(const key_type& keyval) {}
01948
01950
01954 const_ipair equal_range(const key_type& keyval) const {}
01955 };
01956
01958
01963 template <class T, class Pr, class R>
01964 bool operator==(const MultiSkipList<T,Pr,R> &left, const MultiSkipList<T,Pr,R> &right)
01965 {
01966 return ((left.size() == right.size()) &&
01967 (std::equal(left.begin(), left.end(), right.begin())));
01968 }
01969
01971
01976 template <class T, class Pr, class R>
01977 bool operator!=(const MultiSkipList<T,Pr,R> &left, const MultiSkipList<T,Pr,R> &right)
01978 {
01979 return !(left==right);
01980 }
01981
01983
01988 template <class T, class Pr, class R>
01989 bool operator<(const MultiSkipList<T,Pr,R> &left, const MultiSkipList<T,Pr,R> &right)
01990 {
01991 return lexicographical_compare(left.begin(),left.end(),right.begin(),right.end(),left.value_comp());
01992 }
01993
01995
02000 template <class T, class Pr, class R>
02001 bool operator<=(const MultiSkipList<T,Pr,R> &left, const MultiSkipList<T,Pr,R> &right)
02002 {
02003 return !(right < left);
02004 }
02005
02007
02012 template <class T, class Pr, class R>
02013 bool operator>(const MultiSkipList<T,Pr,R> &left, const MultiSkipList<T,Pr,R> &right)
02014 {
02015 return (right < left);
02016 }
02017
02019
02024 template <class T, class Pr, class R>
02025 bool operator>=(const MultiSkipList<T,Pr,R> &left, const MultiSkipList<T,Pr,R> &right)
02026 {
02027 return !(left < right);
02028 }
02029
02030
02031
02032
02033
02034
02035
02036