Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xavier Thompson
cython
Commits
21c34835
Commit
21c34835
authored
Jul 07, 2020
by
will
Committed by
Stefan Behnel
Jul 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing unordered_map template defaults (GH-3686)
parent
6e3c9562
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletion
+29
-1
Cython/Includes/libcpp/unordered_map.pxd
Cython/Includes/libcpp/unordered_map.pxd
+1
-1
tests/run/cpp_stl_cpp11.pyx
tests/run/cpp_stl_cpp11.pyx
+15
-0
tests/run/cpp_unordered_map_helper.h
tests/run/cpp_unordered_map_helper.h
+13
-0
No files found.
Cython/Includes/libcpp/unordered_map.pxd
View file @
21c34835
from
.utility
cimport
pair
from
.utility
cimport
pair
cdef
extern
from
"<unordered_map>"
namespace
"std"
nogil
:
cdef
extern
from
"<unordered_map>"
namespace
"std"
nogil
:
cdef
cppclass
unordered_map
[
T
,
U
]:
cdef
cppclass
unordered_map
[
T
,
U
,
HASH
=*
,
PRED
=*
,
ALLOCATOR
=*
]:
ctypedef
T
key_type
ctypedef
T
key_type
ctypedef
U
mapped_type
ctypedef
U
mapped_type
ctypedef
pair
[
const
T
,
U
]
value_type
ctypedef
pair
[
const
T
,
U
]
value_type
...
...
tests/run/cpp_stl_cpp11.pyx
View file @
21c34835
...
@@ -140,6 +140,11 @@ def test_unordered_set_functionality():
...
@@ -140,6 +140,11 @@ def test_unordered_set_functionality():
return
"pass"
return
"pass"
cdef
extern
from
"cpp_unordered_map_helper.h"
:
cdef
cppclass
IntVectorHash
:
pass
def
test_unordered_map_functionality
():
def
test_unordered_map_functionality
():
"""
"""
>>> test_unordered_map_functionality()
>>> test_unordered_map_functionality()
...
@@ -153,6 +158,8 @@ def test_unordered_map_functionality():
...
@@ -153,6 +158,8 @@ def test_unordered_map_functionality():
unordered_map
[
int
,
int
]
int_map2
unordered_map
[
int
,
int
]
int_map2
unordered_map
[
int
,
int
*
]
intptr_map
unordered_map
[
int
,
int
*
]
intptr_map
const
int
*
intptr
const
int
*
intptr
unordered_map
[
vector
[
int
],
int
,
IntVectorHash
]
int_vector_map
vector
[
int
]
intvec
assert
int_map
[
1
]
==
2
assert
int_map
[
1
]
==
2
assert
int_map
.
size
()
==
1
assert
int_map
.
size
()
==
1
assert
int_map
.
erase
(
1
)
==
1
# returns number of elements erased
assert
int_map
.
erase
(
1
)
==
1
# returns number of elements erased
...
@@ -183,4 +190,12 @@ def test_unordered_map_functionality():
...
@@ -183,4 +190,12 @@ def test_unordered_map_functionality():
intptr_map
[
0
]
=
NULL
intptr_map
[
0
]
=
NULL
intptr
=
intptr_map
.
const_at
(
0
)
intptr
=
intptr_map
.
const_at
(
0
)
intvec
=
[
1
,
2
]
int_vector_map
[
intvec
]
=
3
intvec
=
[
4
,
5
]
int_vector_map
[
intvec
]
=
6
assert
int_vector_map
[
intvec
]
==
6
intvec
=
[
1
,
2
]
assert
int_vector_map
[
intvec
]
==
3
return
"pass"
return
"pass"
tests/run/cpp_unordered_map_helper.h
0 → 100644
View file @
21c34835
#include <functional>
#include <vector>
struct
IntVectorHash
{
size_t
operator
()(
const
std
::
vector
<
int
>&
v
)
const
{
std
::
hash
<
int
>
hasher
;
size_t
seed
=
0
;
for
(
int
i
:
v
)
{
seed
^=
hasher
(
i
)
+
0x9e3779b9
+
(
seed
<<
6
)
+
(
seed
>>
2
);
}
return
seed
;
}
};
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