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
e0814f76
Commit
e0814f76
authored
Oct 05, 2010
by
Lisandro Dalcin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes, additions and tests for libcpp.vector
parent
3cf1d712
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
8 deletions
+52
-8
Cython/Includes/libcpp/vector.pxd
Cython/Includes/libcpp/vector.pxd
+10
-2
tests/run/cpp_stl_vector.pyx
tests/run/cpp_stl_vector.pyx
+42
-6
No files found.
Cython/Includes/libcpp/vector.pxd
View file @
e0814f76
...
@@ -6,12 +6,20 @@ cdef extern from "<vector>" namespace "std":
...
@@ -6,12 +6,20 @@ cdef extern from "<vector>" namespace "std":
iterator
operator
--
()
iterator
operator
--
()
bint
operator
==
(
iterator
)
bint
operator
==
(
iterator
)
bint
operator
!=
(
iterator
)
bint
operator
!=
(
iterator
)
bint
operator
<
(
iterator
)
bint
operator
>
(
iterator
)
bint
operator
<=
(
iterator
)
bint
operator
>=
(
iterator
)
cppclass
reverse_iterator
:
cppclass
reverse_iterator
:
T
&
operator
*
()
T
&
operator
*
()
iterator
operator
++
()
iterator
operator
++
()
iterator
operator
--
()
iterator
operator
--
()
bint
operator
==
(
iterator
)
bint
operator
==
(
reverse_iterator
)
bint
operator
!=
(
iterator
)
bint
operator
!=
(
reverse_iterator
)
bint
operator
<
(
reverse_iterator
)
bint
operator
>
(
reverse_iterator
)
bint
operator
<=
(
reverse_iterator
)
bint
operator
>=
(
reverse_iterator
)
#cppclass const_iterator(iterator):
#cppclass const_iterator(iterator):
# pass
# pass
#cppclass const_reverse_iterator(reverse_iterator):
#cppclass const_reverse_iterator(reverse_iterator):
...
...
tests/run/cpp_stl_vector.pyx
View file @
e0814f76
from
cython.operator
cimport
dereference
as
d
from
cython.operator
cimport
dereference
as
d
from
cython.operator
cimport
preincrement
as
incr
cdef
extern
from
"<vector>"
namespace
"std"
:
from
libcpp.vector
cimport
vector
cdef
cppclass
vector
[
T
]:
void
push_back
(
T
)
size_t
size
()
T
&
operator
[](
size_t
)
def
simple_test
(
double
x
):
def
simple_test
(
double
x
):
"""
"""
...
@@ -71,3 +67,43 @@ def index_set_test(L):
...
@@ -71,3 +67,43 @@ def index_set_test(L):
return
d
(
v
)[
0
],
d
(
v
)[
v
.
size
()
-
1
]
return
d
(
v
)[
0
],
d
(
v
)[
v
.
size
()
-
1
]
finally
:
finally
:
del
v
del
v
def
iteration_test
(
L
):
"""
>>> iteration_test([1,2,4,8])
1
2
4
8
"""
try
:
v
=
new
vector
[
int
]()
for
a
in
L
:
v
.
push_back
(
a
)
it
=
v
.
begin
()
while
it
!=
v
.
end
():
a
=
d
(
it
)
incr
(
it
)
print
(
a
)
finally
:
del
v
def
reverse_iteration_test
(
L
):
"""
>>> reverse_iteration_test([1,2,4,8])
8
4
2
1
"""
try
:
v
=
new
vector
[
int
]()
for
a
in
L
:
v
.
push_back
(
a
)
it
=
v
.
rbegin
()
while
it
!=
v
.
rend
():
a
=
d
(
it
)
incr
(
it
)
print
(
a
)
finally
:
del
v
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