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

/trunk/Examples/python/template/example.h

#
C++ Header | 32 lines | 26 code | 4 blank | 2 comment | 0 complexity | f6ca43290440c94abb42f86124ec2d21 MD5 | raw file
 1/* File : example.h */
 2
 3// Some template definitions
 4
 5template<class T> T max(T a, T b) { return  a>b ? a : b; }
 6
 7template<class T> class vector {
 8  T *v;
 9  int sz;
10 public:
11  vector(int _sz) {
12    v = new T[_sz];
13    sz = _sz;
14  }
15  T &get(int index) {
16    return v[index];
17  }
18  void set(int index, T &val) {
19    v[index] = val;
20  }
21#ifdef SWIG
22  %extend {
23    T getitem(int index) {
24      return $self->get(index);
25    }
26    void setitem(int index, T val) {
27      $self->set(index,val);
28    }
29  }
30#endif
31};
32