什么是 C++ 中的映射函数
what are mapping functions in c++?
我搜索了n维数组中的映射函数,但没有找到特定的答案。我想知道多维数组是如何工作的 i c++?在 N 维数组中查找特定索引处的元素的一般公式是什么?
给定一个 k 维数组arr[n,1][n,2][n,3]...[n,k]
,元素在 arr[x,1][x,2][x,3]...[x,k]
处的索引是 x,k + x,(k-1) * n,k + x,(k-2) * n,k * n,(k-1) + ... + x,1 * n,2 * n,3 * ... * n,k
。
Redefine 运算符 [] 返回带有重新定义的 oprator[] 的对象
template<T>
struct Matrix {
// initialization and access checking skipped
typedef std::vector<T> t_raw;
typedef std::vector<t_raw> t_col;
t_col m_mat;
struct Idx {
Matrix* mat;
size_t row;
T& operator[](size_t col) {
return this->mat->m_mat[ this->row ][col];
};
}
Idx operator[](size_t row) {
Idx idx;
idx.mat = this;
idx.row = row;
return idx;
};
friend class Idx;
};
Matrix<int> m;
m[1][2] = 5;
相关文章:
- 将函数类成员映射到类本身内部
- 使用std::函数映射对象方法
- 内联映射初始化的动态atexit析构函数崩溃
- 从函数角度看ID到文件路径的内部与外部映射
- C++ 已停止工作静态映射函数
- C++中的映射函数
- 从 lambda 内部返回 C++11 中的 lambda 类型(平面映射函数)
- 如何将值传递给MFC消息映射函数on_command
- 创建高阶映射函数时,应该使用指针、引用或值
- 什么是 C++ 中的映射函数
- 使用变量参数映射函数并通过字符串 c++ 调用
- OpenCV 3.1 重映射函数类型值错误
- std::映射函数指针
- 在一个简单的映射函数中避免IF
- 相当于使用lambda的python映射函数
- 更好的数据结构映射函数与多个参数(键)
- 使用 c++11 构造映射函数
- 反向映射函数关系(c++)
- 类C++中的映射函数
- c++映射函数中的向量相等