/* This file contains a generic definition of std::deque along with
* some helper functions. Specific language modules should include
* this file to generate wrappers.
/* This macro defines all of the standard methods for a deque. This
is defined as a macro to simplify the task of specialization. For
template<> class deque<int> {
%define %std_deque_methods(T)
typedef const T& const_reference;
deque(unsigned int size, const T& value=T());
void assign(unsigned int n, const T& value);
unsigned int size() const;
unsigned int max_size() const;
void resize(unsigned int n, T c = T());
void push_front(const T& x);
void push_back(const T& x);
/* Some useful extensions */
const_reference getitem(int i) throw (std::out_of_range) {
int size = int(self->size());
throw std::out_of_range("deque index out of range");
void setitem(int i, const T& x) throw (std::out_of_range) {
int size = int(self->size());
throw std::out_of_range("deque index out of range");
void delitem(int i) throw (std::out_of_range) {
int size = int(self->size());
self->erase(self->begin()+i);
throw std::out_of_range("deque index out of range");
std::deque<T> getslice(int i, int j) {
int size = int(self->size());
std::copy(self->begin()+i,self->begin()+j,tmp.begin());
void setslice(int i, int j, const std::deque<T>& v) {
int size = int(self->size());
if (int(v.size()) == j-i) {
std::copy(v.begin(),v.end(),self->begin()+i);
self->erase(self->begin()+i,self->begin()+j);
self->insert(self->begin()+i+1,v.begin(),v.end());
self->insert(self->end(),v.begin(),v.end());
void delslice(int i, int j) {
int size = int(self->size());
self->erase(self->begin()+i,self->begin()+j);
template<class T> class deque {