-
Notifications
You must be signed in to change notification settings - Fork 0
/
array.h
48 lines (37 loc) · 1.05 KB
/
array.h
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
/*
* array.h
* Untitled
*
* Created by Ellie on 16/01/10.
* Copyright 2010 Ellie. All rights reserved.
*
*/
#ifndef BASIQUE_ARRAY_H
#define BASIQUE_ARRAY_H
#include <exception>
#include <utility>
#include <vector>
#include "variant.h"
namespace basic {
class Array;
}
class basic::Array {
public:
typedef std::pair<int, int> DimensionSpecification;
typedef std::vector<int> Index;
class BadDimensionSpecification : public std::exception { };
class IndexOutOfBounds : public std::exception { };
Array(const std::vector<DimensionSpecification> &);
~Array();
bool isValidIndex(const Index &) const;
const Variant &itemAt(const Index &) const;
const Variant &operator[](const Index &index) const { return itemAt(index); }
Variant &operator[](const Index &index) { return const_cast<Variant&>(itemAt(index)); }
private:
Array();
Array &operator=(const Array &);
std::vector<DimensionSpecification> m_dimensions;
std::vector<size_t> m_sizes;
std::vector<Variant> m_data;
};
#endif