Changeset 170761c in mainline
- Timestamp:
- 2018-07-05T21:41:21Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b044f66
- Parents:
- 8ec1cd2
- git-author:
- Dzejrou <dzejrou@…> (2018-04-24 20:22:34)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:21)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/unordered_map.hpp
r8ec1cd2 r170761c 48 48 class Alloc = allocator<pair<const Key, Value>> 49 49 > 50 class unordered_map; 50 class unordered_map 51 { 52 public: 53 using key_type = Key; 54 using mapped_type = Value; 55 using value_type = pair<const key_type, mapped_type>; 56 using hasher = Hash; 57 using key_equal = Pred; 58 using allocator_type = Alloc; 59 using pointer = typename allocator_traits<allocator_type>::pointer; 60 using const_pointer = typename allocator_traits<allocator_type>::const_pointer; 61 using reference = value_type&; 62 using const_reference = const value_type&; 63 using size_type = size_t; 64 using difference_type = ptrdiff_t; 65 66 using iterator = aux::hash_table_iterator< 67 value_type, reference, pointer, size_type 68 >; 69 using const_iterator = aux::hash_table_const_iterator< 70 value_type, const_reference, const_pointer, size_type 71 >; 72 using local_iterator = aux::hash_table_local_iterator< 73 value_type, reference, pointer 74 >; 75 using const_local_iterator = aux::hash_table_const_local_iterator< 76 value_type, const_reference, const_pointer 77 >; 78 79 unordered_map() 80 : unordered_map{default_bucket_count_} 81 { /* DUMMY BODY */ } 82 83 explicit unordered_map(size_type bucket_count = default_bucket_count_, 84 const hasher& hf = hasher{}, 85 const key_equal& eql = key_equal{}, 86 const allocator_type& alloc = allocator_type{}) 87 : table_{bucket_count, hf, eql}, allocator_{alloc} 88 { /* DUMMY BODY */ } 89 90 template<class InputIterator> 91 unordered_map(InputIterator first, InputIterator last, 92 size_type bucket_count = default_bucket_count_, 93 const hasher& hf = hasher{}, 94 const key_equal& eql = key_equal{}, 95 const allocator_type& alloc = allocator_type{}) 96 : unordered_map{bucket_count, hf, eql, alloc} 97 { 98 // TODO: insert the range 99 } 100 101 unordered_map(const unordered_map& other) 102 : unordered_map{other, other.allocator_} 103 { /* DUMMY BODY */ } 104 105 unordered_map(unordered_map&& other) 106 : table_{move(other.table_)}, allocator_{move(other.allocator_)} 107 { /* DUMMY BODY */ } 108 109 explicit unordered_map(const allocator_type& alloc) 110 : table_{default_bucket_count_}, allocator_{alloc} 111 { /* DUMMY BODY */ } 112 113 unordered_map(const unordered_map& other, const allocator_type& alloc) 114 : table_{other.table_}, allocator_{alloc} 115 { /* DUMMY BODY */ } 116 117 unordered_map(unordered_map&& other, const allocator_type& alloc) 118 : table_{move(other.table_)}, allocator_{alloc} 119 { /* DUMMY BODY */ } 120 121 unordered_map(initializer_list<value_type> init, 122 size_type bucket_count = default_bucket_count_, 123 const hasher& hf = hasher{}, 124 const key_equal& eql = key_equal{}, 125 const allocator_type& alloc = allocator_type{}) 126 : unordered_map{bucket_count, hf, eql, alloc} 127 { 128 // TODO: insert the range 129 } 130 131 unordered_map(size_type bucket_count, const allocator_type& alloc) 132 : unordered_map{bucket_count, hasher{}, key_equal{}, alloc} 133 { /* DUMMY BODY */ } 134 135 unordered_map(size_type bucket_count, const hasher& hf, const allocator_type& alloc) 136 : unordered_map{bucket_count, hf, key_equal{}, alloc} 137 { /* DUMMY BODY */ } 138 139 template<class InputIterator> 140 unordered_map(InputIterator first, InputIterator last, 141 size_type bucket_count, const allocator_type& alloc) 142 : unordered_map{first, last, bucket_count, hasher{}, key_equal{}, alloc} 143 { /* DUMMY BODY */ } 144 145 template<class InputIterator> 146 unordered_map(InputIterator first, InputIterator last, 147 size_type bucket_count, const hasher& hf, const allocator_type& alloc) 148 : unordered_map{first, last, bucket_count, hf, key_equal{}, alloc} 149 { /* DUMMY BODY */ } 150 151 unordered_map(initializer_list<value_type> init, size_type bucket_count, 152 const allocator_type& alloc) 153 : unordered_map{init, bucket_count, hasher{}, key_equal{}, alloc} 154 { /* DUMMY BODY */ } 155 156 unordered_map(initializer_list<value_type> init, size_type bucket_count, 157 const hasher& hf, const allocator_type& alloc) 158 : unordered_map{init, bucket_count, hf, key_equal{}, alloc} 159 { /* DUMMY BODY */ } 160 161 ~unordered_map() 162 { /* DUMMY BODY */ } 163 164 unordered_map& operator=(const unordered_map& other) 165 { 166 // TODO: implement 167 return *this; 168 } 169 170 unordered_map& operator=(unordered_map&& other) 171 noexcept(allocator_traits<allocator_type>::is_always_equal::value && 172 is_nothrow_move_assignable<hasher>::value && 173 is_nothrow_move_assignable<key_equal>::value) 174 { 175 // TODO: implement 176 return *this; 177 } 178 179 unordered_map& operator=(initializer_list<value_type>& init) 180 { 181 // TODO: implement 182 return *this; 183 } 184 185 allocator_type get_allocator() const noexcept 186 { 187 return allocator_; 188 } 189 190 bool empty() const noexcept 191 { 192 return table_.empty(); 193 } 194 195 size_type size() const noexcept 196 { 197 return table_.size(); 198 } 199 200 size_type max_size() const noexcept 201 { 202 return table_.max_size(); 203 } 204 205 iterator begin() noexcept 206 { 207 return table_.begin(); 208 } 209 210 const_iterator begin() const noexcept 211 { 212 return table_.begin(); 213 } 214 215 iterator end() noexcept 216 { 217 return table_.end(); 218 } 219 220 const_iterator end() const noexcept 221 { 222 return table_.end(); 223 } 224 225 const_iterator cbegin() const noexcept 226 { 227 return table_.cbegin(); 228 } 229 230 const_iterator cend() const noexcept 231 { 232 return table_.cend(); 233 } 234 235 template<class... Args> 236 pair<iterator, bool> emplace(Args&&... args) 237 { 238 // TODO: implement 239 } 240 241 template<class... Args> 242 iterator emplace_hint(const_iterator position, Args&&... args) 243 { 244 // TODO: implement 245 } 246 247 pair<iterator, bool> insert(const value_type& val) 248 { 249 // TODO: implement 250 } 251 252 pair<iterator, bool> insert(value_type&& val) 253 { 254 // TODO: implement 255 } 256 257 template<class T> 258 pair<iterator, bool> insert(T&& val) 259 { 260 // TODO: implement 261 } 262 263 iterator insert(const_iterator hint, const value_type& val) 264 { 265 // TODO: implement 266 } 267 268 iterator insert(const_iterator hint, value_type&& val) 269 { 270 // TODO: implement 271 } 272 273 template<class T> 274 iterator insert(const_iterator hint, T&& val) 275 { 276 // TODO: implement 277 } 278 279 template<class InputIterator> 280 void insert(InputIterator first, InputIterator last) 281 { 282 // TODO: implement 283 } 284 285 void insert(initializer_list<value_type> init) 286 { 287 insert(init.begin(), init.end()); 288 } 289 290 template<class... Args> 291 pair<iterator, bool> try_emplace(const key_type& key, Args&&... args) 292 { 293 // TODO: implement 294 } 295 296 template<class... Args> 297 pair<iterator, bool> try_emplace(key_type&& key, Args&&... args) 298 { 299 // TODO: implement 300 } 301 302 template<class... Args> 303 iterator try_emplace(const_iterator hint, const key_type& key, Args&&... args) 304 { 305 // TODO: implement 306 } 307 308 template<class... Args> 309 iterator try_emplace(const_iterator hint, key_type&& key, Args&&... args) 310 { 311 // TODO: implement 312 } 313 314 template<class T> 315 pair<iterator, bool> insert_or_assign(const key_type& key, T&& val) 316 { 317 // TODO: implement 318 } 319 320 template<class T> 321 pair<iterator, bool> insert_or_assign(key_type&& key, T&& val) 322 { 323 // TODO: implement 324 } 325 326 template<class T> 327 iterator insert_or_assign(const_iterator hint, const key_type& key, T&& val) 328 { 329 // TODO: implement 330 } 331 332 template<class T> 333 iterator insert_or_assign(const_iterator hint, key_type&& key, T&& val) 334 { 335 // TODO: implement 336 } 337 338 iterator erase(const_iterator position) 339 { 340 // TODO: implement 341 } 342 343 size_type erase(const key_type& key) 344 { 345 // TODO: implement 346 } 347 348 iterator erase(const_iterator first, const_iterator last) 349 { 350 // TODO: implement 351 } 352 353 void clear() noexcept 354 { 355 table_.clear(); 356 } 357 358 void swap(unordered_map& other) 359 noexcept(allocator_traits<allocator_type>::is_always_equal::value && 360 noexcept(std::swap(declval<hasher>(), declval<hasher>())) && 361 noexcept(std::swap(declval<key_equal>(), declval<key_equal>()))) 362 { 363 table_.swap(other.table_); 364 std::swap(allocator_, other.allocator_); 365 } 366 367 hasher hash_function() const 368 { 369 return table_.hash_function(); 370 } 371 372 key_equal key_eq() const 373 { 374 return table_.key_eq(); 375 } 376 377 iterator find(const key_type& key) 378 { 379 // TODO: implement 380 } 381 382 const_iterator find(const key_type& key) const 383 { 384 // TODO: implement 385 } 386 387 size_type count(const key_type& key) const 388 { 389 // TODO: implement 390 } 391 392 pair<iterator, iterator> equal_range(const key_type& key) 393 { 394 // TODO: implement 395 } 396 397 pair<const_iterator, const_iterator> equal_range(const key_type& key) const 398 { 399 // TODO: implement 400 } 401 402 mapped_type& operator[](const key_type& key) 403 { 404 // TODO: implement 405 } 406 407 mapped_type& operator[](key_type&& key) 408 { 409 // TODO: implement 410 } 411 412 mapped_type& at(const key_type& key) 413 { 414 // TODO: implement 415 } 416 417 const mapped_type& at(const key_type& key) const 418 { 419 // TODO: implement 420 } 421 422 size_type bucket_count() const noexcept 423 { 424 return table_.bucket_count(); 425 } 426 427 size_type max_bucket_count() const noexcept 428 { 429 return table_.max_bucket_count(); 430 } 431 432 size_type bucket_size(size_type idx) const 433 { 434 return table_.bucket_size(idx); 435 } 436 437 size_type bucket(const key_type& key) const 438 { 439 return table_.bucket(key); 440 } 441 442 local_iterator begin(size_type idx) 443 { 444 return table_.begin(idx); 445 } 446 447 const_local_iterator begin(size_type idx) const 448 { 449 return table_.begin(idx); 450 } 451 452 local_iterator end(size_type idx) 453 { 454 return table_.end(idx); 455 } 456 457 const_local_iterator end(size_type idx) const 458 { 459 return table_.end(idx); 460 } 461 462 const_local_iterator cbegin(size_type idx) const 463 { 464 return table_.cbegin(idx); 465 } 466 467 const_local_iterator cend(size_type idx) const 468 { 469 return table_.cend(idx); 470 } 471 472 float load_factor() const noexcept 473 { 474 return table_.load_factor(); 475 } 476 477 float max_load_factor() const noexcept 478 { 479 return table_.max_load_factor(); 480 } 481 482 void max_load_factor(float factor) 483 { 484 table_.max_load_factor(factor); 485 } 486 487 void rehash(size_type bucket_count) 488 { 489 table_.rehash(bucket_count); 490 } 491 492 void reserve(size_type count) 493 { 494 table_.reserve(count); 495 } 496 497 private: 498 aux::hash_map< 499 value_type, key_type, aux::key_value_key_extractor<key_type, mapped_type>, 500 hasher, key_equal, allocator_type, size_type, 501 iterator, const_iterator, local_iterator, const_local_iterator, 502 aux::hash_single_policy 503 > table_; 504 505 allocator_type allocator_; 506 507 static constexpr size_type default_bucket_count_{16}; 508 }; 51 509 52 510 /**
Note:
See TracChangeset
for help on using the changeset viewer.