~ubuntu-branches/ubuntu/maverick/swig1.3/maverick

« back to all changes in this revision

Viewing changes to Examples/test-suite/python/lib_std_vectora.i

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-09-01 18:35:55 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050901183555-eq59uwhq8b62e44c
Tags: 1.3.24-1ubuntu4
* Use php5-dev instead of php4-dev, to kick php4 out of main.
* Drop support for generation of pike bindings, as nothing uses it,
  and swig is the only thing keeping pike7.6 in main (Ubuntu #13796)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%module lib_std_vectora
2
 
 
3
 
%include std_vectora.i
4
 
 
5
 
 
6
 
%{
7
 
#include <algorithm>
8
 
#include <functional>
9
 
#include <numeric>
10
 
%}
11
 
 
12
 
 
13
 
%template(vector_i) std::vector<int, std::allocator<int> >;
14
 
 
15
 
%template(matrix_i) std::vector<std::vector<int,std::allocator<int> >,std::allocator<std::vector<int,std::allocator<int> > > >;
16
 
 
17
 
%inline 
18
 
{
19
 
  typedef 
20
 
    std::vector<std::vector<int,std::allocator<int> >,
21
 
                std::allocator<std::vector<int,std::allocator<int> > > >
22
 
    imatrix;
23
 
 
24
 
  std::vector<int> vident(const std::vector<int,std::allocator<int> >& v)
25
 
  {
26
 
    return v;
27
 
  }
28
 
 
29
 
  imatrix mident(const imatrix& v)
30
 
  {
31
 
    return v;
32
 
  }
33
 
}
34
 
 
35
 
 
36
 
%template(DoubleVector) std::vector<double, std::allocator<double> >;
37
 
 
38
 
%inline %{
39
 
typedef float Real;
40
 
%}
41
 
 
42
 
namespace std {
43
 
  %template(RealVector) vector<Real, std::allocator<Real> >;
44
 
}
45
 
 
46
 
%inline %{
47
 
 
48
 
double average(std::vector<int, std::allocator<int> > v) {
49
 
    return std::accumulate(v.begin(),v.end(),0.0)/v.size();
50
 
}
51
 
 
52
 
std::vector<Real,std::allocator<Real> >
53
 
half(const std::vector<Real,std::allocator<Real> >& v) {
54
 
    std::vector<Real> w(v);
55
 
    for (unsigned int i=0; i<w.size(); i++)
56
 
        w[i] /= 2.0;
57
 
    return w;
58
 
}
59
 
 
60
 
%}
61
 
 
62
 
%template(IntPtrVector) std::vector<int *,std::allocator<int *> >;
63
 
 
64
 
 
65