bool RecursiveSceneIterator::operator==(const RecursiveSceneIterator& rhs) const noexcept { if (isEnd() || rhs.isEnd()) { return isEnd() == rhs.isEnd(); } return &(*iter_) == &(*rhs.iter_); }
// ---------------------------------------------------------------------------- int RiffWavReader::getStream(void* buf, const size_t& count, size_t& result) { if (!isRiffWav()) return -1; if (count == 0) return 0; if (buf == nullptr) return -2; if (isEnd()) return -3; try { result = this->readBytes(buf, count); } catch (const WavIoException&) { return -3; } return isEnd() ? 1 : 0; }
// Visits all PtNodes in post-order depth first manner. // For example, visits c -> b -> y -> x -> a for the following dictionary: // a _ b _ c // \ x _ y bool DynamicPatriciaTrieReadingHelper::traverseAllPtNodesInPostorderDepthFirstManner( TraversingEventListener *const listener) { bool alreadyVisitedChildren = false; // Descend from the root to the root PtNode array. if (!listener->onDescend(getPosOfLastPtNodeArrayHead())) { return false; } while (!isEnd()) { if (!alreadyVisitedChildren) { if (mNodeReader.hasChildren()) { // Move to the first child. if (!listener->onDescend(mNodeReader.getChildrenPos())) { return false; } pushReadingStateToStack(); readChildNode(); } else { alreadyVisitedChildren = true; } } else { if (!listener->onVisitingPtNode(&mNodeReader, mMergedNodeCodePoints)) { return false; } readNextSiblingNode(); if (isEnd()) { // All PtNodes in current linked PtNode arrays have been visited. // Return to the parent. if (!listener->onReadingPtNodeArrayTail()) { return false; } if (mReadingStateStack.size() <= 0) { break; } if (!listener->onAscend()) { return false; } popReadingStateFromStack(); alreadyVisitedChildren = true; } else { // Process sibling PtNode. alreadyVisitedChildren = false; } } } // Ascend from the root PtNode array to the root. if (!listener->onAscend()) { return false; } return !isError(); }
// メイン処理 void AdventureScene::update(SceneManager* smgr) { InputManager &idev = InputManager::getInstance(); if (idev.getConfigKeyState(KEY_CANCEL) == 1 && m_backlog.second.size() > 1) smgr->reserveNextScene(new BacklogScene(m_backlog)); // 中断セーブはオミット /*if (idev.getConfigKeyState(KEY_MENU) == 1) { std::vector<std::string> data; data.push_back("scriptpath " + m_scriptPath); data.push_back("current " + std::to_string(m_current - 1)); data.push_back("bg " + getBGKey()); data.push_back("bgm " + getBGMKey()); data.push_back("left " + getLeftCharKey()); data.push_back("right " + getRightCharKey()); ExitDialogScene* dialog = new ExitDialogScene(data); smgr->reserveNextScene(dialog); }*/ if (idev.getConfigKeyState(KEY_LEFT) == 1) { // スキップ処理開始・停止 if (getIsSkipMode()) { setIsSkipMode(false); } else { setIsSkipMode(true); } } if (idev.getConfigKeyState(KEY_RIGHT) == 1) { // 高速スキップ処理 printf("fast skip mode. ==>\n"); setIsSkipMode(true); while (m_taskList.empty() == false) { // スキップの開始 AdventureTask* current = getCurrentTask(); AdventureTask* newest = getRunningTaskNewest(); if ((current != nullptr && typeid(*current) == typeid(ChoiceTask)) || (newest != nullptr && typeid(*newest) == typeid(ChoiceTask)) || (current != nullptr && typeid(*current) == typeid(TransSceneTask)) || (newest != nullptr && typeid(*newest) == typeid(TransSceneTask))) { // 選択肢の入力ではスキップを停止 break; } if (m_taskList.empty() == false) { addRunningTask(); } if (isEnd() && m_runningTaskList.empty()) { break; } runTask(smgr); } setIsSkipMode(false); printf("==> done.\n"); } // 処理するタスクを取得する if (isEnd() && m_runningTaskList.empty()) { smgr->reserveExitScene(); return; } if (m_taskList.empty() == false) { addRunningTask(); } runTask(smgr); }
void SVIParticleAnimation::update(SVIUInt& time) { if( getStatus() == IDLE ) { } updateInfo(time); if( getStatus() == ANIMATING ) { if(mParticleEffect != NULL) { if(mParticleEffect->getStatus() == SVIParticleEffect::IDLE) { mSlide->getProjectionSlide()->addParticleEffect(mParticleEffect); } SVIFloat interpolateTime = mInterpolator->getTimeInterpolation(time); if(mParticleEffect) mParticleEffect->updateFromAnimation(time, interpolateTime, mDuration); } if( isEnd(time) ) { setStatus(END); if( !mIsContainedInAniSet && mSlide != NULL ) { //mSlide->getProjectionSlide()->removeParticleEffect(mParticleEffect); mParticleEffect->stop(); mParticleEffect = NULL; mSlide->removeAnimation(); } } } }
void Insert (TList<Tdata>* l, Tdata info) { TLNode<Tdata>* box = new TLNode<Tdata>; box->info=info; if(IsEmpty(l)) Push_back(l,info); else { if(!isEnd(l)) { if(l->first == l->window) { l->first->prev=box; box->next=l->first; box->prev=NULL; l->first=box; } else { box->next=l->window; box->prev=l->window->prev; l->window->prev=box; box->prev->next=box; } l->window=box; } } }
RecursiveSceneIterator& RecursiveSceneIterator::operator++() noexcept { if (isEnd()) return *this; // If has child if (!(*iter_)->children_.empty()) { // References to first child parents_.push(iter_); iter_ = (*iter_)->children_.begin(); } // Else if has GameObject as parent else if (!parents_.empty()) { ASSERT(scene_); // If has brother, references to brother // Else, references to parent if (++iter_ == (*parents_.top())->children_.end()) { iter_ = parents_.top(); parents_.pop(); } } // Else (has Scene as parent) else { // If has brother, references to brother. // Else (no brother), references to end. ++iter_; } return *this; }
// Increment the iterator by one and set current_string_ to the new value // Return false if there are no more terminals in the group (we are past the end) bool SeenTerminalGroup::SeenTerminalGroupStringIterator:: increment() { if (!isEnd()) { unsigned int bytes_read; grammartools::ReadLineFromCharArray2(current_group_position_, bytes_read); // Parse the line const char *terminal, *source_ids; double probability; grammartools::ParseNonterminalLine(current_group_position_, bytes_read, &terminal, probability, &source_ids); // Adjust class variables current_group_position_ += bytes_read; // Adjust bytes_remaining_ but make sure we don't overflow the unsigned in if (bytes_read <= bytes_remaining_) bytes_remaining_ -= bytes_read; else bytes_remaining_ = 0; std::string terminalstr(terminal); // Uppercase the terminal in the correct positions, if needed if (parent_->out_matching_needed_) parent_->matchOutRepresentation(terminalstr); current_string_ = terminalstr.c_str(); return true; } return false; }
step search(void){ push(start); getVisited(start) = 1; while (queueIsNotEmpty){ step curr = pop(); if (isEnd(curr)) return curr; int i, j; for (i = 0; i < MOVENUM; i++){ step next = curr; next.parent = qs-1; // popped index next.move = i+1; for (j = 0; j < CLOCKNUM; j++){ next.clocks[j] += moves[i][j]; next.clocks[j] %= STATENUM; } if (!getVisited(next)){ push(next); getVisited(next) = 1; } } } }
/** * Возвращает следующую строчку массива с текстом и передвигает указатель */ const QString &GameText::nextLine() { if (isEnd()) return emptyString; ++pos; return currentLine(); }
void BulletMLRunnerImpl::run() { if (isEnd()) return; changes(); endTurn_ = runner_->getTurn(); // 最後の wait, change系を待つだけ if (act_ == 0) { if (!isTurnEnd()) { if (changeDir_.get() == 0 && changeSpeed_.get() == 0 && accelx_.get() == 0 && accely_.get() == 0) { end_ = true; } } return; } act_ = node_[actIte_]; if (actTurn_ == -1) actTurn_ = runner_->getTurn(); runSub(); if (act_ == 0) { actIte_++; if (node_.size() != actIte_) act_ = node_[actIte_]; } else { node_[actIte_] = act_; } }
QString BuildModel::__skeleton(gum::prm::System<double> &sys) { QString sk = "graph " + QString::fromStdString(sys.name()).replace('.', '_') + " {"; // List nodes for (const auto node: sys.skeleton().nodes()) { const auto &inst = sys.get(node); const auto &c = inst.type(); QString line = "\n%1[label=\"%2 %3\"]"; sk.append(line.arg(QString::number(node), QString::fromStdString(c.name()), QString::fromStdString(inst.name()))); } sk.append("\n"); // list arcs for (const auto node: sys.skeleton().nodes()) { const auto &inst = sys.get(node); const auto &c = inst.type(); for (auto ref: c.referenceSlots()) { for (auto iter = inst.begin(ref->id()); not iter.isEnd(); iter.operator++()) { QString line = "\n\t%1 -- %2"; sk.append(line.arg(QString::number(node), QString::number(sys.get(*iter)))); } } } sk.append("\n}"); return sk; }
void RPNScript::runStep() { if (isEnd()) throw RPNError("trying to evaluate nonexist command"); (*this)[curCmd].evaluate(*this, *stack); }
//function responsible for retrieving data from the input file and then loading it to the code array for //code output and further token processing. void load1() { codeCount = 0; char symbolBuffer[2]; int i = 0; int x, prev = 0, codeIndex, endSwitch = 0, commentSwitch = 0; if(!codeFile) { printf("Error in opening the file."); exit(0); } while (isEnd() != 1) { x = fgetc(codeFile); //printf("%d", codeCount); //printf("this iteration of x is %c \n", x); char tempString [256]; if(isSymbol2(x)) { if(x == '*' && prev == '/') { skipComment(); prev = 33; continue; } if(!isSymbol2(prev)) { codeCount += 2; //printf("\nthe string is %c%c%c\n", buffer[0],buffer[1],buffer[2]); put(codeArray, buffer); //printf("\n%s\n", buffer); } symbolBuffer[0] = x; symbolBuffer[1] = '\0'; put(codeArray, symbolBuffer); //printf("\n%s\n", symbolBuffer); i = 0; } else { codeCount ++; buffer[i] = x; buffer[i+1] = '\0'; i++; } prev = x; //printf("%d\n", codeCount); } put(codeArray, "end"); put(codeArray, "."); //printArrayList(codeArray); fclose(codeFile); }
//seek a particular instance bool CLASS::seekInst(int inst){ if(isEnd()) return false; //at end! //starting at outgoing instance pointer... while(seekNext()){ if(inst==buf[index].inst) return true; } return false; }
//============================================================================= /// Запись байта //============================================================================= void ByteOrderConverter::write(u16 byte_value) { if (!data || isEnd()) return; if (byte_order == eboHighFirst) __byte(data, cnt - cur_index++) = byte_value & 0xFF; else __byte(data, cur_index++) = byte_value & 0xFF; }
uv_err_t UVDBfdInstructionIterator::get(UVDInstruction **out) const { UVDInstruction *ret = NULL; uv_assert_ret(!isEnd()); ret = new UVDBFDInstruction(); uv_assert_ret(ret); *ret = m_instruction; return UV_ERR_OK; }
//============================================================================= /// Чтение байта //============================================================================= u16 ByteOrderConverter::read() { if (!data || isEnd()) return 0; if (byte_order == eboHighFirst) return __byte(data, cnt - cur_index++); return __byte(data, cur_index++); }
void AdventureScene::addRunningTask() { AdventureTask* runningTaskNewest = getRunningTaskNewest(); if (runningTaskNewest == nullptr || !(runningTaskNewest->wait())) { if (!isEnd()) { m_runningTaskList.push_back(getCurrentTask()); m_current++; std::cout << "m_current: " << m_current << std::endl; } } }
void strategyDriverTimerCallback(Timer* timer) { // enabled only if robot started if (!isStarted()) { return; } // disabled after end if (isEnd()) { return; } strategyDriverInterruptCounter++; }
uint VFile::read(void* buffer, uint len) { if (isEnd()) return 0; uint realSize = len; if (m_ptrCur + len > m_ptrSrc + m_size) realSize = (unsigned long)m_ptrSrc + (unsigned long)m_size - (unsigned long)m_ptrCur; memcpy(buffer, m_ptrCur, realSize); m_ptrCur += realSize; return realSize; }
uv_err_t UVDBfdInstructionIterator::next() { while( true ) { if( isEnd() ) { //Loop logic is actually handled here uv_assert_err_ret(initNextValidSection()); break; } else { m_curOffset = m_nextOffset; uv_assert_err_ret(dissassembleCur()); break; } } return UV_ERR_OK; }
void RPNScript::run(bool debug) { curCmd = 0; if (debug) printf("RPN running started from %d/%d command\n", curCmd, count - 1); while (!isEnd()) { if (debug) printf("RPN running %d/%d command ", curCmd, count - 1); if (debug) (*this)[curCmd].print(*master); if (debug) printf("\nRPN stack on begin:\n"); if (debug) stack->print(); runStep(); if (debug) printf("\n"); } }
int main(int argc, char *argv[]) { const uint64_t storage_size = sizeof(mdb::Page::Header) + (sizeof(mdb::Meas) * pagesize); mdb::Storage::Storage_ptr ds = mdb::Storage::Create(storage_path, storage_size); ds->enableCacheDynamicSize(enable_dyn_cache); ds->setPoolSize(cache_pool_size); ds->setCacheSize(cache_size); auto writes_count = 3000000; std::cout << "write " << writes_count << " values..." << std::endl; clock_t write_t0 = clock(); mdb::Meas meas = mdb::Meas::empty(); for (int i = 0; i < 3000000; ++i) { meas.value = i; meas.id = i % 10; meas.source = meas.flag = 0; meas.time = i; ds->append(meas); } clock_t write_t1 = clock(); std::cout << "write time: " << ((float)write_t1 - write_t0) / CLOCKS_PER_SEC << std::endl; std::cout << "read all values..." << std::endl; clock_t read_t0 = clock(); mdb::Meas::MeasList output; auto reader = ds->readInterval(0, writes_count); // or meases->readAll(&output); while (!reader->isEnd()) { reader->readNext(&output); } clock_t read_t1 = clock(); std::cout<<"read time :" << ((float)read_t1 - read_t0) / CLOCKS_PER_SEC<<std::endl; ds->Close(); }
bool AstarFlexible::checkNearby() { int i=0,j=0,x=0,y=0,k=0,g=0,h=0; AstarNode* searchedNode; for(;k<DEFAULT_NEARS_LENGTH;k++){ //near=defaultNears[k]; i=defaultNears[k][0]; j=defaultNears[k][1]; x=m_current->getX()+i; y=m_current->getY()+j; //结束提前,可对目标是障碍物进行寻路。(例:人物要对某个建筑进行操作,比如攻击,要走到建筑旁边才可以) if (isEnd(x,y ,i ,j)) {//如果是斜着寻路,则要对旁边是否有障碍物进行判断。 return true;//查找成功 } if(!isOut(x,y) && isWorkableWithCrossSide(x ,y ,i ,j)){ if(!isInClose(x ,y)){ g=m_current->getG()+(i==0||j==0?ASTAR_G_LINE:ASTAR_G_CROSS); searchedNode=getFromOpen(x ,y); if(searchedNode!=NULL){ //在开起列表中,比较G值 if (g < searchedNode->getG()) { //有最小F值,重新排序 setOpenSeqNode(searchedNode,g); } }else { //没有搜索过,直接添加到开起列表中 h=getH(x ,y); AstarNode* astarNode=new AstarNode(); astarNode->init(x ,y,g,h); astarNode->setParent(m_current); addToOpen(astarNode); astarNode->release(); } } } } return false; }
static bool contains(const Node& root, int value) { const Node* currNode = &root; while (currNode != NULL &&!isEnd(currNode)) { if (currNode->getValue() == value) return true; if (currNode->getValue() > value) currNode = currNode->getLeft(); else currNode = currNode->getRight(); } if (currNode && currNode->getValue() == value) return true; return false; }
int cMessageSender::Start(SOCKET Sock, bool isTcp) { if(isEnd() == false) { Stop(); } SetEnd(false); SetSock(Sock); if(isTcp) m_pThread = new std::thread(ThreadJob, this); else m_pThread = new std::thread(UdpThreadJob, this); return 0; }
/* <fun> <fun> <fun> ... */ static Funs *funs() { Funs *p = 0; Fun *first = fun(); if (first) { p = NEW(Funs); p->first = first; p->rest = funs(); if (p->rest) { p->n = p->rest->n + 1; } else { p->n = 1; } } if (!isEnd()) error(); return p; }
int cMessageSender::Stop() { if(isEnd()) return -1; SetEnd(true); Sleep(100); if(m_pThread != NULL) { m_pThread->join(); delete m_pThread; m_pThread = NULL; } return 0; }
bool AstarFlexible::search() { //如果开始和结束点是同一点、终点超出范围,不必寻路。 if (isEnd(m_start->getX(),m_start->getY())|| isOut(m_end->getX(),m_end->getY())){ return false; } while (m_openSeq->count()) { //取得下一个搜索点 getNext(); removeFromOpen(m_current); //添加到closes addToClose(m_current->getX(),m_current->getY()); //处理相邻结点 if(checkNearby()){ return true; } } return false; }