/** 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; }
/** * 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; }
//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(); }
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); } }