diff options
Diffstat (limited to 'gnu/lib/libg++/g++-include/intVec.hP')
-rw-r--r-- | gnu/lib/libg++/g++-include/intVec.hP | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/gnu/lib/libg++/g++-include/intVec.hP b/gnu/lib/libg++/g++-include/intVec.hP new file mode 100644 index 000000000000..e3838700251d --- /dev/null +++ b/gnu/lib/libg++/g++-include/intVec.hP @@ -0,0 +1,80 @@ +/* : light weight Vector: This will simply reuse code from */ +/* a int Vec, which was genclassed from the Vec libg++ class. */ +/* The classes generated from this file will all be derived classes */ +/* from class VoidVec or intVec. No .cc file is generated. So */ +/* it costs nothing to use these type-safe Vectors. Only member */ +/* functions needing type casting are re-defined. */ +/* */ + +#ifndef _<T>Vec_h +#define _<T>Vec_h 1 + +#include "int.Vec.h" +#include "<T>.defs.h" + + +#ifndef _<T>_typedefs +#define _<T>_typedefs 1 +typedef void (*<T>Procedure)(<T> ); +typedef <T> (*<T>Mapper)(<T> ); +typedef <T> (*<T>Combiner)(<T> , <T> ); +typedef int (*<T>Predicate)(<T> ); +typedef int (*<T>Comparator)(<T> , <T> ); +#endif + +class <T>Vec : public intVec +{ +protected: + <T>Vec(int l, <T>* d) : (l, (int*) d) {}; +public: + <T>Vec() {}; + <T>Vec(int l) : (l) {}; + <T>Vec(int l, <T&> fill_value) : (l, fill_value) {}; + <T>Vec(<T>Vec& v) : (v) {}; + <T>Vec(intVec& v) {fake_copy(v, s, len);} + ~<T>Vec() {}; + + <T>Vec& operator = (<T>Vec& a) + {return (<T>Vec&) intVec::operator= (a);} + <T>Vec at(int from, int n) {return (<T>Vec) intVec::at(from, n);} + + <T>& operator [] (int n) {return (<T>&)intVec::operator[] (n);} + <T>& elem(int n) {return (<T>&)intVec::elem(n);} + + friend <T>Vec concat(<T>Vec& a, <T>Vec& b); + friend <T>Vec map(<T>Mapper f, <T>Vec & a); + friend <T>Vec merge(<T>Vec & a, <T>Vec & b, <T>Comparator f); + friend <T>Vec combine(<T>Combiner f, <T>Vec & a, <T>Vec & b); + friend <T>Vec reverse(<T>Vec& a); + + void sort(<T>Comparator f); + void apply(<T>Procedure f); + <T> reduce(<T>Combiner f, <T> base); +}; + +inline <T>Vec concat(<T>Vec& a, <T>Vec& b) +{return (<T>Vec)concat((intVec&)a, (intVec&)b);} + +inline <T>Vec map(<T>Mapper f, <T>Vec & a) { + return (<T>Vec)map((intMapper)f, (intVec&)a); } + +inline <T>Vec merge(<T>Vec & a, <T>Vec & b, <T>Comparator f) { + return (<T>Vec)merge((intVec&)a, (intVec&)b, (intComparator)f); } + +inline <T>Vec combine(<T>Combiner f, <T>Vec & a, <T>Vec & b) { + return (<T>Vec)combine((intCombiner)f, (intVec&)a, (intVec&)b); } + +inline <T>Vec reverse(<T>Vec& a) { + return (<T>Vec)reverse((intVec&)a);} + +inline void <T>Vec::sort(<T>Comparator f) { + intVec::sort((intComparator) f); } + +inline void <T>Vec::apply(<T>Procedure f) { + intVec::apply((intProcedure) f); } + +inline <T> <T>Vec::reduce(<T>Combiner f, <T> base) { + return (<T>)intVec::reduce((intCombiner)f, base);} + +#endif /* conditional include */ + |