当前位置: 首页>>代码示例>>C++>>正文


C++ ArrayData::next方法代码示例

本文整理汇总了C++中ArrayData::next方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayData::next方法的具体用法?C++ ArrayData::next怎么用?C++ ArrayData::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArrayData的用法示例。


在下文中一共展示了ArrayData::next方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: advance

bool MutableArrayIter::advance() {
    ArrayData *data = m_var ? getData() : m_data;
    if (!data) return false;
    // If the foreach loop's array changed since the previous iteration,
    // we recover by creating a new strong iterator for the new array,
    // starting with at the position indicated by the new array's internal
    // pointer.
    if (m_fp.container != data) {
        // Free the current strong iterator if its valid
        if (m_fp.container != NULL) {
            m_fp.container->freeFullPos(m_fp);
        }
        assert(m_fp.container == NULL);
        // If needed, escalate the array to an array type that can support
        // foreach by reference
        escalateCheck();
        // Trigger COW if needed, copying over strong iterators
        data = cowCheck();
        // Create a new strong iterator for the new array
        data->newFullPos(m_fp);
    } else {
        // Trigger COW if needed, copying over strong iterators
        data = cowCheck();
    }
    assert(m_fp.container == data);
    if (!data->setFullPos(m_fp)) return false;
    CVarRef curr = data->currentRef();
    m_valp->assignRef(curr);
    if (m_key) m_key->assignVal(data->key());
    data->next();
    data->getFullPos(m_fp);
    return true;
}
开发者ID:gitlisted,项目名称:hiphop-php,代码行数:33,代码来源:array_iterator.cpp

示例2: advance

bool MutableArrayIter::advance() {
  ArrayData *data = m_var ? getData() : m_data;
  if (!data) return false;
  // If the foreach loop's array changed since the previous iteration,
  // we recover by creating a new strong iterator for the new array,
  // starting with at the position indicated by the new array's internal
  // pointer.
  if (m_fp.container != data) {
    // Free the current strong iterator if its valid
    if (m_fp.container != NULL) {
      m_fp.container->freeFullPos(m_fp);
    }
    // Create a new strong iterator for the new array
    ASSERT(m_fp.container == NULL);
    data->newFullPos(m_fp);
  }
  ASSERT(m_fp.container == data);
  if (!data->setFullPos(m_fp)) return false;
  CVarRef curr = data->currentRef();
  curr.setContagious();
  m_val = curr;
  if (m_key) *m_key = data->key();
  data->next();
  data->getFullPos(m_fp);
  return true;
}
开发者ID:dipjyotighosh,项目名称:hiphop-php,代码行数:26,代码来源:array_iterator.cpp

示例3: operator

                // The default operator called from parallel_for
                void operator() (const tbb::blocked_range<int64> &range) const {
                		callerContext.EnteringOperator();

                        // Build arguments array
                        Array args = Array::Create();

                        // Pass the range start and end as parameters
                        args.append(range.begin());
                        args.append(range.end());

                        // If an input array is defined, copy it and pass as a parameter
                        if(inputArrayOfVariant.size() > 0) {
                        	Array inputPHPArray = Array::Create();
                        	for(size_t ai=0; ai<inputArrayOfVariant.size(); ai++)
                        		inputPHPArray.append(inputArrayOfVariant[ai]);

                        	Variant inputArrayArg(inputPHPArray.getArrayData());
                        	args.append(inputArrayArg);
                        }

                        // Call user supplied callback with arguments
                        // This is a PHP function of the form worker($begin, $end, $array), returning an array or nothing
                        // If an array is returned, it is expected to have elements which will be comingled into the output
                        // array in the elements defined by the input range.
                        Variant vres = f_call_user_func_array(this->callback, args);

                		callerContext.ExitingOperator();		// Call this straight after the callback completes

                		// Return if no result to pass back
                        if(vres.isNull() || !vres.isArray())
                        	return;

                        // Now we take the output array [0..N) and assign it into the overall output array at [begin..begin+N)

                        // Extract output array from result variant
                    	const Array aOutputArray = vres.asCArrRef();
                    	ArrayData *pdOutputArray = aOutputArray.getArrayData();

                    	Variant v = pdOutputArray->reset();

                    	// Check the output array is the same size or smaller than the range passed
                    	size_t outIdx = range.begin();
                    	if(pdOutputArray->size() > (range.end()-range.begin())) {
                    		raise_warning("Callback function returned array larger than passed range size");
                    		return;
                    	}

                    	// Copy each row
                    	while(!v.isBoolean() || v.toBoolean())
                    	{
                        	// printf(" outIdx=%d, v=%s\n", (int)outIdx, v.toString().c_str());
                        	( *pOutputArrayOfVariant ) [outIdx++] = v;

                        	v = pdOutputArray->next();
                    	}

                }
开发者ID:openparallel,项目名称:hiphop-php,代码行数:58,代码来源:ext_tbb_parallelfor.cpp

示例4: advance

bool MutableArrayIter::advance() {
  ArrayData *data = getData();
  if (!data) return false;
  if (!data->setFullPos(m_pos)) return false;
  CVarRef curr = data->currentRef();
  curr.setContagious();
  m_val = curr;
  if (m_key) *m_key = data->key();
  data->next();
  data->getFullPos(m_pos);
  return true;
}
开发者ID:Neomeng,项目名称:hiphop-php,代码行数:12,代码来源:array_iterator.cpp


注:本文中的ArrayData::next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。