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


C++ deque::swap方法代码示例

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


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

示例1: mergePaths

/** Attempt to merge the paths specified in mergeQ with path.
 * @return the number of paths merged
 */
static unsigned mergePaths(const Lengths& lengths,
		ContigPath& path,
		deque<ContigNode>& mergeQ, set<ContigNode>& seen,
		const ContigPathMap& paths)
{
	unsigned merged = 0;
	deque<ContigNode> invalid;
	for (ContigNode pivot; !mergeQ.empty(); mergeQ.pop_front()) {
		pivot = mergeQ.front();
		ContigPathMap::const_iterator path2It
			= paths.find(pivot.contigIndex());
		if (path2It == paths.end())
			continue;

		ContigPath path2 = path2It->second;
		if (pivot.sense())
			reverseComplement(path2.begin(), path2.end());
		ContigPath consensus = align(lengths, path, path2, pivot);
		if (consensus.empty()) {
			invalid.push_back(pivot);
			continue;
		}

		appendToMergeQ(mergeQ, seen, path2);
		path.swap(consensus);
		if (gDebugPrint)
#pragma omp critical(cout)
			cout << get(g_contigNames, pivot)
				<< '\t' << path2 << '\n'
				<< '\t' << path << '\n';
		merged++;
	}
	mergeQ.swap(invalid);
	return merged;
}
开发者ID:BioinformaticsArchive,项目名称:abyss,代码行数:38,代码来源:MergePaths.cpp

示例2: CustomGetSamples

/**
 * Returns the complete queue of samples that have been received so far.
 * Lock the p_sys->lock before calling this function.
 * @param samples_queue [out] Empty queue that will get all elements from
 * the pin queue.
 * @return S_OK if a sample was available, S_FALSE if no sample was
 * available
 */
HRESULT CapturePin::CustomGetSamples( deque<VLCMediaSample> &external_queue )
{
#if 0 //def DEBUG_DSHOW
    msg_Dbg( p_input, "CapturePin::CustomGetSamples: %d samples in the queue", samples_queue.size());
#endif

    if( !samples_queue.empty() )
    {
        external_queue.swap(samples_queue);
        return S_OK;
    }
    return S_FALSE;
}
开发者ID:cmassiot,项目名称:vlc-broadcast,代码行数:21,代码来源:filter.cpp

示例3: drawFood

//Method to draw all the food left and delete the ate one
void drawFood(float pacmanX, float pacmanY){
	deque<float> temp;
	//check if the food has not been eaten
	for (int i = 0; i < food.size(); i = i + 2){
		if (!foodEaten(food.at(i)*squareSize, food.at(i + 1)*squareSize, pacmanX, pacmanY)){
			temp.push_back(food.at(i));
			temp.push_back(food.at(i + 1));
		}
		else {
			points++;
		}
	}
	food.swap(temp);
	glPointSize(5.0);
	glBegin(GL_POINTS);
	glColor3f(1.0, 1.0, 1.0);
	//draw all the food avilable
	for (int j = 0; j < food.size(); j = j + 2){
		glVertex2f(food.at(j)*squareSize, food.at(j + 1)*squareSize);
	}
	glEnd();
}
开发者ID:patriciateroltolsa,项目名称:Pacman,代码行数:23,代码来源:assign10.cpp

示例4: visitFrom

    void visitFrom(int direction,vector<vector<int>>& result,deque<TreeNode*>& _deque)
    {
       vector<int> solution;
       deque<TreeNode*> dq;

       while(!_deque.empty())
       {
          // right -> left
          if(direction)
          {
             TreeNode* pn = _deque.back();
             _deque.pop_back();
             if(!pn)
                continue;
             solution.push_back(pn -> val);
             dq.push_back(pn -> right);
             dq.push_back(pn -> left);
          }
          else
          {
             TreeNode* pn = _deque.front();
             _deque.pop_front();
             if(!pn)
                continue;
             solution.push_back(pn -> val);
             dq.push_back(pn -> left);
             dq.push_back(pn -> right);
          }
       }
       if(solution.size())
       {
          result.push_back(solution);
          if(direction)
             reverse(dq.begin(),dq.end());
          _deque.swap(dq);
          return visitFrom(!direction,result,_deque);
       }
    }
开发者ID:hellogdut,项目名称:MyLeetcode,代码行数:38,代码来源:Binary+Tree+Zigzag+Level+Order+Traversal.cpp


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