MATLAB 帮助中心
从 ValueIterator 获取下一个值
X = getnext(ValIter)
X = getnext(ValIter) 返回 ValIter 中下一个可用的值。使用 hasnext 函数在调用 getnext 之前确认 ValIter 中的值的可用性。
ValIter
hasnext
getnext
示例
全部折叠
在 reduce 函数内的 while 循环中使用 hasnext 和 getnext 函数,以便从 ValueIterator 对象中以迭代方式获取值。例如,
while
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 返回错误。
mapreduce
中间值迭代器,指定为一个 ValueIterator 对象。mapreduce 函数在执行期间自动创建该对象。reduce 函数的第二个输入指定 ValueIterator 对象的变量名称,这是要用于 hasnext 和 getnext 函数的变量名称。
有关详细信息,请参阅 ValueIterator。
在 R2014b 中推出
hasnext | mapreduce | ValueIterator
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处