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>
82 get_slice(Container& container, index_type from, index_type to)
85 return object(Container());
86 return object(Container(container.begin()+from, container.begin()+to));
90 set_item(Container& container, index_type i, data_type
const& v)
97 index_type to, data_type
const& v)
103 container.erase(container.begin()+from, container.begin()+to);
104 container.insert(container.begin()+from, v);
108 template <
class Iter>
111 index_type to, Iter first, Iter last)
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();
145 contains(Container& container, key_type
const& key)
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();
192 append(Container& container, data_type
const& v)
194 container.push_back(v);
197 template <
class Iter>
199 extend(Container& container, Iter first, Iter last)
201 container.insert(container.end(), first, last);
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();
235 std::vector<data_type> temp;
237 DerivedPolicies::extend(container, temp.begin(), temp.end());
243 #endif // VECTOR_INDEXING_SUITE_JDG20036_HPP static void extension_def(Class &cl)
static void delete_slice(Container &container, index_type from, index_type to)
static void set_item(Container &container, index_type i, data_type const &v)
Container::size_type size_type
static void append(Container &container, data_type const &v)
Container::size_type index_type
Container::difference_type difference_type
void extend_container(Container &container, object l)
static void delete_item(Container &container, index_type i)
Container::value_type key_type
static void set_slice(Container &container, index_type from, index_type to, data_type const &v)
static void base_extend(Container &container, object v)
static index_type convert_index(Container &container, PyObject *i_)
static size_t size(Container &container)
static index_type get_max_index(Container &container)
static bool contains(Container &container, key_type const &key)
static object get_slice(Container &container, index_type from, index_type to)
static mpl::if_< is_class< data_type >, data_type &, data_type >::type get_item(Container &container, index_type i)
static void base_append(Container &container, object v)
static index_type get_min_index(Container &container)
static bool compare_index(Container &container, index_type a, index_type b)
Container::value_type data_type
static void extend(Container &container, Iter first, Iter last)
static void set_slice(Container &container, index_type from, index_type to, Iter first, Iter last)