annotate lib/swig/swigwin-2.0.11/Lib/std/_std_deque.i @ 1980:c1c74df0a33e

changing most of auto types to their actual types
author Grumpy7
date Wed, 30 Oct 2013 00:47:37 -0700
parents b3009adc0e2f
children
rev   line source
1899
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
1 /* -----------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
2 * _std_deque.i
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
3 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
4 * This file contains a generic definition of std::deque along with
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
5 * some helper functions. Specific language modules should include
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
6 * this file to generate wrappers.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
7 * ----------------------------------------------------------------------------- */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
8
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
9 %include <std_except.i>
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
10
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
11 %{
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
12 #include <deque>
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
13 #include <stdexcept>
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
14 %}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
15
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
16
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
17 /* This macro defines all of the standard methods for a deque. This
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
18 is defined as a macro to simplify the task of specialization. For
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
19 example,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
20
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
21 template<> class deque<int> {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
22 public:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
23 %std_deque_methods(int);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
24 };
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
25 */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
26
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
27 %define %std_deque_methods_noempty(T)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
28 typedef size_t size_type;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
29 typedef ptrdiff_t difference_type;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
30 typedef T value_type;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
31 typedef value_type* pointer;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
32 typedef const value_type* const_pointer;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
33 typedef value_type& reference;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
34 typedef const value_type& const_reference;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
35
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
36 deque();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
37 deque(unsigned int size, const T& value=T());
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
38 deque(const deque<T> &);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
39 ~deque();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
40
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
41 void assign(unsigned int n, const T& value);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
42 void swap(deque<T> &x);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
43 unsigned int size() const;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
44 unsigned int max_size() const;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
45 void resize(unsigned int n, T c = T());
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
46 const_reference front();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
47 const_reference back();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
48 void push_front(const T& x);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
49 void push_back(const T& x);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
50 void pop_front();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
51 void pop_back();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
52 void clear();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
53
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
54 /* Some useful extensions */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
55 %extend {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
56 const_reference getitem(int i) throw (std::out_of_range) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
57 int size = int(self->size());
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
58 if (i<0) i += size;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
59 if (i>=0 && i<size)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
60 return (*self)[i];
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
61 else
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
62 throw std::out_of_range("deque index out of range");
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
63 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
64 void setitem(int i, const T& x) throw (std::out_of_range) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
65 int size = int(self->size());
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
66 if (i<0) i+= size;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
67 if (i>=0 && i<size)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
68 (*self)[i] = x;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
69 else
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
70 throw std::out_of_range("deque index out of range");
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
71 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
72 void delitem(int i) throw (std::out_of_range) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
73 int size = int(self->size());
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
74 if (i<0) i+= size;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
75 if (i>=0 && i<size) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
76 self->erase(self->begin()+i);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
77 } else {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
78 throw std::out_of_range("deque index out of range");
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
79 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
80 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
81 std::deque<T> getslice(int i, int j) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
82 int size = int(self->size());
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
83 if (i<0) i = size+i;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
84 if (j<0) j = size+j;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
85 if (i<0) i = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
86 if (j>size) j = size;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
87 std::deque<T > tmp(j-i);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
88 std::copy(self->begin()+i,self->begin()+j,tmp.begin());
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
89 return tmp;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
90 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
91 void setslice(int i, int j, const std::deque<T>& v) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
92 int size = int(self->size());
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
93 if (i<0) i = size+i;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
94 if (j<0) j = size+j;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
95 if (i<0) i = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
96 if (j>size) j = size;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
97 if (int(v.size()) == j-i) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
98 std::copy(v.begin(),v.end(),self->begin()+i);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
99 } else {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
100 self->erase(self->begin()+i,self->begin()+j);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
101 if (i+1 <= size)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
102 self->insert(self->begin()+i+1,v.begin(),v.end());
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
103 else
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
104 self->insert(self->end(),v.begin(),v.end());
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
105 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
106 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
107 void delslice(int i, int j) {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
108 int size = int(self->size());
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
109 if (i<0) i = size+i;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
110 if (j<0) j = size+j;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
111 if (i<0) i = 0;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
112 if (j>size) j = size;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
113 self->erase(self->begin()+i,self->begin()+j);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
114 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
115 };
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
116 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
117
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
118 #ifdef SWIGPHP
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
119 %define %std_deque_methods(T)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
120 %extend {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
121 bool is_empty() const {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
122 return self->empty();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
123 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
124 };
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
125 %std_deque_methods_noempty(T)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
126 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
127 #else
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
128 %define %std_deque_methods(T)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
129 bool empty() const;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
130 %std_deque_methods_noempty(T)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
131 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
132 #endif
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
133
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
134 namespace std {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
135 template<class T> class deque {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
136 public:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
137 %std_deque_methods(T);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
138 };
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
139 }