-
Notifications
You must be signed in to change notification settings - Fork 0
/
VectorRef.h
52 lines (44 loc) · 1.77 KB
/
VectorRef.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
49
50
51
52
//
// Created by mfbut on 11/16/2019.
//
#ifndef ECS_36B_HOMEWORK_VECTORREF_H
#define ECS_36B_HOMEWORK_VECTORREF_H
#include <vector>
#include "BaseVector.h"
#include "ConstVectorRef.h"
namespace Matrix {
class Matrix;
class VectorRef : public ConstVectorRef, public BaseVector {
public:
//type tags
using value_type = BaseVector::value_type;
using reference = BaseVector::reference;
using const_reference = BaseVector::const_reference;
using pointer = BaseVector::pointer;
using const_pointer = BaseVector::const_pointer;
using difference_type = BaseVector::difference_type;
using iterator = BaseVector::iterator;
using const_iterator = BaseVector::const_iterator;
VectorRef() = delete;
virtual ~VectorRef() override = default;
//create a reference to the given vector
explicit VectorRef(BaseVector& orig);
explicit VectorRef(const ConstBaseVector& orig) = delete; // make extra sure this doesn't get created
//create a reference over the specified column in the given matrix
VectorRef(Matrix& matrix, int col);
VectorRef(const Matrix& matrix, int col) = delete; // make extra sure this doesn't get created
//set the value of each element that we refer to
//equal to the value at the corresponding position in rhs
VectorRef& operator=(const BaseVector& rhs);
//return the number of elements in the vector it refers to
virtual int size() const override;
//element access
virtual value_type& at(int index) override;
virtual const value_type& at(int index) const override;
virtual value_type& operator[](int index) override;
virtual const value_type& operator[](int index) const override;
// protected:
// std::vector<value_type> rawVector;
};
}
#endif //ECS_36B_HOMEWORK_VECTORREF_H