1 %module li_std_deque
2 
3 %include "std_deque.i"
4 
5 %{
6 #include <algorithm>
7 #include <functional>
8 #include <numeric>
9 %}
10 
11 namespace std {
12     %template(IntDeque) deque<int>;
13 }
14 
15 %template(DoubleDeque) std::deque<double>;
16 
17 %inline %{
18 typedef float Real;
19 %}
20 
21 namespace std {
22     %template(RealDeque) deque<Real>;
23 }
24 
25 %inline %{
26 
average(std::deque<int> v)27 double average(std::deque<int> v) {
28     return std::accumulate(v.begin(),v.end(),0.0)/v.size();
29 }
30 
half(const std::deque<float> & v)31 std::deque<float> half(const std::deque<float>& v) {
32     std::deque<float> w(v);
33     for (unsigned int i=0; i<w.size(); i++)
34         w[i] /= 2.0;
35     return w;
36 }
37 
halve_in_place(std::deque<double> & v)38 void halve_in_place(std::deque<double>& v) {
39     for (std::deque<double>::iterator it = v.begin(); it != v.end(); ++it)
40         *it /= 2.0;
41 }
42 
43 %}
44 
45 
46 
47 
48