aboutsummaryrefslogtreecommitdiffstats
path: root/gnu/lib/libg++/g++-include/intVec.hP
blob: e3838700251d11b46e5e060127a85a0012522d1b (plain) (blame)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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 */