xref: /aoo41x/main/stlport/systemstl/hash_map (revision dee715a7)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements.  See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership.  The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22#ifndef SYSTEM_STL_HASHMAP
23#define SYSTEM_STL_HASHMAP
24
25#ifdef HAVE_STL_INCLUDE_PATH
26	// TODO: use computed include file name
27	#include_next <unordered_map>
28#elif defined(_MSC_VER)
29	#include <../../VC/include/unordered_map>
30	#define STLP4_EMUBASE_NS ::std::tr1
31#else // fall back to boost/tr1
32	#include <boost/tr1/tr1/unordered_map>
33	#define STLP4_EMUBASE_NS ::boost
34#endif
35
36
37#ifndef NO_STLPORT4_EMULATION
38
39namespace std
40{
41#ifdef STLP4_EMUBASE_NS
42	using STLP4_EMUBASE_NS::hash;
43	using STLP4_EMUBASE_NS::unordered_map;
44	using STLP4_EMUBASE_NS::unordered_multimap;
45	#undef STLP4_EMUBASE_NS
46#endif
47
48
49template<
50	typename __K,
51	typename __T,
52	typename __H = hash<__K>,
53	typename __E = equal_to<__K>,
54	typename __A = allocator<pair<__K,__T> > >
55class hash_map
56:	public unordered_map<__K,__T,__H,__E,__A>
57{
58public:
59	typedef unordered_map<__K,__T,__H,__E,__A> _super;
60	typedef __T data_type;
61
62	hash_map( void) {}
63	hash_map( size_t n) : _super( n) {}
64
65#ifdef BOOST_TR1_UNORDERED_MAP_INCLUDED // workaround pre-BOOST_UNORDERED_USE_MOVE problem
66	// in derived classes the copy assignment operator can only be declared implicitly if
67	// its base class's assignment operator has the canonical signature.
68	// boost's assignment operators don't have this canonical signature when move-semantics are enabled
69	hash_map& operator=( const hash_map& r) { hash_map c(r); this->swap(c); return *this; }
70#endif
71
72	void resize( size_t n) { _super::rehash(n); }
73private:
74	// setting the hasher dynamically is not supported in the emulation!
75	hash_map( size_t, const __H&, const __E& rE=__E(), const __A& rA=__A()); // not implemented
76};
77
78template<
79	typename __K,
80	typename __T,
81	typename __H = hash<__K>,
82	typename __E = equal_to<__K>,
83	typename __A = allocator<pair<__K,__T> > >
84class hash_multimap
85:	public unordered_multimap<__K,__T,__H,__E,__A>
86{
87public:
88	typedef unordered_multimap<__K,__T,__H,__E,__A> _super;
89	typedef __T data_type;
90
91	hash_multimap( void) {}
92	hash_multimap( size_t n) : _super( n) {}
93
94#ifdef BOOST_TR1_UNORDERED_MAP_INCLUDED // workaround pre-BOOST_UNORDERED_USE_MOVE problem
95	// in derived classes the copy assignment operator can only be declared implicitly if
96	// its base class's assignment operator has the canonical signature.
97	// boost's assignment operators don't have this canonical signature when move-semantics are enabled
98	hash_multimap& operator=( const hash_multimap& r) { hash_multimap c(r); this->swap(c); return *this; }
99#endif
100
101	void resize( size_t n) { _super::rehash(n); }
102private:
103	// setting the hasher dynamically is not supported in the emulation!
104	hash_multimap( size_t, const __H&, const __E& rE=__E(), const __A& rA=__A()); // not implemented
105};
106
107} // namespace std
108
109#endif // NO_STLPORT4_EMULATION
110
111#endif
112
113