bool CreditValidator::MayValidate(Dossier d) const { auto iter = d.SemestreIterator(); auto sl = Select<SemestreSuivi, unsigned int>(iter, iter.getEnd(), [=](const SemestreSuivi& x) { return x.get_nb_credit_previsional(t); }); int ag = Sum<unsigned int>(sl, sl.getEnd(), d.getNbEquivalences(t)); return ag >= nb; }
String getText() const { std::ostringstream oss; oss << getStart().first << ":" << getStart().second << " - " << getEnd().first << ":" << getEnd().second; return oss.str(); }
void UseEmplaceCheck::check(const MatchFinder::MatchResult &Result) { const auto *Call = Result.Nodes.getNodeAs<CXXMemberCallExpr>("call"); const auto *InnerCtorCall = Result.Nodes.getNodeAs<CXXConstructExpr>("ctor"); auto FunctionNameSourceRange = CharSourceRange::getCharRange( Call->getExprLoc(), Call->getArg(0)->getExprLoc()); auto Diag = diag(Call->getExprLoc(), "use emplace_back instead of push_back"); if (FunctionNameSourceRange.getBegin().isMacroID()) return; Diag << FixItHint::CreateReplacement(FunctionNameSourceRange, "emplace_back("); auto CallParensRange = InnerCtorCall->getParenOrBraceRange(); // Finish if there is no explicit constructor call. if (CallParensRange.getBegin().isInvalid()) return; // Range for constructor name and opening brace. auto CtorCallSourceRange = CharSourceRange::getTokenRange( InnerCtorCall->getExprLoc(), CallParensRange.getBegin()); Diag << FixItHint::CreateRemoval(CtorCallSourceRange) << FixItHint::CreateRemoval(CharSourceRange::getTokenRange( CallParensRange.getEnd(), CallParensRange.getEnd())); }
void CGPUProgramParams::map(uint index, const std::string &name) { size_t offsetIndex = getOffset(index); size_t offsetName = getOffset(name); if (offsetName != getEnd()) { // Remove possible duplicate if (offsetIndex != getEnd()) { freeOffset(offsetIndex); } // Set index m_Meta[offsetName].Index = index; // Map index to name if (index >= m_Map.size()) m_Map.resize(index + 1, s_End); m_Map[index] = offsetName; } else if (offsetIndex != getEnd()) { // Set name m_Meta[offsetIndex].Name = name; // Map name to index m_MapName[name] = offsetIndex; } }
int SemestreSuivi::get_nb_credit_previsional(UVType type) const //! Retourne le nombre de crédits pouvant etre obtenus durant le semestre. { auto x = Where<const UVEncours>(UVs.begin(), UVs.end(), [](const UVEncours& u) { return u.get_status() == UVStatus::EC || u.get_hasCompleted(); }); auto y = Select<const UVEncours, int>(x, x.getEnd(), [=](const UVEncours& u) { return u.get_uv().get_nb_credit(type); }); return Sum<int>(y, y.getEnd(), type < UVType::size ? Prevision[type] : Sum<int>(Prevision, Prevision + UVType::size, 0)); }
int SemestreSuivi::get_nb_credit_effective(UVType type) const //! Retourne le nombre de crédits obtenus durant le semestre. { auto x = Where<const UVEncours>(UVs.begin(), UVs.end(), [](const UVEncours& u) { return u.get_hasCompleted(); }); auto y = Select<const UVEncours, int>(x, x.getEnd(), [=](const UVEncours& u) { return u.get_uv().get_nb_credit(type); }); return Sum<int>(y, y.getEnd(), Status == SemestreStatus::Fini ? (type < UVType::size ? Prevision[type] : Sum<int>(Prevision, Prevision + UVType::size, 0)) : 0); }
bool XUVAvecYInValidator::MayValidate(Dossier d) const { auto iter = d.UVIterator(); auto sl = Select<UVEncours, unsigned int>(iter, iter.getEnd(), [=](const UVEncours& x) { return t.contains(x.get_uv().get_code()) && (x.get_hasCompleted() || x.get_status() == UVStatus::EC) ? 1 : 0; }); int ag = Sum<unsigned int>(sl, sl.getEnd(), 0); return ag >= nb; }
void Line::rotate(float degrees) { auto rotateVector = [](sf::Vector2f v, float degrees, const sf::Vector2f& midpoint=sf::Vector2f()) -> sf::Vector2f { float theta = degrees*DEGTORAD; float x_new = ( (v.x - midpoint.x) * cos(theta) + (v.y - midpoint.y) * sin(theta) ) + midpoint.x; float y_new = ( -(v.x - midpoint.x) * sin(theta) + (v.y - midpoint.y) * cos(theta) ) + midpoint.y; return sf::Vector2f(x_new, y_new); }; sf::Vector2f midpoint = sf::Vector2f((getStart().x+getEnd().x)/2, (getStart().y+getEnd().y)/2); rotateVector(getStart(), degrees, midpoint); rotateVector(getEnd(), degrees, midpoint); }
int main() { int count = 0; int total = 0; int largest = INT_MIN; Element i; Vector vector = createVector(); V_Iterator it = getEnd(&vector); while( (scanf("%d",&i) == 1 ) ) { if(vector.size == 0 ) prepend(&vector,i); else { insertAfter(&it,i); moveNext(&it); } if( i > largest) largest = i; } printf( "Valor máximo: %d\n", largest); it = getBegin(&vector); while( it.index < vector.size ) { i = getElement(&it); // if( largest % i == 0 ) { total += i; count++; // } moveNext(&it); } if(count != 0) printf( "Média: %d\n", (total/count)); }
Type CTECList<Type>:: getFromIndex(int index) { Type thingToGet; assert(size > 0 && index >= 0 && index < size); ArrayNode<Type> * previous, next; if(index == 0) { thingToGet = getFront(); } else if(index == size - 1) { thingToGet = getEnd(); } else { for(int spot = 0; spot < index + 1; spot++) { } } this -> calculateSize(); return thingToGet; }
Node* getEnd(Node &node){ if(node.next == nullptr){ return &node; }else{ return getEnd(*node.next); } }
void getTOnsetAndEndScale( double *scale, int lengthScale, int tPeak, int tPre, int tPost, int intervalSizeToSearch, int *onsetPos, int *endPos, int tPosIndex, int scaleFactor ){ double thr = 0.5 * fabs(scale[tPre]); onsetPos[tPosIndex] = getOnset(scale, lengthScale, tPeak, tPre, intervalSizeToSearch, thr) * scaleFactor; thr = 0.9 * fabs(scale[tPost]); endPos[tPosIndex] = getEnd(scale, lengthScale, tPeak, tPost, intervalSizeToSearch, thr) * scaleFactor; }
void VideoPreview::AddTempFileToPreview(QueueItem* tempItem, HWND serverReadyReport) { if (tempItem != NULL) { _canUseFile = false; clear(); _callWnd = serverReadyReport; _currentFilePreview = tempItem->getTarget(); _previewFileSize = tempItem->getSize(); m_tempFilename = tempItem->getTempTarget(); _fileRoadMap = unique_ptr<FileRoadMap>(new FileRoadMap(_previewFileSize)); QueueItem::SegmentSet segments; { RLock(*QueueItem::g_cs); segments = tempItem->getDoneL(); } for (auto i = segments.cbegin(); i != segments.cend(); ++i) { addSegment(i->getStart(), i->getEnd()); } tempItem->setDelegate(this); _canUseFile = true; StartServer(); _viewStarted = false; } }
void Messageheader::removeHeader(const char* key) { if (!*key) throw std::runtime_error("empty key not allowed in messageheader"); char* p = getEnd(); const_iterator it = begin(); while (it != end()) { if (StringCompareIgnoreCase<const char*>(key, it->first) == 0) { unsigned slen = it->second - it->first + std::strlen(it->second) + 1; std::memcpy( const_cast<char*>(it->first), it->first + slen, p - it->first + slen); p -= slen; it.fixup(); } else ++it; } endOffset = p - rawdata; }
std::string LineShape::asString() const { std::ostringstream os; os << Shape::asString() << " LineShape: name = " << title << " " << Shape2DUtils::asString(getBegin()) << "->" << Shape2DUtils::asString(getEnd()); return os.str(); }
void Messageheader::setHeader(const char* key, const char* value, bool replace) { if (!*key) throw std::runtime_error("empty key not allowed in messageheader"); if (replace) removeHeader(key); char* p = getEnd(); size_t lk = std::strlen(key); // length of key size_t lk2 = key[lk-1] == ':' ? lk + 1 : lk; // length of key including trailing ':' size_t lv = std::strlen(value); // length of value if (p - rawdata + lk2 + lv + 3 > MAXHEADERSIZE) throw std::runtime_error("message header too big"); std::strcpy(p, key); // copy key p += lk2; *(p - 2) = ':'; // make sure, key is prepended by ':' *(p - 1) = '\0'; std::strcpy(p, value); // copy value p[lv + 1] = '\0'; // put new message end marker in place endOffset = (p + lv + 1) - rawdata; }
uint Aligner::checkBeginGreedy(const string& read, pair<kmer, uint>& overlap, vector<uNumber>& path, uint errors){ if(overlap.second==0){path.push_back(0);return 0;} string readLeft(read.substr(0,overlap.second)),unitig; auto rangeUnitigs(getEnd(overlap.first)); uint minMiss(errors+1),indiceMinMiss(0); bool ended(false); int offset(0); kmer nextOverlap(0); for(uint i(0); i<rangeUnitigs.size(); ++i){ unitig=(rangeUnitigs[i].first); if(unitig.size()-k+1>=readLeft.size()){ uint miss(missmatchNumber(unitig.substr(unitig.size()-readLeft.size()-k+1,readLeft.size()),readLeft, errors)); // if(miss==0){ // path.push_back(unitig.size()-readLeft.size()-k+1); // path.push_back(rangeUnitigs[i].second); // return 0; // } if(miss<minMiss){ minMiss=miss; indiceMinMiss=i; ended=true; offset=unitig.size()-readLeft.size()-k+1; } }else{ uint miss(missmatchNumber(unitig.substr(0,unitig.size()-k+1), readLeft.substr(readLeft.size()+k-1-unitig.size()), errors)); // if(miss==0){ // minMiss+=mapOnLeftEndGreedy(read, path, {nextOverlap,overlap.second-(nextUnitig.size()-k+1)},errors); // if(minMiss<=errors){ // path.push_back(rangeUnitigs[indiceMinMiss].second); // sucessML++; // } // } if(miss<minMiss){ kmer overlapNum(str2num(unitig.substr(0,k-1))); if(miss<minMiss){ ended=false; minMiss=miss; indiceMinMiss=i; nextOverlap=overlapNum; } } } } if(minMiss<=errors){ if(ended){ path.push_back(offset); path.push_back(rangeUnitigs[indiceMinMiss].second); return minMiss; } minMiss+=mapOnLeftEndGreedy(read, path, {nextOverlap,overlap.second-(rangeUnitigs[indiceMinMiss].first.size()-k+1)},errors-minMiss); if(minMiss<=errors){ path.push_back(rangeUnitigs[indiceMinMiss].second); sucessML++; } } return minMiss; }
TEST_F(PQueueTest, Sequence) { using Data = MoveOnly<MoveOnly<int>>; auto rd = getRand(); pqueue<Data, std::deque, std::less<Data>, InsertBefore> q; // 並び順のチェック auto fnCheck = [&q]() { int check = 0; for(auto itr=getBegin(q) ; itr!=getEnd(q) ; ++itr) { EXPECT_LE(check, (*itr).getValue()); check = (*itr).getValue(); } }; // ランダムな値を追加 auto fnAddrand = [&](int n) { for(int i=0 ; i<n ; i++) q.push(Data(rd.getUniformMin(0))); }; fnAddrand(512); fnCheck(); // 先頭の半分を削除して、再度チェック for(int i=0 ; i<256 ; i++) q.pop_front(); fnAddrand(256); fnCheck(); EXPECT_EQ(512, q.size()); }
FileRange SourceRange::getFileRange() const { FileRange range; range.start = getStart().getSpellingLocation(); range.end = getEnd().getSpellingLocation(); return range; }
void CGPUProgramParams::unset(uint index) { size_t offset = getOffset(index); if (offset != getEnd()) { freeOffset(offset); } }
void CGPUProgramParams::unset(const std::string &name) { size_t offset = getOffset(name); if (offset != getEnd()) { freeOffset(offset); } }
bool Action::operator==(Action & a) { bool b=true; if (getType() == a.getType()) { if (getType() == DEPLACEMENT) if (getStart() == a.getStart()) if (getEnd() == a.getEnd()) b = true; else if (getType() == DEPOT) if (getCommande() == a.getCommande()) if (getStart() == a.getStart()) if (getEnd() == a.getEnd()) b = true; } return b; }
void filterSnps() /* Do a serial read through ContigLoc. */ /* For each SNP, get loc_type (1-6), orientation (strand) and allele (refNCBI). */ /* Output to ContigLocFilter table (tableName hard-coded). */ /* Use ctg_id to filter: only save rows where ctg_id is in our hash. */ /* Also, skip whenever weight = 0 or weight = 10 from MapInfo weightHash. */ /* We have to skip if phys_pos_from = 0 */ /* This means we have to skip locType 4-6. */ { char query[512]; struct sqlConnection *conn = hAllocConn(); struct sqlResult *sr; char **row; struct hashEl *el1, *el2; FILE *f; int start = 0; int end = 0; int loc_type = 0; f = hgCreateTabFile(".", "ContigLocFilter"); sqlSafef(query, sizeof(query), "select snp_id, ctg_id, loc_type, phys_pos_from, phys_pos, orientation, allele from ContigLoc"); sr = sqlGetResult(conn, query); while ((row = sqlNextRow(sr)) != NULL) { el1 = hashLookup(contigChroms, row[1]); if (el1 != NULL) { el2 = hashLookup(weightHash, row[0]); if (sameString(el2->val, "10")) continue; if (sameString(el2->val, "0")) continue; loc_type = sqlUnsigned(row[2]); if (loc_type < 1 || loc_type > 3) continue; start = sqlUnsigned(row[3]); if (start == 0) continue; /* process phys_pos based on locType */ end = getEnd(loc_type, start, row[4]); if (end == -1) continue; if (loc_type == 1) { start++; end++; } fprintf(f, "%s\t%s\t%s\t%s\t%d\t%d\t%s\t%s\t%s\n", row[0], row[1], (char *)el1->val, row[2], start, end, row[5], row[6], (char *)el2->val); } } sqlFreeResult(&sr); hFreeConn(&conn); carefulClose(&f); }
bool operator==(const LastDimensionMajorIterator& it){ if(index == it.index && outer == it.outer){ return true; } else if(index == it.index && getEnd() == true && it.getEnd() == true && topLevel){ return true; } return false; }
size_t TrackList::size() const { int cnt = 0; if (!empty()) cnt = getPrev( getEnd() ).first->get()->GetIndex() + 1; return cnt; }
/* int trimQual() * Determine ends of the read. */ int trimQual(char* line, int len, float qual, int* end, int opt5, int opt3) { if (opt3) *end = getEnd(line, len, qual, *end); int st = 0; if (opt5) st = getStart(line, len, qual, *end); return st; }
std::string LineShape::asDebugString() const { std::ostringstream os; os << "LineShape:\n"; os << Shape::asDebugString() << "\n"; os << "name = " << (title.size() == 0 ? "\"\"" : title) << ", " << Shape2DUtils::asString(getBegin()) << "->" << Shape2DUtils::asString(getEnd()); return os.str(); }
// To evaluate a parenthetical expression is simply to evaluate the enclosed // expression ValueAST *ParenExpr::eval(Environment &env) const { ValueAST *value = expr->eval(env); if (!value) return nullptr; value->setStart(getStart()); value->setEnd(getEnd()); return value; }
/** * kruskal 最小生成树算法 */ void kruskal(MGraph G) { // 获取图中所有的边 Edge* edges = getEdges(G); // 对边按权值进行排序(edges是经过排序后的边的数组) sortEdges(edges, G.edgeNum); int vends[MAX] = {0}; Edge kruskal[MAX]; int index = 0; /* * 在不形成环路的前提下,将边从小到大拿出来,直到生成一个树 */ for(int i = 0; i < G.edgeNum; i++) { int edgeStart = getPosition(G, edges[i].start); int edgeEnd = getPosition(G, edges[i].end); // 获取edgeStart和edgeEnd在已有的最小生成树中的终点 int m = getEnd(vends, edgeStart); int n = getEnd(vends, edgeEnd); // 如果m!=n,意味着"边i"与"已经添加到最小生成树中的顶点"没有形成环路 if(m != n) { vends[m] = n; kruskal[index++] = edges[i]; } } free(edges); // 统计并打印"kruskal最小生成树"的信息 int length = 0; for(int i = 0; i < index; i++) length += kruskal[i].weight; printf("length = %d \n", length); for(int i = 0; i < index; i++) { printf("(%c, %c) ", kruskal[i].start, kruskal[i].end); } printf("\n"); }
TEST_F(PQueueTest, InsertAfter) { spn::pqueue<MyPair, std::deque, std::less<MyPair>, InsertAfter> myA; for(int i=0 ; i<20 ; i++) myA.push(MyPair{0, i*100}); int check = myA.front().b; for(auto itr=getBegin(myA) ; itr!=getEnd(myA) ; ++itr) { EXPECT_LE(check, (*itr).b); check = (*itr).b; } }