Changeset be9eb15 in mainline
- Timestamp:
- 2018-07-05T21:41:22Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 49fbfb5
- Parents:
- 2a482ee
- git-author:
- Dzejrou <dzejrou@…> (2018-04-29 00:38:54)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:22)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/internal/rbtree.hpp
r2a482ee rbe9eb15 56 56 using const_iterator = ConstIterator; 57 57 58 using reverse_iterator = std::reverse_iterator<iterator>; 59 using const_reverse_iterator = std::reverse_iterator<const_iterator>; 60 58 61 using node_type = rbtree_node<value_type>; 59 62 … … 63 66 { /* DUMMY BODY */ } 64 67 65 rbtree(const rbtree& other); 66 67 rbtree(rbtree&& other); 68 69 rbtree& operator=(const rbtree& other); 70 71 rbtree& operator=(rbtree&& other); 68 rbtree(const rbtree& other); // TODO: 69 70 rbtree(rbtree&& other) 71 : root_{other.root_}, size_{other.size_}, 72 key_compare_{move(other.key_compare_)}, 73 key_extractor_{move(other.key_extractor_)} 74 { 75 other.root_ = nullptr; 76 other.size_ = size_type{}; 77 } 78 79 rbtree& operator=(const rbtree& other) 80 { 81 auto tmp{other}; 82 tmp.swap(*this); 83 84 return *this; 85 } 86 87 rbtree& operator=(rbtree&& other) 88 { 89 rbtree tmp{move(other)}; 90 tmp.swap(*this); 91 92 return *this; 93 } 72 94 73 95 bool empty() const noexcept … … 106 128 } 107 129 130 reverse_iterator rbegin() 131 { 132 return make_reverse_iterator(end()); 133 } 134 135 const_reverse_iterator rbegin() const 136 { 137 return make_reverse_iterator(cend()); 138 } 139 140 reverse_iterator rend() 141 { 142 return make_reverse_iterator(begin()); 143 } 144 145 const_reverse_iterator rend() const 146 { 147 return make_reverse_iterator(cbegin()); 148 } 149 108 150 const_iterator cbegin() const 109 151 { … … 114 156 { 115 157 return const_iterator{find_largest_(), true}; 158 } 159 160 const_reverse_iterator crbegin() const 161 { 162 return make_reverse_iterator(cend()); 163 } 164 165 const_reverse_iterator crend() const 166 { 167 return make_reverse_iterator(cbegin()); 116 168 } 117 169 … … 191 243 iterator find(const key_type& key) 192 244 { 193 // TODO: implement 194 } 195 196 const_iterator find(const key_type&& key) const 197 { 198 // TODO: implement 245 auto node = find_(key); 246 if (node) 247 return iterator{node, false}; 248 else 249 return end(); 250 } 251 252 const_iterator find(const key_type& key) const 253 { 254 auto node = find_(key); 255 if (node) 256 return const_iterator{node, false}; 257 else 258 return end(); 199 259 } 200 260 … … 273 333 key_extract key_extractor_; 274 334 335 node_type* find_(const key_type& key) const 336 { 337 auto current = root_; 338 while (current != nullptr) 339 { 340 if (key_compare_(key, key_extractor_(current->value))) 341 current = current->left; 342 else if (key == key_extractor_(current->value)) 343 return current; 344 else 345 current = current->right; 346 } 347 348 return nullptr; 349 } 350 275 351 node_type* find_smallest_() const 276 352 { … … 304 380 } 305 381 382 void repair_after_erase_(node_type* node) 383 { 384 // TODO: implement 385 } 386 306 387 friend Policy; 307 388 };
Note:
See TracChangeset
for help on using the changeset viewer.