/* : 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 _Vec_h #define _Vec_h 1 #include "int.Vec.h" #include ".defs.h" #ifndef __typedefs #define __typedefs 1 typedef void (*Procedure)( ); typedef (*Mapper)( ); typedef (*Combiner)( , ); typedef int (*Predicate)( ); typedef int (*Comparator)( , ); #endif class Vec : public intVec { protected: Vec(int l, * d) : (l, (int*) d) {}; public: Vec() {}; Vec(int l) : (l) {}; Vec(int l, fill_value) : (l, fill_value) {}; Vec(Vec& v) : (v) {}; Vec(intVec& v) {fake_copy(v, s, len);} ~Vec() {}; Vec& operator = (Vec& a) {return (Vec&) intVec::operator= (a);} Vec at(int from, int n) {return (Vec) intVec::at(from, n);} & operator [] (int n) {return (&)intVec::operator[] (n);} & elem(int n) {return (&)intVec::elem(n);} friend Vec concat(Vec& a, Vec& b); friend Vec map(Mapper f, Vec & a); friend Vec merge(Vec & a, Vec & b, Comparator f); friend Vec combine(Combiner f, Vec & a, Vec & b); friend Vec reverse(Vec& a); void sort(Comparator f); void apply(Procedure f); reduce(Combiner f, base); }; inline Vec concat(Vec& a, Vec& b) {return (Vec)concat((intVec&)a, (intVec&)b);} inline Vec map(Mapper f, Vec & a) { return (Vec)map((intMapper)f, (intVec&)a); } inline Vec merge(Vec & a, Vec & b, Comparator f) { return (Vec)merge((intVec&)a, (intVec&)b, (intComparator)f); } inline Vec combine(Combiner f, Vec & a, Vec & b) { return (Vec)combine((intCombiner)f, (intVec&)a, (intVec&)b); } inline Vec reverse(Vec& a) { return (Vec)reverse((intVec&)a);} inline void Vec::sort(Comparator f) { intVec::sort((intComparator) f); } inline void Vec::apply(Procedure f) { intVec::apply((intProcedure) f); } inline Vec::reduce(Combiner f, base) { return ()intVec::reduce((intCombiner)f, base);} #endif /* conditional include */