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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
f0043eb7
Commit
f0043eb7
authored
Apr 20, 2018
by
Valentin Valls
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add swap to queues
parent
85086530
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
Cython/Includes/libcpp/queue.pxd
Cython/Includes/libcpp/queue.pxd
+5
-0
tests/run/cpp_stl_cpp11.pyx
tests/run/cpp_stl_cpp11.pyx
+32
-0
No files found.
Cython/Includes/libcpp/queue.pxd
View file @
f0043eb7
...
...
@@ -9,6 +9,9 @@ cdef extern from "<queue>" namespace "std" nogil:
void
pop
()
void
push
(
T
&
)
size_t
size
()
# C++11 methods
void
swap
(
queue
&
)
cdef
cppclass
priority_queue
[
T
]:
priority_queue
()
except
+
priority_queue
(
priority_queue
&
)
except
+
...
...
@@ -18,3 +21,5 @@ cdef extern from "<queue>" namespace "std" nogil:
void
push
(
T
&
)
size_t
size
()
T
&
top
()
# C++11 methods
void
swap
(
priority_queue
&
)
tests/run/cpp_stl_cpp11.pyx
View file @
f0043eb7
...
...
@@ -5,6 +5,8 @@
import
sys
from
libcpp.unordered_map
cimport
unordered_map
from
libcpp.vector
cimport
vector
from
libcpp.queue
cimport
queue
from
libcpp.queue
cimport
priority_queue
from
libcpp.vector
cimport
vector
from
libcpp.pair
cimport
pair
...
...
@@ -26,6 +28,36 @@ def test_vector_functionality():
return
"pass"
def
test_queue_functionality
():
"""
>>> test_queue_functionality()
'pass'
"""
cdef
:
queue
[
int
]
int_queue
=
queue
[
int
]()
queue
[
int
]
int_queue2
=
queue
[
int
]()
int_queue
.
push
(
77
)
int_queue
.
swap
(
int_queue2
)
assert
int_queue
.
size
()
==
0
assert
int_queue2
.
size
()
==
1
return
"pass"
def
test_priority_queue_functionality
():
"""
>>> test_priority_queue_functionality()
'pass'
"""
cdef
:
priority_queue
[
int
]
int_queue
=
priority_queue
[
int
]()
priority_queue
[
int
]
int_queue2
=
priority_queue
[
int
]()
int_queue
.
push
(
77
)
int_queue
.
swap
(
int_queue2
)
assert
int_queue
.
size
()
==
0
assert
int_queue2
.
size
()
==
1
return
"pass"
def
test_unordered_map_functionality
():
"""
>>> test_unordered_map_functionality()
...
...
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