Main Content

hasnext

确定 ValueIterator 是否具有一个或多个可用值

说明

示例

如果 ValueIter 具有一个或多个可用的值,则 tf = hasnext(ValIter) 返回逻辑值 1 (true),否则它返回逻辑值 0 (false)。

示例

全部折叠

在 reduce 函数内的 while 循环中使用 hasnextgetnext 函数,以便从 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 以确认值的可用性。如果调用 getnextValueIterator 对象中没有其余的值,则 mapreduce 返回错误。

输入参数

全部折叠

中间值迭代器,指定为一个 ValueIterator 对象。mapreduce 函数在执行期间自动创建该对象。reduce 函数的第二个输入指定 ValueIterator 对象的变量名称,这是要用于 hasnextgetnext 函数的变量名称。

有关详细信息,请参阅 ValueIterator

版本历史记录

在 R2014b 中推出