00001
00007
00008
00055 template <class K, class T, class Pr = std::less<K>, class R = RNG >
00056 class KeyedSkipList
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 KeyedSkipList<K,T,Pr,R> container_type;
00073 typedef K key_type;
00075 typedef std::pair<const K, T> value_type;
00077 typedef BidiNode<value_type> node_type;
00079
00084 typedef T0 iterator;
00086 typedef value_type* pointer;
00088 typedef value_type& reference;
00090 typedef T data_type;
00092 typedef T mapped_type;
00094 typedef T& mapped_type_reference;
00096 typedef const T const_mapped_type;
00098 typedef const T& const_mapped_type_reference;
00100 typedef const T& const_reference;
00102 typedef T1 const_iterator;
00104
00107 typedef std::reverse_iterator<iterator> reverse_iterator;
00109 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
00111 typedef std::pair<iterator, bool> slpair;
00113 typedef std::pair<iterator, iterator> ipair;
00115 typedef std::pair<const_iterator, const_iterator> const_ipair;
00117 typedef Pr key_compare;
00118
00120 class value_compare
00121 : public std::binary_function<value_type, value_type, bool>
00122 {
00123 friend container_type;
00124 public:
00125 bool operator()(const value_type& left, const value_type& right) const
00126 {return (comp(left.first, right.first)); }
00127 protected:
00128 value_compare(const key_compare &pr) : comp(pr) {}
00129 key_compare comp;
00130 };
00131
00132 private:
00133 R rng;
00134 key_compare KeyCompare;
00135 value_compare ValueCompare;
00136 unsigned int maxLevel;
00137 unsigned int level;
00138 node_type *head;
00139 node_type *tail;
00140 double probability;
00141 size_type items;
00142 mutable std::pair<size_type,node_type*> *update;
00143
00145
00149 void Init(double probability, unsigned int maxLevel) {}
00150
00152
00157 node_type* Alloc(unsigned int level, const T &obj) {}
00158
00160
00164 node_type* Alloc(unsigned int level) {}
00165
00167
00170 void Free(node_type *item) {}
00171
00173
00176 unsigned int GenerateRandomLevel() const {}
00177
00179 void adjust_levels() {}
00180
00182
00188 void scan(const key_type &val) const{}
00189
00191
00197 void scan(const value_type &val) const{}
00198
00200
00206 void scan(const node_type *nodex) const{}
00207
00209
00216 void scan(const iterator &where) const{}
00217 public:
00218
00220
00223 class T0 : public std::iterator<std::bidirectional_iterator_tag, value_type>
00224 {
00225 public:
00226 typedef std::iterator<std::bidirectional_iterator_tag, value_type> baseclass;
00227 typedef std::random_acces_iterator_tag iterator_category;
00228 typedef typename baseclass::value_type value_type;
00229 typedef typename baseclass::value_type* pointer;
00230 typedef typename baseclass::value_type& reference;
00231 typedef ptrdiff_t difference_type;
00232
00233 friend T1;
00234 friend container_type;
00235 private:
00236 container_type *container;
00237 node_type* node;
00238 public:
00240 T0() {}
00241
00243
00246 T0(const T0 &t0){}
00247
00249
00252 T0(const T1 &t1){}
00253
00255
00259 T0(container_type *container, node_type* p){}
00260
00262
00265 bool operator==(const T0& other) const{}
00266
00268
00271 bool operator!=(const T0& other) const{}
00272
00274
00277 bool operator==(const T1& other) const{}
00278
00280
00283 bool operator!=(const T1& other) const{}
00284
00286
00291 T0& operator++(){}
00292
00294
00299 T0 operator++(int){}
00300
00302
00307 T0& operator--(){}
00308
00310
00315 T0 operator--(int){}
00316
00318
00323 reference operator*() const{}
00324
00326
00331 pointer operator->() const{}
00332
00334
00337 bool operator<(const T0 &other) const{}
00338
00340
00343 bool operator<=(const T0 &other) const{}
00344
00346
00349 bool operator>(const T0 &other) const{}
00350
00352
00355 bool operator>=(const T0 &other) const{}
00356
00358
00361 bool operator<(const T1 &other) const{}
00362
00364
00367 bool operator<=(const T1 &other) const{}
00368
00370
00373 bool operator>(const T1 &other) const{}
00374
00376
00379 bool operator>=(const T1 &other) const{}
00380 };
00381
00383
00386 class T1 : public std::iterator<std::bidirectional_iterator_tag, value_type, ptrdiff_t, const value_type*, const value_type&>
00387 {
00388 public:
00389 typedef std::iterator<std::bidirectional_iterator_tag, value_type> baseclass;
00390 typedef std::random_acces_iterator_tag iterator_category;
00391 typedef typename baseclass::value_type value_type;
00392 typedef typename const baseclass::value_type* pointer;
00393 typedef typename const baseclass::value_type& reference;
00394 typedef ptrdiff_t difference_type;
00395
00396 friend T0;
00397 friend container_type;
00398 private:
00399 const container_type *container;
00400 const node_type* node;
00401 public:
00403 T1() {}
00404
00406
00409 T1(const T1 &t1){}
00410
00412
00415 T1(const T0 &t0){}
00416
00418
00422 T1(container_type *container, node_type* p){}
00423
00425
00428 bool operator==(const T0& other) const{}
00429
00431
00434 bool operator!=(const T0& other) const{}
00435
00437
00440 bool operator==(const T1& other) const{}
00441
00443
00446 bool operator!=(const T1& other) const{}
00447
00449
00454 T1& operator++(){}
00455
00457
00462 T1 operator++(int){}
00463
00465
00470 T1& operator--(){}
00471
00473
00478 T1 operator--(int){}
00479
00481
00486 reference operator*() const{}
00487
00489
00494 pointer operator->() const{}
00495
00497
00500 bool operator<(const T0 &other) const{}
00501
00503
00506 bool operator<=(const T0 &other) const{}
00507
00509
00512 bool operator>(const T0 &other) const{}
00513
00515
00518 bool operator>=(const T0 &other) const{}
00519
00521
00524 bool operator<(const T1 &other) const{}
00525
00527
00530 bool operator<=(const T1 &other) const{}
00531
00533
00536 bool operator>(const T1 &other) const{}
00537
00539
00542 bool operator>=(const T1 &other) const{}
00543 };
00544
00546
00550 KeyedSkipList(){}
00551
00553
00559 explicit KeyedSkipList(size_type maxNodes){}
00560
00562
00566 KeyedSkipList(double probability, unsigned int maxLevel){}
00567
00569
00574 KeyedSkipList(const container_type &source){}
00575
00577
00584 template<class InIt> KeyedSkipList(InIt first, InIt last){}
00585
00587
00593 template<class InIt> KeyedSkipList(InIt first, InIt last, double probability, unsigned int maxLevel){}
00594
00596
00604 template<class InIt> KeyedSkipList(InIt first, InIt last, size_type maxNodes){}
00605
00607
00613 explicit KeyedSkipList(const key_compare& comp){}
00614
00616
00624 template<class InIt> KeyedSkipList(InIt first, InIt last, const key_compare& comp){}
00625
00627
00634 template<class InIt> KeyedSkipList(InIt first, InIt last, const key_compare& comp, double probability, unsigned int maxLevel){}
00635
00637
00646 template<class InIt> KeyedSkipList(InIt first, InIt last, const key_compare& comp, size_type maxNodes) : Compare(comp){}
00647
00649
00652 ~KeyedSkipList(){}
00653
00654
00656
00662 container_type& operator=(const container_type &source){}
00663
00665
00668 iterator begin(){}
00669
00671
00674 iterator end(){}
00675
00677
00680 const_iterator begin() const{}
00681
00683
00686 const_iterator end() const{}
00687
00689
00692 reverse_iterator rbegin(){}
00693
00695
00698 reverse_iterator rend(){}
00699
00701
00704 const_reverse_iterator rbegin() const{}
00705
00707
00710 const_reverse_iterator rend() const{}
00711
00713
00716 size_type size() const{}
00717
00719
00722 bool empty() const{}
00723
00725
00728 reference front(){}
00729
00731
00734 const_reference front() const{}
00735
00737
00740 reference back(){}
00741
00743
00746 const_reference back() const{}
00747
00749 void pop_front(){}
00750
00752 void destroy_front(){}
00753
00755 void pop_back(){}
00756
00758 void destroy_back(){}
00759
00761
00765 template<class InIt> void assign(InIt first, InIt last){}
00766
00768
00778 slpair insert(const value_type& val){}
00779
00781
00787 iterator insert(const iterator &where, const value_type& val) {}
00788
00790
00794 template<class InIt> void insert(InIt first, InIt last) {}
00795
00797 void clear(){}
00798
00800 void destroy(){}
00801
00803 iterator erase(const iterator &where){}
00804
00806 iterator destroy(const iterator &where){}
00807
00809
00816 iterator erase(const iterator &first, const iterator &last){}
00817
00819
00826 iterator destroy(const iterator &first, const iterator &last){}
00827
00829
00833 size_type erase(const key_type &keyval){}
00834
00836
00840 size_type destroy(const key_type &keyval){}
00841
00843
00846 void swap(container_type& right) {}
00847
00849
00852 template<class Pr1> void erase_if(Pr1 pred);
00853
00855
00858 template<class Pr4> void destroy_if(Pr4 pred);
00859
00861
00872 void cut(const iterator &first, const iterator &last, container_type& right);
00873
00875
00881 mapped_type_reference operator[](const key_type& key){}
00882
00884
00890 const_mapped_type_reference operator[](const key_type& key) const{}
00891
00893
00899 mapped_type_reference operator()(const key_type& key){}
00900
00902
00908 const_mapped_type_reference operator()(const key_type& key) const{}
00909
00911 key_compare key_comp() const { }
00912
00914 value_compare value_comp() const { }
00915
00917 size_type max_size() const{}
00918
00920
00926 const key_type& key(const value_type& value) const {}
00927
00929
00935 mapped_type& value(value_type& value) {}
00936
00938
00942 iterator find(const key_type& keyval) {}
00943
00945
00949 const_iterator find(const key_type& keyval) const {}
00950
00952
00956 size_type count(const key_type& keyval) const {}
00957
00958
00960
00964 iterator lower_bound(const key_type& keyval) {}
00965
00967
00971 const_iterator lower_bound(const key_type& keyval) const {}
00972
00974
00978 iterator upper_bound(const key_type& keyval) {}
00979
00981
00985 const_iterator upper_bound(const key_type& keyval) const {}
00986
00988
00992 ipair equal_range(const key_type& keyval) {}
00993
00995
00999 const_ipair equal_range(const key_type& keyval) const {}
01000 };
01001
01003
01008 template <class K, class T, class Pr, class R>
01009 bool operator==(const KeyedSkipList<K,T,Pr,R> &left, const KeyedSkipList<K,T,Pr,R> &right)
01010 {
01011 return ((left.size() == right.size()) &&
01012 (std::equal(left.begin(), left.end(), right.begin())));
01013
01014 }
01015
01017
01022 template <class K, class T, class Pr, class R>
01023 bool operator!=(const KeyedSkipList<K,T,Pr,R> &left, const KeyedSkipList<K,T,Pr,R> &right)
01024 {
01025 return !(left==right);
01026 }
01027
01029
01034 template <class K, class T, class Pr, class R>
01035 bool operator<(const KeyedSkipList<K,T,Pr,R> &left, const KeyedSkipList<K,T,Pr,R> &right)
01036 {
01037 return lexicographical_compare(left.begin(),left.end(),right.begin(),right.end(),left.value_comp());
01038 }
01039
01041
01046 template <class K, class T, class Pr, class R>
01047 bool operator<=(const KeyedSkipList<K,T,Pr,R> &left, const KeyedSkipList<K,T,Pr,R> &right)
01048 {
01049 return !(right < left);
01050 }
01051
01053
01058 template <class K, class T, class Pr, class R>
01059 bool operator>(const KeyedSkipList<K,T,Pr,R> &left, const KeyedSkipList<K,T,Pr,R> &right)
01060 {
01061 return (right < left);
01062 }
01063
01065
01070 template <class K, class T, class Pr, class R>
01071 bool operator>=(const KeyedSkipList<K,T,Pr,R> &left, const KeyedSkipList<K,T,Pr,R> &right)
01072 {
01073 return !(left < right);
01074 }
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01087
01134 template <class K, class T, class Pr = std::less<K>, class R = RNG >
01135 class MultiKeyedSkipList
01136 {
01137 public:
01138 class T0;
01139 class T1;
01140 friend class T0;
01141 friend class T1;
01143 typedef size_t size_type;
01145
01148 typedef ptrdiff_t difference_type;
01150 typedef MultiKeyedSkipList<K,T,Pr> container_type;
01152 typedef K key_type;
01154 typedef std::pair<const K, T> value_type;
01156 typedef BidiNode<value_type> node_type;
01158
01163 typedef T0 iterator;
01165 typedef value_type* pointer;
01167 typedef value_type& reference;
01169 typedef T data_type;
01171 typedef T mapped_type;
01173 typedef T& mapped_type_reference;
01175 typedef const T const_mapped_type;
01177 typedef const T& const_mapped_type_reference;
01179 typedef const T& const_reference;
01181 typedef T1 const_iterator;
01183
01186 typedef std::reverse_iterator<iterator> reverse_iterator;
01188 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
01190 typedef std::pair<iterator, iterator> ipair;
01192 typedef std::pair<const_iterator, const_iterator> const_ipair;
01194 typedef Pr key_compare;
01195
01197 class value_compare
01198 : public std::binary_function<value_type, value_type, bool>
01199 {
01200 friend container_type;
01201 public:
01202 bool operator()(const value_type& left, const value_type& right) const
01203 {return (comp(left.first, right.first)); }
01204 protected:
01205 value_compare(const key_compare &pr) : comp(pr) {}
01206 key_compare comp;
01207 };
01208
01209 private:
01210 R rng;
01211 key_compare KeyCompare;
01212 value_compare ValueCompare;
01213 unsigned int maxLevel;
01214 unsigned int level;
01215 node_type *head;
01216 node_type *tail;
01217 double probability;
01218 size_type items;
01219 mutable std::pair<size_type,node_type*> *update;
01220
01222
01226 void Init(double probability,unsigned int maxLevel) {}
01227
01229
01234 node_type* Alloc(unsigned int level, const T &obj) {}
01235
01237
01241 node_type* Alloc(unsigned int level) {}
01242
01244
01247 void Free(node_type *item) {}
01248
01250
01253 unsigned int GenerateRandomLevel() const {}
01254
01256 void adjust_levels() {}
01257
01259
01265 void scan(const key_type &val) const{}
01266
01268
01274 void scan(const value_type &val) const{}
01275
01277
01283 void scan(const node_type *nodex) const{}
01284
01286
01293 void scan(const iterator &where) const{}
01294
01295 public:
01297
01300 class T0 : public std::iterator<std::bidirectional_iterator_tag, value_type>
01301 {
01302 public:
01303 typedef std::iterator<std::bidirectional_iterator_tag, value_type> baseclass;
01304 typedef std::random_acces_iterator_tag iterator_category;
01305 typedef typename baseclass::value_type value_type;
01306 typedef typename baseclass::value_type* pointer;
01307 typedef typename baseclass::value_type& reference;
01308 typedef ptrdiff_t difference_type;
01309
01310 friend T1;
01311 friend container_type;
01312 private:
01313 container_type *container;
01314 node_type* node;
01315 public:
01317 T0() {}
01318
01320
01323 T0(const T0 &t0){}
01324
01326
01329 T0(const T1 &t1){}
01330
01332
01336 T0(container_type *container, node_type* p){}
01337
01339
01342 bool operator==(const T0& other) const{}
01343
01345
01348 bool operator!=(const T0& other) const{}
01349
01351
01354 bool operator==(const T1& other) const{}
01355
01357
01360 bool operator!=(const T1& other) const{}
01361
01363
01368 T0& operator++(){}
01369
01371
01376 T0 operator++(int){}
01377
01379
01384 T0& operator--(){}
01385
01387
01392 T0 operator--(int){}
01393
01395
01400 reference operator*() const{}
01401
01403
01408 pointer operator->() const{}
01409
01411
01414 bool operator<(const T0 &other) const{}
01415
01417
01420 bool operator<=(const T0 &other) const{}
01421
01423
01426 bool operator>(const T0 &other) const{}
01427
01429
01432 bool operator>=(const T0 &other) const{}
01433
01435
01438 bool operator<(const T1 &other) const{}
01439
01441
01444 bool operator<=(const T1 &other) const{}
01445
01447
01450 bool operator>(const T1 &other) const{}
01451
01453
01456 bool operator>=(const T1 &other) const{}
01457 };
01458
01460
01463 class T1 : public std::iterator<std::bidirectional_iterator_tag, value_type, ptrdiff_t, const value_type*, const value_type&>
01464 {
01465 public:
01466 typedef std::iterator<std::bidirectional_iterator_tag, value_type> baseclass;
01467 typedef std::random_acces_iterator_tag iterator_category;
01468 typedef typename baseclass::value_type value_type;
01469 typedef typename const baseclass::value_type* pointer;
01470 typedef typename const baseclass::value_type& reference;
01471 typedef ptrdiff_t difference_type;
01472
01473 friend T0;
01474 friend container_type;
01475 private:
01476 const container_type *container;
01477 const node_type* node;
01478 public:
01480 T1() {}
01481
01483
01486 T1(const T1 &t1){}
01487
01489
01492 T1(const T0 &t0){}
01493
01495
01499 T1(container_type *container, node_type* p){}
01500
01502
01505 bool operator==(const T0& other) const{}
01506
01508
01511 bool operator!=(const T0& other) const{}
01512
01514
01517 bool operator==(const T1& other) const{}
01518
01520
01523 bool operator!=(const T1& other) const{}
01524
01526
01531 T1& operator++(){}
01532
01534
01539 T1 operator++(int){}
01540
01542
01547 T1& operator--(){}
01548
01550
01555 T1 operator--(int){}
01556
01558
01563 reference operator*() const{}
01564
01566
01571 pointer operator->() const{}
01572
01574
01577 bool operator<(const T0 &other) const{}
01578
01580
01583 bool operator<=(const T0 &other) const{}
01584
01586
01589 bool operator>(const T0 &other) const{}
01590
01592
01595 bool operator>=(const T0 &other) const{}
01596
01598
01601 bool operator<(const T1 &other) const{}
01602
01604
01607 bool operator<=(const T1 &other) const{}
01608
01610
01613 bool operator>(const T1 &other) const{}
01614
01616
01619 bool operator>=(const T1 &other) const{}
01620 };
01621
01622
01624
01628 MultiKeyedSkipList(){}
01629
01631
01637 explicit MultiKeyedSkipList(size_type maxNodes){}
01638
01640
01644 MultiKeyedSkipList(double probability, unsigned int maxLevel){}
01645
01647
01652 MultiKeyedSkipList(const container_type &source){}
01653
01655
01662 template<class InIt> MultiKeyedSkipList(InIt first, InIt last){}
01663
01665
01671 template<class InIt> MultiKeyedSkipList(InIt first, InIt last, double probability, unsigned int maxLevel){}
01672
01674
01682 template<class InIt> MultiKeyedSkipList(InIt first, InIt last, size_type maxNodes){}
01683
01685
01691 explicit MultiKeyedSkipList(const key_compare& comp){}
01692
01694
01702 template<class InIt> MultiKeyedSkipList(InIt first, InIt last, const key_compare& comp){}
01703
01705
01712 template<class InIt> MultiKeyedSkipList(InIt first, InIt last, const key_compare& comp, double probability, unsigned int maxLevel){}
01713
01715
01724 template<class InIt> MultiKeyedSkipList(InIt first, InIt last, const key_compare& comp, size_type maxNodes) : Compare(comp){}
01725
01727
01730 ~MultiKeyedSkipList(){}
01731
01732
01734
01740 container_type& operator=(const container_type &source){}
01741
01743
01746 iterator begin(){}
01747
01749
01752 iterator end(){}
01753
01755
01758 const_iterator begin() const{}
01759
01761
01764 const_iterator end() const{}
01765
01767
01770 reverse_iterator rbegin(){}
01771
01773
01776 reverse_iterator rend(){}
01777
01779
01782 const_reverse_iterator rbegin() const{}
01783
01785
01788 const_reverse_iterator rend() const{}
01789
01791
01794 size_type size() const{}
01795
01797
01800 bool empty() const{}
01801
01803
01806 reference front(){}
01807
01809
01812 const_reference front() const{}
01813
01815
01818 reference back(){}
01819
01821
01824 const_reference back() const{}
01825
01827 void pop_front(){}
01828
01830 void destroy_front(){}
01831
01833 void pop_back(){}
01834
01836 void destroy_back(){}
01837
01839
01843 template<class InIt> void assign(InIt first, InIt last){}
01844
01846
01850 iterator insert(const value_type& val){}
01851
01853
01859 iterator insert(const iterator &where, const value_type& val) {}
01860
01862
01866 template<class InIt> void insert(InIt first, InIt last) {}
01867
01869 void clear(){}
01870
01872 void destroy(){}
01873
01875 iterator erase(const iterator &where){}
01876
01878 iterator destroy(const iterator &where){}
01879
01881
01888 iterator erase(const iterator &first, const iterator &last){}
01889
01891
01898 iterator destroy(const iterator &first, const iterator &last){}
01899
01901
01905 size_type erase(const key_type &keyval){}
01906
01908
01912 size_type destroy(const key_type &keyval){}
01913
01915
01918 void swap(container_type& right) {}
01919
01921
01924 template<class Pr1> void erase_if(Pr1 pred);
01925
01927
01930 template<class Pr4> void destroy_if(Pr4 pred);
01931
01933
01944 void cut(const iterator &first, const iterator &last, container_type& right);
01945
01947 key_compare key_comp() const { }
01948
01950 value_compare value_comp() const { }
01951
01953 size_type max_size() const{}
01954
01956
01962 const key_type& key(const value_type& value) const {}
01963
01965
01971 mapped_type& value(value_type& value) {}
01972
01974
01978 iterator find(const key_type& keyval) {}
01979
01981
01985 const_iterator find(const key_type& keyval) const {}
01986
01988
01992 size_type count(const key_type& keyval) const {}
01993
01994
01996
02000 iterator lower_bound(const key_type& keyval) {}
02001
02003
02007 const_iterator lower_bound(const key_type& keyval) const {}
02008
02010
02014 iterator upper_bound(const key_type& keyval) {}
02015
02017
02021 const_iterator upper_bound(const key_type& keyval) const {}
02022
02024
02028 ipair equal_range(const key_type& keyval) {}
02029
02031
02035 const_ipair equal_range(const key_type& keyval) const {}
02036 };
02037
02039
02044 template <class K, class T, class Pr, class R>
02045 bool operator==(const MultiKeyedSkipList<K,T,Pr,R> &left, const MultiKeyedSkipList<K,T,Pr,R> &right)
02046 {
02047 return ((left.size() == right.size()) &&
02048 (std::equal(left.begin(), left.end(), right.begin())));
02049 }
02050
02052
02057 template <class K, class T, class Pr, class R>
02058 bool operator!=(const MultiKeyedSkipList<K,T,Pr,R> &left, const MultiKeyedSkipList<K,T,Pr,R> &right)
02059 {
02060 return !(left==right);
02061 }
02062
02064
02069 template <class K, class T, class Pr, class R>
02070 bool operator<(const MultiKeyedSkipList<K,T,Pr,R> &left, const MultiKeyedSkipList<K,T,Pr,R> &right)
02071 {
02072 return lexicographical_compare(left.begin(),left.end(),right.begin(),right.end(),left.value_comp());
02073 }
02074
02076
02081 template <class K, class T, class Pr, class R>
02082 bool operator<=(const MultiKeyedSkipList<K,T,Pr,R> &left, const MultiKeyedSkipList<K,T,Pr,R> &right)
02083 {
02084 return !(right < left);
02085 }
02086
02088
02093 template <class K, class T, class Pr, class R>
02094 bool operator>(const MultiKeyedSkipList<K,T,Pr,R> &left, const MultiKeyedSkipList<K,T,Pr,R> &right)
02095 {
02096 return (right < left);
02097 }
02098
02100
02105 template <class K, class T, class Pr, class R>
02106 bool operator>=(const MultiKeyedSkipList<K,T,Pr,R> &left, const MultiKeyedSkipList<K,T,Pr,R> &right)
02107 {
02108 return !(left < right);
02109 }
02110
02111
02112
02113
02114
02115
02116
02117