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
0be3c6cc
Commit
0be3c6cc
authored
Sep 15, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement const-correct cypclass list without excessive use of 'mutable' qualifier
parent
9f69fd5e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
Cython/Includes/libcythonplus/list.pxd
Cython/Includes/libcythonplus/list.pxd
+9
-9
No files found.
Cython/Includes/libcythonplus/list.pxd
View file @
0be3c6cc
...
...
@@ -26,9 +26,9 @@ cdef extern from * nogil:
cdef
cypclass
cyplist
[
V
]:
ctypedef
V
value_type
ctypedef
vector
[
value_type
].
size_type
size_type
ctypedef
list_iterator_t
[
const
cyplist
[
V
],
vector
[
value_type
].
iterator
,
value_type
]
iterator
ctypedef
list_iterator_t
[
const
cyplist
[
V
],
vector
[
value_type
].
const_
iterator
,
value_type
]
iterator
mutable
vector
[
value_type
]
_elements
vector
[
value_type
]
_elements
mutable
atomic
[
int
]
_active_iterators
__init__
(
self
):
...
...
@@ -89,13 +89,13 @@ cdef cypclass cyplist[V]:
cyplist
[
V
]
__add__
(
self
,
const
cyplist
[
V
]
other
)
const
:
result
=
cyplist
[
V
]()
result
.
_elements
.
reserve
(
self
.
_elements
.
size
()
+
other
.
_elements
.
size
())
result
.
_elements
.
insert
(
result
.
_elements
.
end
(),
self
.
_elements
.
begin
(),
self
.
_elements
.
end
())
result
.
_elements
.
insert
(
result
.
_elements
.
end
(),
other
.
_elements
.
begin
(),
other
.
_elements
.
end
())
result
.
_elements
.
insert
(
result
.
_elements
.
end
(),
self
.
_elements
.
const_begin
(),
self
.
_elements
.
const_
end
())
result
.
_elements
.
insert
(
result
.
_elements
.
end
(),
other
.
_elements
.
const_begin
(),
other
.
_elements
.
const_
end
())
return
result
cyplist
[
V
]
__iadd__
(
self
,
const
cyplist
[
V
]
other
):
if
self
.
_active_iterators
==
0
:
self
.
_elements
.
insert
(
self
.
_elements
.
end
(),
other
.
_elements
.
begin
(),
other
.
_elements
.
end
())
self
.
_elements
.
insert
(
self
.
_elements
.
end
(),
other
.
_elements
.
const_begin
(),
other
.
_elements
.
const_
end
())
return
self
else
:
with
gil
:
...
...
@@ -105,7 +105,7 @@ cdef cypclass cyplist[V]:
result
=
cyplist
[
V
]()
result
.
_elements
.
reserve
(
self
.
_elements
.
size
()
*
n
)
for
i
in
range
(
n
):
result
.
_elements
.
insert
(
result
.
_elements
.
end
(),
self
.
_elements
.
begin
(),
self
.
_elements
.
end
())
result
.
_elements
.
insert
(
result
.
_elements
.
end
(),
self
.
_elements
.
const_begin
(),
self
.
_elements
.
const_
end
())
return
result
cyplist
[
V
]
__imul__
(
self
,
size_type
n
):
...
...
@@ -126,10 +126,10 @@ cdef cypclass cyplist[V]:
raise
RuntimeError
(
"Modifying a list with active iterators"
)
iterator
begin
(
self
)
const
:
return
iterator
(
self
.
_elements
.
begin
(),
self
)
return
iterator
(
self
.
_elements
.
const_
begin
(),
self
)
vector
[
value_type
].
iterator
end
(
self
)
const
:
return
self
.
_elements
.
end
()
vector
[
value_type
].
const_
iterator
end
(
self
)
const
:
return
self
.
_elements
.
const_
end
()
size_type
__len__
(
self
)
const
:
return
self
.
_elements
.
size
()
...
...
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