⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 for_each.hpp

📁 矩阵运算源码最新版本
💻 HPP
字号:
// Software License for MTL// // Copyright (c) 2007 The Trustees of Indiana University. All rights reserved.// Authors: Peter Gottschling and Andrew Lumsdaine// // This file is part of the Matrix Template Library// // See also license.mtl.txt in the distribution.#ifndef MTL_FOR_EACH_INCLUDE#define MTL_FOR_EACH_INCLUDEnamespace mtl { namespace recursion {// Go recursively down to base case and apply function on ittemplate <typename Matrix, typename Function, typename BaseCaseTest>void for_each(matrix_recursator<Matrix> const& recursator, Function const& f, BaseCaseTest const& is_base){    if (recursator.is_empty())	return;    if (is_base(recursator)) {	f(*recursator);	return;    }    for_each(recursator.north_west(), f, is_base);    for_each(recursator.south_west(), f, is_base);    for_each(recursator.north_east(), f, is_base);    for_each(recursator.south_east(), f, is_base);}// Non-const versiontemplate <typename Matrix, typename Function, typename BaseCaseTest>void for_each(matrix_recursator<Matrix>& recursator, Function const& f, BaseCaseTest const& is_base){    typedef matrix_recursator<Matrix> recursator_type;    if (recursator.is_empty())	return;    if (is_base(recursator)) {	f(recursator.get_value());	return;    }    recursator_type  tmp_nw(recursator.north_west()), tmp_sw(recursator.south_west()),	             tmp_ne(recursator.north_east()), tmp_se(recursator.south_east());    for_each(tmp_nw, f, is_base);    for_each(tmp_sw, f, is_base);    for_each(tmp_ne, f, is_base);    for_each(tmp_se, f, is_base);}}} // namespace mtl::recursion#endif // MTL_FOR_EACH_INCLUDE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -