CFileNodePackFileNode* CPackFiles::Iterate(CPackFileIterator* psIter) { SPackFileIteratorPosition* psCurrent; int iDirectoryElements; CFileNodePackFileNode* pcChild; psCurrent = psIter->Peek(); if (!psCurrent) { return NULL; } iDirectoryElements = psCurrent->pcNode->Directory()->maNodeFiles.NumElements(); psCurrent->iIndex++; if (psCurrent->iIndex < iDirectoryElements) { pcChild = (CFileNodePackFileNode*)psCurrent->pcNode->Directory()->maNodeFiles.Get(psCurrent->iIndex); if (pcChild->IsDirectory()) { psIter->Push(pcChild); return Iterate(psIter); } else { psIter->SetCurrent(pcChild); return psIter->Current(); } } else { psIter->Pop(); return Iterate(psIter); } }
static EvaluationContextBase * DoEvaluate(LetEvaluationContext * evaluationContext) { Term * lets = NULL, * current = NULL, * let[] = {NULL, NULL}, * error = NULL; if (!evaluationContext->childContextBindings) { if (!(lets = Iterate(&evaluationContext->arguments))) { THIS_CONTEXT->result = InvalidArgumentCount(); return THIS_CONTEXT; } if (terRedex != lets->tag) { THIS_CONTEXT->result = InvalidArgumentType(); return THIS_CONTEXT; } evaluationContext->letsList = lets->redex; evaluationContext->childContextBindings = AllocateContextBindings(THIS_CONTEXT->contextBindings); } if (!(current = Iterate(&evaluationContext->letsList))) return AcquireTermListEvaluationContext(THIS_CONTEXT->parent, evaluationContext->childContextBindings, evaluationContext->arguments); if (terRedex != current->tag) { THIS_CONTEXT->result = InvalidArgumentType(); return THIS_CONTEXT; } if (TakeSeveralArguments(current->redex, let, &error) < 0) { THIS_CONTEXT->result = error; return THIS_CONTEXT; } if (terVariable != let[0]->tag) { THIS_CONTEXT->result = InvalidArgumentType(); return THIS_CONTEXT; } evaluationContext->currentLetVariable = let[0]->variable; return AcquireTermEvaluationContext(THIS_CONTEXT, THIS_CONTEXT->contextBindings, let[1]); }
static Term * EvalLambda(Lambda lambda, List arguments) { Term * formalArgument = NULL, * argument = NULL; ContextBindings * childContextBindings = AllocateContextBindings(lambda.context); while(formalArgument = Iterate(&lambda.formalArguments)) { argument = Iterate(&arguments); if (!argument) return InvalidArgumentCount(); CheckTermType(formalArgument, terVariable); childContextBindings->dictionary = Set(childContextBindings->dictionary, formalArgument->variable, argument); } if (Iterate(&arguments)) return InvalidArgumentCount(); return EvalList(lambda.body, childContextBindings); }
void PanamaCipherPolicy<B>::CipherSetKey(const NameValuePairs ¶ms, const byte *key, unsigned int length) { FixedSizeSecBlock<word32, 8> buf; Reset(); memcpy(buf, key, 32); Iterate(1, buf); if (length == 64) memcpy(buf, key+32, 32); else memset(buf, 0, 32); Iterate(1, buf); Iterate(32); }
int main(int argc, char **argv) { FILE *f; double atk,def; int t=0; InitSystem(); Bpp=4; XRes=800+XR; YRes=400; ScreenBuf=(unsigned char*)malloc(XRes*YRes*Bpp); memset(ScreenBuf,0,XRes*YRes*Bpp); InitSDL(); while (1) { int Ch=ReadKey(); if (Ch=='q') exit(0); Iterate(); Survey(&atk,&def); f=fopen("output.txt","a"); fprintf(f,"%d %.6g %.6g\n",t,atk,def); fclose(f); t++; } }
void TableGroup<V>::GlobalBarrier() { VLOG(0) << "Iterating " << max_staleness_ + 1 << " times to simulate GlobalBarrier()"; for (int i = 0; i < max_staleness_ + 1; ++i) { Iterate(); } }
void Think(POS *p, int *pv) { pv[1] = 0; // fixing rare glitch // Play a move from opening book, if applicable if (use_book) { pv[0] = GuideBook.GetPolyglotMove(p, 1); if (pv[0]) return; pv[0] = MainBook.GetPolyglotMove(p, 1); if (pv[0]) return; } // Set basic data ClearHist(); tt_date = (tt_date + 1) & 255; nodes = 0; abort_search = 0; verbose = 1; Timer.SetStartTime(); // Search Iterate(p, pv); }
void* CMemory::Iterate(SMemoryIterator* psIterator) { void* pv; pv = psIterator->pcFreeList->Iterate(&psIterator->sFreeListIterator); if (pv == NULL) { psIterator->pcFreeList = mcFreeLists.GetNext(psIterator->pcFreeList); if (psIterator->pcFreeList == NULL) { return NULL; } else { pv = psIterator->pcFreeList->StartIteration(&psIterator->sFreeListIterator); if (pv == NULL) { return Iterate(psIterator); } else { return pv; } } } else { return RemapSinglePointer(pv, sizeof(SMemoryAllocation)); } }
static void RunAnnotate(char *fname, int side) { FILE *fin = fopen(fname, "r"); struct Position *p; if(fin) { struct PGNHeader header; char move[16]; while(!scanHeader(fin, &header)) { p = InitialPosition(); while(!scanMove(fin, move)) { int themove = ParseSAN(p, move); if(themove != M_NONE) { ShowPosition(p); Print(0, "%s(%d): ", p->turn == White ? "White":"Black", (p->ply/2)+1); Print(0, "%s\n", SAN(p, themove)); if(side == -1 || (side == p->turn)) { Iterate(p); } DoMove(p, themove); } } FreePosition(p); } } else Print(0, "Couldn't open %s\n", fname); }
QString QmitkStatisticsModelToStringConverter::GetString() const { if (m_statisticsModel == nullptr) { mitkThrow() << "Cannot convert TableModel to String: TableModel is nullptr"; } QString textData; int columns = m_statisticsModel->columnCount(); if (m_includeHeaderData) { for (int i = 0; i < columns; i++) { if (i > 0) { textData += m_columnDelimiterWithSpace; } textData += m_statisticsModel->headerData(i, Qt::Horizontal).toString(); } textData += m_lineDelimiter; } textData += Iterate(m_rootIndex, m_statisticsModel); return textData; }
void CFiles::GetFileNames(CMapStringInt* pcFileNames) { CFileIterator cIter; CFileIteratorReturn* pcReturn; int* piValue; int iRank; pcReturn = StartIteration(&cIter); while (pcReturn) { piValue = pcFileNames->Get(pcReturn->GetFullName()); if (!piValue) { iRank = pcReturn->GetFileRank() << 16; pcFileNames->Put(pcReturn->GetFullName(), iRank + 1); } else { iRank = (*piValue) >> 16; if (iRank < pcReturn->GetFileRank()) { iRank = pcReturn->GetFileRank() << 16; *piValue = iRank | (*piValue & 0xFFFF); } (*piValue)++; } pcReturn = Iterate(&cIter); } StopIteration(&cIter); }
static int premia_interactive_menu( Planning *pt_plan, Model **models, Family **families, Pricing **pricings, int user) { Model* pt_model; Option* pt_option; Pricing* pt_pricing; PricingMethod* pt_method; DynamicTest* pt_test; PricingMethod* pt_methods_available[MAX_METHODS]; if (OutputFile(&out_stream)!=OK) return WRONG; if (SelectModel(user,pt_plan,models,families,pricings,&pt_model)!=OK) return WRONG; if (SelectOption(user,pt_plan,families,pt_model,pricings,&pt_option)!=OK) return WRONG; if (SelectPricing(user,pt_model,pt_option,pricings,&pt_pricing)!=OK) return WRONG; while(1){ if (SelectMethod(user,pt_plan,pt_pricing,pt_option,pt_model,&pt_method)!=OK) return FAIL; if (SelectTest(user,pt_plan,pt_pricing,pt_option,pt_model,pt_method,&pt_test)!=OK) return FAIL; if (GetTimeInfo(user,pt_plan,&computation_time_info)!=OK) return FAIL; if ((pt_plan->Action=='p')|| (( pt_plan->Action=='t')&& (GetTest(user,pt_plan,pt_pricing,pt_option,pt_test)==OK))){ (void)ShowPlanning(NAMEONLYTOFILE,pt_plan); (void)Action(pt_model,pt_option,pt_pricing, pt_method,pt_test,NAMEONLYTOFILE,pt_plan,&computation_time_info); Fprintf(TOSCREEN,"\nComputing...\n"); Iterate(pt_plan,&(pt_plan->Par[0]),0,pt_plan->Action,pt_model,pt_option, pt_pricing,pt_method,pt_test,TOFILE,&computation_time_info); pt_methods_available[pt_plan->NumberOfMethods]=pt_method; if (pt_plan->Action=='t' || MoreAction(&(pt_plan->NumberOfMethods))==FAIL) break; else free_premia_method(pt_method); } } fclose(out_stream); if ((pt_plan->Action=='p') && (pt_plan->VarNumber>0)) (void)BuildGnuStuff(pt_plan,pt_model,pt_option,pt_pricing,pt_methods_available); if (pt_plan->Action=='t') { (void)FreeTest(pt_test); (void)BuildGnuStuffTest(pt_model,pt_option,pt_pricing,pt_method,pt_test); } free_premia_model(pt_model); free_premia_option(pt_option); free_premia_method(pt_method); return OK; }
// Iterate over all valid rows in this batch void RowBatch::Iterate(CodeGen &codegen, const std::function<void(RowBatch::Row &)> cb) { // Create a simple adapter around the provided function CallbackAdapter adapter{cb}; // Do iteration with adapter Iterate(codegen, adapter); }
int StringHash::Add(const String & string, void * object) { unsigned int key = getKey(string); unsigned int h = Iterate(key, string); if (strings[h] == NULL) Insert(h, key, string); objects[h] = object; if (count * 2 > size) { Grow(); return Iterate(key, string); } return h; }
int32 ConditionalAllAppsIterator::CountEntries() { if (!Iterate()) return 0; Instantiate(); return fWalker->CountEntries(); }
status_t ConditionalAllAppsIterator::Rewind() { if (!Iterate()) return B_OK; Instantiate(); return fWalker->Rewind(); }
status_t ConditionalAllAppsIterator::GetNextRef(entry_ref* ref) { if (!Iterate()) return B_ENTRY_NOT_FOUND; Instantiate(); return fWalker->GetNextRef(ref); }
status_t ConditionalAllAppsIterator::GetNextEntry(BEntry* entry, bool traverse) { if (!Iterate()) return B_ENTRY_NOT_FOUND; Instantiate(); return fWalker->GetNextEntry(entry, traverse); }
OP_STATUS ChainedHashBackend::Next(ChainedHashIterator* iterator) const { INT32 pos = iterator->GetHashLinkPos(); if (pos < 0) { return OpStatus::ERR; } return Iterate(iterator, (UINT32)(pos + 1)); }
int StringDoubleHash::Add(const String & string, double value) { unsigned int key = getKey(string); unsigned int h = Iterate(key, string); if (strings[h] == NULL) Insert(h, key, string); doubles[h] = value; if (count * 2 > size) { Grow(); return Iterate(key, string); } return h; }
CFileNodePackFileNode* CPackFiles::StartIteration(CPackFileIterator* psIter) { CFileNodePackFileNode* pcFileNodePackFileNode; pcFileNodePackFileNode = mcNames.GetRoot(); psIter->Init(); psIter->Push(pcFileNodePackFileNode); return Iterate(psIter); }
CFileIteratorReturn* CFiles::StartIteration(CFileIterator* pcIter) { pcIter->Init(); if (mcPackFilesArray.IsEmpty()) { pcIter->mbFileSystem = TRUE; } return Iterate(pcIter); }
int32 ConditionalAllAppsIterator::GetNextDirents(struct dirent *buffer, size_t length, int32 count) { if (!Iterate()) return 0; Instantiate(); return fWalker->GetNextDirents(buffer, length, count); }
Term * EvalList(List list, ContextBindings * contextBindings) { Term * result = NULL; Term * i = NULL; while(i = Iterate(&list)) EvalTermAndCheckError(result, i, contextBindings); if (!result) return InvalidArgumentCount(); return result; }
void RunningSceneController::DoMainLoop() { initialized = true; while(!stop_requested) { Iterate(); m_thread->sleep(boost::get_system_time()+boost::posix_time::milliseconds(5)); } }
CDenseVector<T> CLevenbergMarquardt<Matrix,T>::Iterate(size_t nouter, const CWeightFunction<T>& w, size_t ninner, T epsilon, bool silentouter, bool silentinner) { vector<T> residuals; CDenseVector<T>& weights = m_problem.GetWeights(); CDenseVector<T> r(m_problem.GetNumberOfDataPoints()); m_problem.ComputeResidual(r); T res = r.Norm2(); residuals.push_back(res); size_t k = 0; if(!silentouter) { cout.setf(ios::scientific,ios::floatfield); cout << "k=" << k << ": " << res << endl; } T sinv; while(k<nouter) { // run LM method Iterate(ninner,1e-10,1e-10,silentinner); // compute weight function from unweighted (!) residual vector residual m_problem.ComputeResidual(r); // update weights used in inner iteration sinv = w(r,weights); // save norm of residual res = r.Norm2(); residuals.push_back(res); k++; if(!silentouter) cout << "k=" << k << ": " << res << endl; double dres = res - residuals[residuals.size()-2]; if(fabs(dres)<epsilon) break; } // express residual in numbers of variance for(size_t i=0;i<r.NElems();i++) r(i) = r.Get(i)*sinv; // return residual return r; }
int StringIntHash::Find(const String & string, int defaultValue) { unsigned int key = getKey(string); unsigned int h = Iterate(key, string); if (strings[h] == NULL) { Insert(h, key, string); integers[h] = defaultValue; if (count * 2 > size) { Grow(); return Iterate(key, string); } } return h; }
const int GravityIterator<T>::IterateUntilTrapped() { while (true) { const int result = Trapped(); if (result != -1) { return result; } Iterate(); } }
int StringDoubleHash::Find(const String & string) const { unsigned int key = getKey(string); unsigned int h = Iterate(key, string); if (strings[h] == NULL) return -1; return h; }
void PolygonRender::GetExtent(CachedExtent &ioCache) { mBuildExtent = &ioCache.mExtent; *mBuildExtent = Extent2DF(); SetTransform(ioCache.mTransform); Iterate(itGetExtent,*ioCache.mTransform.mMatrix); mBuildExtent = 0; }