My own vector class.
More...
#include <myvector.h>
|
| | MyVector (const long long int n=0) |
| | Allocates a vector with n elements on the heap. More...
|
| |
| | MyVector (const MyVector &orig) |
| | Allocates a vector with the same elements as vector orig and copies its elements. More...
|
| |
| virtual | ~MyVector () |
| | Deallocates the heap memory. More...
|
| |
| MyVector & | operator= (MyVector const &orig) |
| | Reallocates the vector with the same elements as vector orig and copies its elements. More...
|
| |
| const long long int & | size () const |
| | Returns the number of elements. More...
|
| |
| double & | operator[] (const long long int i) |
| | Returns the value of element i. More...
|
| |
| const double & | operator[] (const long long int i) const |
| | Returns the value of element i. More...
|
| |
My own vector class.
The macro DEBUG switches the range check on/off.
Definition at line 10 of file myvector.h.
◆ MyVector() [1/2]
| MyVector::MyVector |
( |
const long long int |
n = 0 | ) |
|
Allocates a vector with n elements on the heap.
- Parameters
-
- Warning
- Throws an exception in case of insufficient memory on the heap.
Definition at line 8 of file myvector.cpp.
◆ MyVector() [2/2]
| MyVector::MyVector |
( |
const MyVector & |
orig | ) |
|
Allocates a vector with the same elements as vector orig and copies its elements.
- Parameters
-
- Warning
- Throws an exception in case of insufficient memory.
Definition at line 28 of file myvector.cpp.
◆ ~MyVector()
Deallocates the heap memory.
Definition at line 38 of file myvector.cpp.
◆ operator=()
Reallocates the vector with the same elements as vector orig and copies its elements.
- Parameters
-
- Warning
- Throws an exception in case of insufficient memory.
Definition at line 45 of file myvector.cpp.
◆ operator[]() [1/2]
| double& MyVector::operator[] |
( |
const long long int |
i | ) |
|
|
inline |
Returns the value of element i.
- Parameters
-
- Returns
- value
- Warning
- Throws an exception "OutOfRange" in case an invalid index
i.
Definition at line 64 of file myvector.h.
◆ operator[]() [2/2]
| const double& MyVector::operator[] |
( |
const long long int |
i | ) |
const |
|
inline |
Returns the value of element i.
- Parameters
-
- Returns
- value
- Warning
- Throws an exception "OutOfRange" in case an invalid index
i.
Definition at line 79 of file myvector.h.
◆ size()
| const long long int& MyVector::size |
( |
| ) |
const |
|
inline |
Returns the number of elements.
- Returns
- Number of elements
Definition at line 53 of file myvector.h.
◆ operator<<
| std::ostream& operator<< |
( |
std::ostream & |
s, |
|
|
MyVector const & |
orig |
|
) |
| |
|
friend |
Output of the vector orig.
- Parameters
-
| [in] | s | output stream |
| [in] | orig | vector |
- Warning
- Throws an exception in case of insufficient memory.
◆ length_
| long long int MyVector::length_ |
|
protected |
◆ val_
pointer to allocated memory
Definition at line 103 of file myvector.h.
The documentation for this class was generated from the following files: