Commit f0043eb7 authored by Valentin Valls's avatar Valentin Valls

Add swap to queues

parent 85086530
......@@ -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&)
......@@ -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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment