getnext
从 ValueIterator 获取下一个值
说明
示例
从 reduce 函数中的 ValueIterator 获取值
在 reduce 函数内的 while
循环中使用 hasnext
和 getnext
函数,以便从 ValueIterator
对象中以迭代方式获取值。例如,
function MeanDistReduceFun(sumLenKey, sumLenIter, outKVStore) sumLen = [0 0]; while hasnext(sumLenIter) sumLen = sumLen + getnext(sumLenIter); end add(outKVStore, 'Mean', sumLen(1)/sumLen(2)); end
始终在 getnext
之前调用 hasnext
以确认值的可用性。如果调用 getnext
且 ValueIterator
对象中没有其余的值,则 mapreduce
返回错误。
输入参数
ValIter
— 中间值迭代器
ValueIterator
对象
中间值迭代器,指定为一个 ValueIterator
对象。mapreduce
函数在执行期间自动创建该对象。reduce 函数的第二个输入指定 ValueIterator
对象的变量名称,这是要用于 hasnext
和 getnext
函数的变量名称。
有关详细信息,请参阅 ValueIterator
。
版本历史记录
在 R2014b 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)