source: trunk/src/emx/include/Attic/cpp/gen/intVec.hP@ 18

Last change on this file since 18 was 18, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.5 KB
Line 
1/* : light weight Vector: This will simply reuse code from */
2/* a int Vec, which was genclassed from the Vec libg++ class. */
3/* The classes generated from this file will all be derived classes */
4/* from class VoidVec or intVec. No .cc file is generated. So */
5/* it costs nothing to use these type-safe Vectors. Only member */
6/* functions needing type casting are re-defined. */
7/* */
8
9#ifndef _<T>Vec_h
10#define _<T>Vec_h 1
11
12#include "int.Vec.h"
13#include "<T>.defs.h"
14
15
16#ifndef _<T>_typedefs
17#define _<T>_typedefs 1
18typedef void (*<T>Procedure)(<T> );
19typedef <T> (*<T>Mapper)(<T> );
20typedef <T> (*<T>Combiner)(<T> , <T> );
21typedef int (*<T>Predicate)(<T> );
22typedef int (*<T>Comparator)(<T> , <T> );
23#endif
24
25class <T>Vec : public intVec
26{
27protected:
28 <T>Vec(int l, <T>* d) : (l, (int*) d) {};
29public:
30 <T>Vec() {};
31 <T>Vec(int l) : (l) {};
32 <T>Vec(int l, <T&> fill_value) : (l, fill_value) {};
33 <T>Vec(<T>Vec& v) : (v) {};
34 <T>Vec(intVec& v) {fake_copy(v, s, len);}
35 ~<T>Vec() {};
36
37 <T>Vec& operator = (<T>Vec& a)
38 {return (<T>Vec&) intVec::operator= (a);}
39 <T>Vec at(int from, int n) {return (<T>Vec) intVec::at(from, n);}
40
41 <T>& operator [] (int n) {return (<T>&)intVec::operator[] (n);}
42 <T>& elem(int n) {return (<T>&)intVec::elem(n);}
43
44 friend <T>Vec concat(<T>Vec& a, <T>Vec& b);
45 friend <T>Vec map(<T>Mapper f, <T>Vec & a);
46 friend <T>Vec merge(<T>Vec & a, <T>Vec & b, <T>Comparator f);
47 friend <T>Vec combine(<T>Combiner f, <T>Vec & a, <T>Vec & b);
48 friend <T>Vec reverse(<T>Vec& a);
49
50 void sort(<T>Comparator f);
51 void apply(<T>Procedure f);
52 <T> reduce(<T>Combiner f, <T> base);
53};
54
55inline <T>Vec concat(<T>Vec& a, <T>Vec& b)
56{return (<T>Vec)concat((intVec&)a, (intVec&)b);}
57
58inline <T>Vec map(<T>Mapper f, <T>Vec & a) {
59 return (<T>Vec)map((intMapper)f, (intVec&)a); }
60
61inline <T>Vec merge(<T>Vec & a, <T>Vec & b, <T>Comparator f) {
62 return (<T>Vec)merge((intVec&)a, (intVec&)b, (intComparator)f); }
63
64inline <T>Vec combine(<T>Combiner f, <T>Vec & a, <T>Vec & b) {
65 return (<T>Vec)combine((intCombiner)f, (intVec&)a, (intVec&)b); }
66
67inline <T>Vec reverse(<T>Vec& a) {
68 return (<T>Vec)reverse((intVec&)a);}
69
70inline void <T>Vec::sort(<T>Comparator f) {
71 intVec::sort((intComparator) f); }
72
73inline void <T>Vec::apply(<T>Procedure f) {
74 intVec::apply((intProcedure) f); }
75
76inline <T> <T>Vec::reduce(<T>Combiner f, <T> base) {
77 return (<T>)intVec::reduce((intCombiner)f, base);}
78
79#endif /* conditional include */
80
Note: See TracBrowser for help on using the repository browser.