Commit 2ef200bd authored by Robert Bradshaw's avatar Robert Bradshaw

Convert stl map conversion to take const ref.

parent 770acb7d
...@@ -8,14 +8,18 @@ cdef extern from "<map>" namespace "std" nogil: ...@@ -8,14 +8,18 @@ cdef extern from "<map>" namespace "std" nogil:
iterator operator--() iterator operator--()
bint operator==(iterator) bint operator==(iterator)
bint operator!=(iterator) bint operator!=(iterator)
cppclass const_iterator:
pair[const T, U]& operator*()
const_iterator operator++()
const_iterator operator--()
bint operator==(const_iterator)
bint operator!=(const_iterator)
cppclass reverse_iterator: cppclass reverse_iterator:
pair[T, U]& operator*() pair[T, U]& operator*()
iterator operator++() iterator operator++()
iterator operator--() iterator operator--()
bint operator==(reverse_iterator) bint operator==(reverse_iterator)
bint operator!=(reverse_iterator) bint operator!=(reverse_iterator)
#cppclass const_iterator(iterator):
# pass
#cppclass const_reverse_iterator(reverse_iterator): #cppclass const_reverse_iterator(reverse_iterator):
# pass # pass
map() except + map() except +
...@@ -31,19 +35,19 @@ cdef extern from "<map>" namespace "std" nogil: ...@@ -31,19 +35,19 @@ cdef extern from "<map>" namespace "std" nogil:
bint operator>=(map&, map&) bint operator>=(map&, map&)
U& at(T&) U& at(T&)
iterator begin() iterator begin()
#const_iterator begin() const_iterator const_begin "begin" ()
void clear() void clear()
size_t count(T&) size_t count(T&)
bint empty() bint empty()
iterator end() iterator end()
#const_iterator end() const_iterator const_end "end" ()
pair[iterator, iterator] equal_range(T&) pair[iterator, iterator] equal_range(T&)
#pair[const_iterator, const_iterator] equal_range(key_type&) #pair[const_iterator, const_iterator] equal_range(key_type&)
void erase(iterator) void erase(iterator)
void erase(iterator, iterator) void erase(iterator, iterator)
size_t erase(T&) size_t erase(T&)
iterator find(T&) iterator find(T&)
#const_iterator find(key_type&) const_iterator const_find "find" (T&)
pair[iterator, bint] insert(pair[T, U]) # XXX pair[T,U]& pair[iterator, bint] insert(pair[T, U]) # XXX pair[T,U]&
iterator insert(iterator, pair[T, U]) # XXX pair[T,U]& iterator insert(iterator, pair[T, U]) # XXX pair[T,U]&
#void insert(input_iterator, input_iterator) #void insert(input_iterator, input_iterator)
......
...@@ -213,18 +213,18 @@ cdef extern from *: ...@@ -213,18 +213,18 @@ cdef extern from *:
cppclass value_type: cppclass value_type:
T first T first
U second U second
cppclass iterator: cppclass const_iterator:
value_type& operator*() value_type& operator*()
iterator operator++() const_iterator operator++()
bint operator!=(iterator) bint operator!=(const_iterator)
iterator begin() const_iterator begin()
iterator end() const_iterator end()
@cname("{{cname}}") @cname("{{cname}}")
cdef object {{cname}}(map[X,Y] s): cdef object {{cname}}(const map[X,Y]& s):
o = {} o = {}
cdef map[X,Y].value_type *key_value cdef const map[X,Y].value_type *key_value
cdef map[X,Y].iterator iter = s.begin() cdef map[X,Y].const_iterator iter = s.begin()
while iter != s.end(): while iter != s.end():
key_value = &cython.operator.dereference(iter) key_value = &cython.operator.dereference(iter)
o[X_to_py(key_value.first)] = Y_to_py(key_value.second) o[X_to_py(key_value.first)] = Y_to_py(key_value.second)
......
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