6 #ifndef VECTOR_INDEXING_SUITE_JDG20036_HPP
7 # define VECTOR_INDEXING_SUITE_JDG20036_HPP
11 # include <boost/python/iterator.hpp>
13 namespace boost {
namespace python {
16 template <
class Container,
bool NoProxy,
class DerivedPolicies>
21 template <
class Container,
bool NoProxy>
24 NoProxy, final_vector_derived_policies<Container, NoProxy> > {};
54 typedef typename Container::value_type
key_type;
59 template <
class Class>
64 .def(
"append", &base_append)
65 .def(
"push_back", &base_append)
66 .def(
"extend", &base_extend)
85 return object(Container());
86 return object(Container(container.begin()+from, container.begin()+to));
103 container.erase(container.begin()+from, container.begin()+to);
104 container.insert(container.begin()+from,
v);
108 template <
class Iter>
114 container.insert(container.begin()+from, first, last);
117 container.erase(container.begin()+from, container.begin()+to);
118 container.insert(container.begin()+from, first, last);
125 container.erase(container.begin()+i);
135 container.erase(container.begin()+from, container.begin()+to);
141 return container.size();
147 return std::find(container.begin(), container.end(), key)
160 return container.size();
177 index += DerivedPolicies::size(container);
178 if (index >=
long(container.size()) || index < 0)
180 PyErr_SetString(PyExc_IndexError,
"Index out of range");
181 throw_error_already_set();
186 PyErr_SetString(PyExc_TypeError,
"Invalid index type");
187 throw_error_already_set();
194 container.push_back(v);
197 template <
class Iter>
199 extend(Container& container, Iter first, Iter last)
201 container.insert(container.end(), first, last);
207 base_append(Container& container,
object v)
209 extract<data_type&> elem(v);
213 DerivedPolicies::append(container, elem());
218 extract<data_type> elem(v);
221 DerivedPolicies::append(container, elem());
225 PyErr_SetString(PyExc_TypeError,
226 "Attempting to append an invalid type");
227 throw_error_already_set();
233 base_extend(Container& container,
object v)
235 std::vector<data_type> temp;
237 DerivedPolicies::extend(container, temp.begin(), temp.end());
243 #endif // VECTOR_INDEXING_SUITE_JDG20036_HPP