LRAUV  revA
I1D.h
Go to the documentation of this file.
1 /*
2  * I1D.h
3  *
4  * Interface for classes that contain 1D pointer-based matrices.
5  * Contains static methods for creating and deleting 1D pointer-based matrices.
6  *
7  * Created on: Feb 7, 2014
8  * Author: godin
9  */
10 
11 #ifndef I1D_H_
12 #define I1D_H_
13 
14 #include <stddef.h>
15 
16 template <typename T>
17 class I1D
18 {
19 public:
20 
21  virtual ~I1D() {};
22 
23  virtual T* getPtr1d() = 0;
24  virtual int getM() const = 0;
25 
26  // Allocates a 1D pointer array of size m*n
27  // If extra is true, and extra entry is allocated at array[m][0];
28  static T* New1D( int m, bool extra = false )
29  {
30  T* array = NULL;
31  if( m > 0 )
32  {
33  array = new T[m + ( extra ? 1 : 0 ) ];
34 
35  }
36  return array;
37  }
38 
39  static void Delete1D( T* array )
40  {
41  if( NULL != array )
42  {
43  delete[] array;
44  }
45  }
46 
47 protected:
48  // Protected constructors for abstract base class
49  I1D() {}
50  I1D( const I1D& ) {}
51 
52 };
53 
54 ;
55 
56 #endif /* I1D_H_ */
static void Delete1D(T *array)
Definition: I1D.h:39
I1D(const I1D &)
Definition: I1D.h:50
Definition: I1D.h:17
I1D()
Definition: I1D.h:49
virtual ~I1D()
Definition: I1D.h:21
static T * New1D(int m, bool extra=false)
Definition: I1D.h:28
virtual T * getPtr1d()=0
virtual int getM() const =0