-
Notifications
You must be signed in to change notification settings - Fork 0
/
Array.hpp
45 lines (37 loc) · 1.42 KB
/
Array.hpp
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
// Array.hpp
//
// Array class. It uses an ArrayStructure for the actual storage.
// This class acts like a kind of adapter class since it defines a common
// interface for different array structures like normal arrays and
// sparse arrays. The array structure to use is given as template argument.
//
// (C) Datasim Component Technology 1999-2006
#ifndef Array_hpp
#define Array_hpp
#include "ArrayStructure.hpp"
#include "FullArray.cpp"
// Default structure is FullArray with default allocator. Default integral type is int.
template <class V, class I=int, class S=FullArray<V> >
class Array
{
private:
S m_structure; // The array structure
I m_start; // The start index
public:
// Constructors & destructor
Array(); // Default constructor
Array(I size); // Constructor with size. Start index=1.
Array(I size, I start); // Constructor with size & start index
Array(I size, I start, const V& value); // Size, start and value
Array(const Array<V, I, S>& source); // Copy constructor
virtual ~Array(); // Destructor
// Selectors
I MinIndex() const; // Return the minimum index
I MaxIndex() const; // Return the maximum index
I Size() const; // The size of the array
// Operators
virtual V& operator [] (I index); // Subscripting operator
virtual const V& operator [] (I index) const; // Subscripting operator
Array<V, I, S>& operator = (const Array<V, I, S>& source);
};
#endif // Array_hpp