Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
9f841148
Commit
9f841148
authored
8 years ago
by
Jisi Liu
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1520 from pherl/hashmapvs2008
Bridge vs2008 hashmaps.
parents
f9fd4509
dbdf6d90
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
3 deletions
+55
-3
hash.h
src/google/protobuf/stubs/hash.h
+55
-3
No files found.
src/google/protobuf/stubs/hash.h
100755 → 100644
View file @
9f841148
...
...
@@ -108,8 +108,13 @@
# define GOOGLE_PROTOBUF_HAS_CXX11_HASH
# define GOOGLE_PROTOBUF_HASH_COMPARE std::hash_compare
# elif _MSC_VER >= 1500 // Since Visual Studio 2008
# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP
# undef GOOGLE_PROTOBUF_HAVE_HASH_SET
# define GOOGLE_PROTOBUF_HASH_NAMESPACE stdext
# include <hash_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
# include <hash_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare
# define GOOGLE_PROTOBUF_CONTAINERS_NEED_HASH_COMPARE
# elif _MSC_VER >= 1310
# define GOOGLE_PROTOBUF_HASH_NAMESPACE stdext
# include <hash_map>
...
...
@@ -247,6 +252,52 @@ template <>
struct
hash
<
const
char
*>
:
public
GOOGLE_PROTOBUF_HASH_COMPARE
<
const
char
*
,
CstringLess
>
{};
#ifdef GOOGLE_PROTOBUF_CONTAINERS_NEED_HASH_COMPARE
template
<
typename
Key
,
typename
HashFcn
,
typename
EqualKey
>
struct
InternalHashCompare
:
public
GOOGLE_PROTOBUF_HASH_COMPARE
<
Key
>
{
InternalHashCompare
()
{}
InternalHashCompare
(
HashFcn
hashfcn
,
EqualKey
equalkey
)
:
hashfcn_
(
hashfcn
),
equalkey_
(
equalkey
)
{}
size_t
operator
()(
const
Key
&
key
)
const
{
return
hashfcn_
(
key
);
}
bool
operator
()(
const
Key
&
key1
,
const
Key
&
key2
)
const
{
return
!
equalkey_
(
key1
,
key2
);
}
HashFcn
hashfcn_
;
EqualKey
equalkey_
;
};
template
<
typename
Key
,
typename
Data
,
typename
HashFcn
=
hash
<
Key
>
,
typename
EqualKey
=
std
::
equal_to
<
Key
>
,
typename
Alloc
=
std
::
allocator
<
std
::
pair
<
const
Key
,
Data
>
>
>
class
hash_map
:
public
GOOGLE_PROTOBUF_HASH_NAMESPACE
::
GOOGLE_PROTOBUF_HASH_MAP_CLASS
<
Key
,
Data
,
InternalHashCompare
<
Key
,
HashFcn
,
EqualKey
>
,
Alloc
>
{
typedef
GOOGLE_PROTOBUF_HASH_NAMESPACE
::
GOOGLE_PROTOBUF_HASH_MAP_CLASS
<
Key
,
Data
,
InternalHashCompare
<
Key
,
HashFcn
,
EqualKey
>
,
Alloc
>
BaseClass
;
public
:
hash_map
(
int
a
=
0
,
const
HashFcn
&
b
=
HashFcn
(),
const
EqualKey
&
c
=
EqualKey
(),
const
Alloc
&
d
=
Alloc
())
:
BaseClass
(
InternalHashCompare
<
Key
,
HashFcn
,
EqualKey
>
(
b
,
c
),
d
)
{}
HashFcn
hash_function
()
const
{
return
HashFcn
();
}
};
template
<
typename
Key
,
typename
HashFcn
=
hash
<
Key
>
,
typename
EqualKey
=
std
::
equal_to
<
Key
>
>
class
hash_set
:
public
GOOGLE_PROTOBUF_HASH_NAMESPACE
::
GOOGLE_PROTOBUF_HASH_SET_CLASS
<
Key
,
InternalHashCompare
<
Key
,
HashFcn
,
EqualKey
>
>
{
public
:
hash_set
(
int
=
0
)
{}
HashFcn
hash_function
()
const
{
return
HashFcn
();
}
};
#else // GOOGLE_PROTOBUF_CONTAINERS_NEED_HASH_COMPARE
template
<
typename
Key
,
typename
Data
,
typename
HashFcn
=
hash
<
Key
>
,
typename
EqualKey
=
std
::
equal_to
<
Key
>
,
...
...
@@ -275,8 +326,9 @@ class hash_set
HashFcn
hash_function
()
const
{
return
HashFcn
();
}
};
#endif // GOOGLE_PROTOBUF_CONTAINERS_NEED_HASH_COMPARE
#else
#else
// defined(_MSC_VER) && !defined(_STLPORT_VERSION)
template
<
typename
Key
>
struct
hash
:
public
GOOGLE_PROTOBUF_HASH_NAMESPACE
::
hash
<
Key
>
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment