File: example.h

package info (click to toggle)
cableswig 0.1.0%2Bcvs20111009-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 16,064 kB
  • sloc: cpp: 34,106; ansic: 32,676; yacc: 3,999; makefile: 3,800; python: 2,387; ruby: 2,063; lisp: 1,841; java: 1,817; tcl: 1,097; php: 908; ml: 804; perl: 686; cs: 206; sh: 153
file content (32 lines) | stat: -rw-r--r-- 509 bytes parent folder | download | duplicates (35)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* File : example.h */

// Some template definitions

template<class T> T max(T a, T b) { return  a>b ? a : b; }

template<class T> class vector {
  T *v;
  int sz;
 public:
  vector(int _sz) {
    v = new T[_sz];
    sz = _sz;
  }
  T &get(int index) {
    return v[index];
  }
  void set(int index, T &val) {
    v[index] = val;
  }
#ifdef SWIG
  %extend {
    T getitem(int index) {
      return self->get(index);
    }
    void setitem(int index, T val) {
      self->set(index,val);
    }
  }
#endif
};