PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/li_std_list.i

#
Swig | 46 lines | 32 code | 14 blank | 0 comment | 0 complexity | 34a905ac3e9293ed42251961d43f9fd7 MD5 | raw file
 1%module li_std_list
 2
 3%include "std_list.i"
 4
 5%{
 6#include <algorithm>
 7#include <functional>
 8#include <numeric>
 9%}
10
11namespace std {
12    %template(IntList) list<int>;
13}
14
15%template(DoubleList) std::list<double>;
16
17%inline %{
18typedef float Real;
19%}
20
21namespace std {
22    %template(RealList) list<Real>;
23}
24
25%inline %{
26
27double average(std::list<int> v) {
28    return std::accumulate(v.begin(),v.end(),0.0)/v.size();
29}
30
31
32void halve_in_place(std::list<double>& v) {
33    std::transform(v.begin(),v.end(),v.begin(),
34                   std::bind2nd(std::divides<double>(),2.0));
35}
36
37struct Struct {
38  double num;
39  Struct() : num(0.0) {}
40  Struct(double d) : num(d) {}
41//  bool operator==(const Struct &other) { return (num == other.num); }
42};
43%}
44
45
46