/* : light weight Vector: This will simply reuse code from */ /* a VoidP 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 "VoidP.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 VoidPVec { protected: Vec(int l, * d) : (l, (VoidP*) d) {}; public: Vec() {}; Vec(int l) : (l) {}; Vec(int l, fill_value) : (l, fill_value) {}; Vec(Vec& v) : (v) {}; Vec(VoidPVec& v) {fake_copy(v, s, len);} ~Vec() {}; Vec& operator = (Vec& a) {return (Vec&) VoidPVec::operator= (a);} Vec at(int from, int n) {return (Vec) VoidPVec::at(from, n);} & operator [] (int n) {return (&)VoidPVec::operator[] (n);} & elem(int n) {return (&)VoidPVec::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((VoidPVec&)a, (VoidPVec&)b);} inline Vec map(Mapper f, Vec & a) { return (Vec)map((VoidPMapper)f, (VoidPVec&)a); } inline Vec merge(Vec & a, Vec & b, Comparator f) { return (Vec)merge((VoidPVec&)a, (VoidPVec&)b, (VoidPComparator)f); } inline Vec combine(Combiner f, Vec & a, Vec & b) { return (Vec)combine((VoidPCombiner)f, (VoidPVec&)a, (VoidPVec&)b); } inline Vec reverse(Vec& a) { return (Vec)reverse((VoidPVec&)a);} inline void Vec::sort(Comparator f) { VoidPVec::sort((VoidPComparator) f); } inline void Vec::apply(Procedure f) { VoidPVec::apply((VoidPProcedure) f); } inline Vec::reduce(Combiner f, base) { return ()VoidPVec::reduce((VoidPCombiner)f, base);} #endif /* conditional include */