1 | // Copyright (C) 2015 ChaosForge Ltd
|
---|
2 | // http://chaosforge.org/
|
---|
3 | //
|
---|
4 | // This file is part of Nova libraries.
|
---|
5 | // For conditions of distribution and use, see copying.txt file in root folder.
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * @file unordered_map.hh
|
---|
9 | * @author Kornel Kisielewicz epyon@chaosforge.org
|
---|
10 | * @brief unordered_map
|
---|
11 | */
|
---|
12 |
|
---|
13 | #ifndef NV_STL_UNORDERED_MAP_HH
|
---|
14 | #define NV_STL_UNORDERED_MAP_HH
|
---|
15 |
|
---|
16 | #include <nv/common.hh>
|
---|
17 | #include <nv/stl/container/hash_table.hh>
|
---|
18 | #include <nv/stl/utility/pair.hh>
|
---|
19 |
|
---|
20 | namespace nv
|
---|
21 | {
|
---|
22 |
|
---|
23 | template <
|
---|
24 | typename Key,
|
---|
25 | typename T,
|
---|
26 | typename Hash = hash< Key >,
|
---|
27 | typename KeyEqual = equal_to< Key >
|
---|
28 | // typename Hash = hash<Key>(),
|
---|
29 | // typename Predicate = equal_to<Key>,
|
---|
30 | >
|
---|
31 | class unordered_map
|
---|
32 | : public hash_table< hash_table_entry_stl_map< Key, T, size_t, KeyEqual, Hash > >
|
---|
33 | {
|
---|
34 | public:
|
---|
35 | typedef hash_table< hash_table_entry_stl_map< Key, T, size_t, KeyEqual, Hash > > base_type;
|
---|
36 | typedef unordered_map< Key, T, Hash, KeyEqual > this_type;
|
---|
37 | typedef typename base_type::value_type value_type;
|
---|
38 | typedef typename base_type::pointer pointer;
|
---|
39 | typedef typename base_type::const_pointer const_pointer;
|
---|
40 | typedef typename base_type::reference reference;
|
---|
41 | typedef typename base_type::const_reference const_reference;
|
---|
42 | typedef typename base_type::iterator iterator;
|
---|
43 | typedef typename base_type::const_iterator const_iterator;
|
---|
44 | typedef typename base_type::size_type size_type;
|
---|
45 | typedef typename base_type::difference_type difference_type;
|
---|
46 | typedef typename base_type::key_type key_type;
|
---|
47 | typedef typename base_type::mapped_type mapped_type;
|
---|
48 | typedef typename base_type::node_type node_type;
|
---|
49 | typedef typename base_type::insert_return_type insert_return_type;
|
---|
50 | typedef Hash hasher;
|
---|
51 | typedef KeyEqual key_equal;
|
---|
52 |
|
---|
53 | unordered_map() : base_type() { }
|
---|
54 | explicit unordered_map( size_type bucket_count ) : base_type( bucket_count ) { }
|
---|
55 |
|
---|
56 | mapped_type& operator[]( const key_type& key )
|
---|
57 | {
|
---|
58 | return ( *base_type::insert_key( key ).first ).second;
|
---|
59 | }
|
---|
60 |
|
---|
61 | using base_type::insert;
|
---|
62 |
|
---|
63 | // STL compatibility only, hint unused
|
---|
64 | iterator insert( const_iterator, const value_type& value )
|
---|
65 | {
|
---|
66 | return base_type::insert( value ).first;
|
---|
67 | }
|
---|
68 |
|
---|
69 | };
|
---|
70 |
|
---|
71 | }
|
---|
72 |
|
---|
73 | #endif // NV_STL_UNORDERED_MAP_HH
|
---|
74 |
|
---|