引用库更新
This commit is contained in:
parent
de11c25836
commit
765165c153
2 changed files with 30 additions and 12 deletions
|
@ -2,7 +2,7 @@
|
|||
* @Author: iR
|
||||
* @Date: 2022-03-11 16:44:46
|
||||
* @LastEditors: iR
|
||||
* @LastEditTime: 2022-03-12 12:30:44
|
||||
* @LastEditTime: 2022-03-12 12:49:04
|
||||
* @FilePath: \Code\inc\matrix.hpp
|
||||
* @Description:
|
||||
*
|
||||
|
@ -86,7 +86,23 @@ public:
|
|||
* @param {int} h
|
||||
* @return {*}
|
||||
*/
|
||||
T &at(int w, int h) { return _mat[h * _width + w]; }
|
||||
T &at(int w, int h)
|
||||
{
|
||||
double &ref = _mat->get(h * _width + w);
|
||||
return ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 只读引用访问
|
||||
* @param {int} w
|
||||
* @param {int} h
|
||||
* @return {*}
|
||||
*/
|
||||
const T &at(int w, int h) const
|
||||
{
|
||||
double &ref = _mat->get(h * _width + w);
|
||||
return ref;
|
||||
}
|
||||
|
||||
const int getWidth() const { return _width; }
|
||||
const int getHeight() const { return _height; }
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
* @Author: iR
|
||||
* @Date: 2022-03-11 16:47:31
|
||||
* @LastEditors: iR
|
||||
* @LastEditTime: 2022-03-12 12:20:35
|
||||
* @LastEditTime: 2022-03-12 12:49:25
|
||||
* @FilePath: \Code\inc\vector.hpp
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) 2022 by iR, All Rights Reserved.
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) 2022 by iR, All Rights Reserved.
|
||||
*/
|
||||
#ifndef _VECTOR_HPP_
|
||||
#define _VECTOR_HPP_
|
||||
|
@ -43,10 +43,10 @@ public:
|
|||
~Vector() { delete[] _v; }
|
||||
|
||||
//获取值
|
||||
T get(int a) const;
|
||||
T &get(int a);
|
||||
|
||||
//操作符重载
|
||||
T& operator[](int i);
|
||||
T &operator[](int i);
|
||||
|
||||
//某处更改为某值
|
||||
T put(int a, T value);
|
||||
|
@ -109,7 +109,7 @@ Vector<T>::Vector(int len, T value)
|
|||
}
|
||||
|
||||
template <class T>
|
||||
T Vector<T>::get(int a) const
|
||||
T &Vector<T>::get(int a)
|
||||
{
|
||||
|
||||
try
|
||||
|
@ -124,17 +124,19 @@ T Vector<T>::get(int a) const
|
|||
catch (const char *msg)
|
||||
{
|
||||
std::cout << msg;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T& Vector<T>::operator[](int a)
|
||||
T &Vector<T>::operator[](int a)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (a >= 0 && a < _used)
|
||||
return _v[a];
|
||||
{
|
||||
T &ref = _v[a];
|
||||
return ref;
|
||||
}
|
||||
else
|
||||
throw "Error: Request vercor data out of range!\n";
|
||||
}
|
||||
|
|
Reference in a new issue