void HostileRefManager::setOnlineOfflineState(bool pIsOnline) { HostileReference* ref; ref = getFirst(); while (ref != NULL) { ref->setOnlineOfflineState(pIsOnline); ref = ref->next(); } }
void HostileRefManager::deleteReferences() { HostileReference* ref = getFirst(); while(ref) { HostileReference* nextRef = ref->next(); ref->removeReference(); delete ref; ref = nextRef; } }
void HostileRefManager::addThreatPercent(int32 pValue) { HostileReference* ref; ref = getFirst(); while (ref != NULL) { ref->addThreatPercent(pValue); ref = ref->next(); } }
ElemType pop(Stack * stack){ ElemType x = NULL; ListNode * node; if(stack->size > 0){ node = getFirst(stack->elem); x = node->data; deleteListNode(node); stack->size--; } return x; }
bool ScriptLoadRequestList::Contains(ScriptLoadRequest* aElem) const { for (const ScriptLoadRequest* req = getFirst(); req; req = req->getNext()) { if (req == aElem) { return true; } } return false; }
void HostileRefManager::threatAssist(Unit *pVictim, float pThreat, SpellEntry const *pThreatSpell, bool pSingleTarget) { uint32 size = pSingleTarget ? 1 : getSize(); // if pSingleTarget do not devide threat float threat = pThreat/size; HostileReference* ref = getFirst(); while (ref) { ref->getSource()->addThreat(pVictim, threat, false, (pThreatSpell ? GetSpellSchoolMask(pThreatSpell) : SPELL_SCHOOL_MASK_NORMAL), pThreatSpell); ref = ref->next(); } }
int meshOperation::getNext_bc( int center_index, int v, mesh& m, bool * trueNeighbor ) { int next = getNext(center_index,v,m); if(trueNeighbor != NULL){ *trueNeighbor = next >= 0; } if(next < 0){ return getFirst(center_index,v,m); } return next; }
int priority(const intTriple& givenTag,sorContext& graph) const { int row = getFirst(givenTag); int column = getSecond(givenTag); int iteration = getThird(givenTag); //calculate width of wavefronts of diagonals, so that there would only be 20 wavefronts #if 0 static int diagonalWidth = (nRowsOfTiles+nColumnsOfTiles+nIterations-3)/20+1; return (((row+column+iteration)/diagonalWidth)%20); #endif return row + column + iteration + iteration; }
void HostileRefManager::setOnlineOfflineState(bool pIsOnline) { HostileReference* ref; ref = getFirst(); while(ref != NULL) { if(iOwner->GetMapId() == ref->getSource()->getOwner()->GetMapId()) ref->setOnlineOfflineState(pIsOnline); ref = ref->next(); } }
// --------------------------------------------------------------------------------- // count - counts the cards in the list // --------------------------------------------------------------------------------- unsigned int count(void) { Card *pThis = getFirst(); unsigned int thisCount = 0; while (pThis != NULL) { ++thisCount; pThis = pThis->pNext_; } return thisCount; }
inline BedType* ReadLine() { static const bool done = false; static BedType* tmp = static_cast<BedType*>(0); static const IterType end; // lpad_ may be +, rpad_ may be -. In either case, padding may cause an element to become // a non-element (vaporizes). Nothing in the cache_ is a problem. Only need to // check when reading something new from iter_. while ( !done ) { if ( !cache_.empty() ) { // get from the cache_ tmp = cache_.back(); cache_.pop_back(); if ( lpad_ < 0 ) // else, don't waste time on next unimportant assignment lastChr_ = tmp->chrom(); return(tmp); } else if ( iter_ == end ) { // && cache_.empty() return(static_cast<BedType*>(0)); } else { // read from iter_ tmp = *iter_; // cannot post-increment here due to lpad_ < 0 && getFirst() possibility if ( rpad_ < 0 || lpad_ > 0 ) { // tmp->end() is an Bed::CoordType; must cast ++iter_; tmp->start(tmp->start() + lpad_); if ( static_cast<double>(tmp->end()) + rpad_ > tmp->start() ) { tmp->end(tmp->end() + rpad_); return(tmp); } else // tmp vaporized by padding delete tmp; } else if ( lpad_ < 0 ) { if ( tmp->chrom() != lastChr_ ) { // cache_ is empty && iter_ != end getFirst(); // iter_ increments dealt with in getFirst() tmp = cache_.back(); // next item may have changed after getFirst() cache_.pop_back(); lastChr_ = tmp->chrom(); } else { // getFirst() already dealt with any padding issues on this chromosome tmp->start(tmp->start() + lpad_); tmp->end(tmp->end() + rpad_); ++iter_; } return(tmp); } else if ( rpad_ > 0 ) { tmp->start(tmp->start() + lpad_); tmp->end(tmp->end() + rpad_); ++iter_; return(tmp); } else { ++iter_; return(tmp); } } } // while }
void List<T>::pushFirst(const T& data) { Node<T>* newFirst = new Node<T>(data); if (debug) { std::cout << "DEBUG: " << "Pushing " << newFirst << " to first" << std::endl; } if (hasFirst()) { getFirst()->setPrev(newFirst); newFirst->setNext(getFirst()); } if (!hasLast()) { setLast(newFirst); } setFirst(newFirst); }
/* Quote function works well. */ Value* evalQuote(Value* args){ if (getFirst(args) && getFirst(args)->type==closeType){ printf("quote: bad syntax (wrong number of parts) in: (quote)"); return NULL; // since there is one argument list and one close parenthese, the listLength should return zero. }else if (listLength(args) != 1){ printf("quote: bad syntax (wrong number of parts) in: (quote "); printValue(args); printf("\n"); return NULL; } else{ assert(getFirst(getTail(args))!=NULL); assert(getFirst(getTail(args))->type==closeType); Value *toRemove = getTail(args); free(toRemove->cons->car); free(toRemove->cons); free(toRemove); args->cons->cdr = NULL; return args; } }
Node<T> List<T>::popFirst() { if (hasFirst()) { Node<T> oldFirst = *getFirst(); if (getFirst() == getLast()) { setLast(NULL); } delete getFirst(); if (oldFirst.hasNext()) { oldFirst.getNext()->setPrev(NULL); setFirst(oldFirst.getNext()); } else { setFirst(NULL); } return oldFirst; } return NULL; }
/** * this function ADDs a list of selected item names into 'names'. * it assumes the list is ready and doesn't initialize it, or clears it */ void KrView::getSelectedItems(QStringList *names, bool ignoreJustFocused) { for (KrViewItem * it = getFirst(); it != 0; it = getNext(it)) if (it->isSelected() && (it->name() != "..")) names->append(it->name()); // if all else fails, take the current item if (!ignoreJustFocused) { QString item = getCurrentItem(); if (names->empty() && !item.isEmpty() && item != "..") { names->append(item); } } }
void HostileRefManager::threatAssist(Unit* victim, float baseThreat, SpellInfo const* threatSpell) { HostileReference* ref = getFirst(); float threat = ThreatCalcHelper::calcThreat(victim, iOwner, baseThreat, (threatSpell ? threatSpell->GetSchoolMask() : SPELL_SCHOOL_MASK_NORMAL), threatSpell); threat /= getSize(); while (ref) { if (ThreatCalcHelper::isValidProcess(victim, ref->getSource()->getOwner(), threatSpell)) ref->getSource()->doAddThreat(victim, threat); ref = ref->next(); } }
BOOL MyContainer::setupItems() { pCnrRecord pcn; HPOINTER hptr; if (isEmpty()) return(TRUE); hptr = WinLoadPointer(HWND_DESKTOP, 0, SAMPLE_MAIN); pcn = allocRecords(numberOfElements()); if(pcn) { RECORDINSERT ri; ULONG counter = 1; pCnrRecord pcnFirst = pcn; pMyRecord record = getFirst(); while(record) { record->Position = counter; pcn->recordCore.cb = sizeof(RECORDCORE); pcn->recordCore.pszText = record->Name; pcn->recordCore.pszIcon = record->Name; pcn->recordCore.pszName = record->Name; pcn->recordCore.hptrIcon = hptr; pcn->Name = record->Name; pcn->Position = record->Position; pcn = (pCnrRecord) pcn->recordCore.preccNextRecord; record = getNext(); counter++; } memset(&ri, 0, sizeof(RECORDINSERT)); ri.cb = sizeof(RECORDINSERT); ri.pRecordOrder = (PRECORDCORE) CMA_END; ri.pRecordParent = (PRECORDCORE) NULL; ri.zOrder = (USHORT) CMA_TOP; ri.cRecordsInsert = numberOfElements(); ri.fInvalidateRecord = TRUE; // insert them in one shot if (insertRecord(pcnFirst, &ri)) { WinSendMsg(parent, WM_CNR_STATUS, MPFROMP("Completed."), NULL); return(TRUE); } } return(FALSE); }
void XACTWaveBank_ASCII::load(Common::SeekableReadStream &xwb) { Common::StreamTokenizer tokenizer(Common::StreamTokenizer::kRuleIgnoreAll); tokenizer.addSeparator(' '); tokenizer.addChunkEnd('\n'); tokenizer.addIgnore('\r'); tokenizer.addIgnore('\"'); _name = getFirst(tokenizer, xwb); _streaming = getFirst(tokenizer, xwb).equalsIgnoreCase("STREAMING"); size_t waveCount; Common::parseString(getFirst(tokenizer, xwb), waveCount); _waves.resize(waveCount); for (auto &wave : _waves) { std::vector<Common::UString> strings; tokenizer.getTokens(xwb, strings); if (strings.size() != 8) throw Common::Exception("ACTWaveBank_ASCII::load(): Invalid wave declaration"); wave.name = Common::FilePath::getStem(strings[1]); wave.type = strings[0]; Common::parseString(strings[2], wave.samplingRate); Common::parseString(strings[3], wave.channels); Common::parseString(strings[4], wave.bitRate); Common::parseString(strings[5], wave.size); Common::parseString(strings[6], wave.loopOffset); Common::parseString(strings[7], wave.loopLength); wave.bitRate = (wave.bitRate / wave.channels) * 8; tokenizer.nextChunk(xwb); } }
void KrView::getSelectedKrViewItems(KrViewItemList *items) { for (KrViewItem * it = getFirst(); it != 0; it = getNext(it)) if (it->isSelected() && (it->name() != "..")) items->append(it); // if all else fails, take the current item QString item = getCurrentItem(); if (items->empty() && !item.isEmpty() && item != ".." && getCurrentKrViewItem() != 0) { items->append(getCurrentKrViewItem()); } }
void HostileRefManager::setOnlineOfflineState(Unit *pCreature,bool pIsOnline) { HostileReference* ref = getFirst(); while(ref) { HostileReference* nextRef = ref->next(); if(ref->getSource()->getOwner() == pCreature) { ref->setOnlineOfflineState(pIsOnline); break; } ref = nextRef; } }
void HostileRefManager::deleteReferencesForFaction(uint32 faction) { HostileReference* ref = getFirst(); while(ref) { HostileReference* nextRef = ref->next(); if(ref->getSource()->getOwner()->getFactionTemplateEntry()->faction == faction) { ref->removeReference(); delete ref; } ref = nextRef; } }
ReceiverList* ReceiverList::lookup(const char* processName,const char* receiverName) { for(ReceiverList* p = getFirst(); p; p = p->getNext()) { char buf[80]; ASSERT(strlen(processName) + strlen(p->name) + 1 < sizeof(buf)); strcpy(buf,processName), strcat(buf,"."); strcat(buf,p->name); if(!strcmp(buf,receiverName)) return p; } return 0; }
// This function evaluates if statement. Value* evalIf(Value* args, Environment* env){ // args = evalEach(args,env); int count = listLength(args); //printf("count = %d \n",count); // printValue(getTail(args)); // printValue(getTail(getTail(args))); if (count < 2) { printf("syntax error: too few arguments in if statement\n"); return NULL; } if ( count > 3) { printf("syntax error: too many arguments in if statement\n"); return NULL; } Value *evalTest = eval(getFirst(args), env); // Value *tempArgs; // printf("result: %d", evalTest->type); if (evalTest && evalTest->type == booleanType && !(evalTest->boolValue)) { // if evalTest is false, then return eval(alternate) // if no alternate, just returns NULL if (count == 3) { return eval(getFirst(getTail(getTail(args))), env); } else return NULL; // DRracket doesn't return a '(), it returns nothing (NULL) } else { // else return eval(consequence) return eval(getFirst(getTail(args)), env); // return eval(alternate) } }
void TreeDiagram::computeLayout() { QListIterator<DiagramRow> it(*this); DiagramRow *row; for (;(row=it.current()) && row->count()<maxTreeWidth;++it) {} if (row) { //printf("computeLayout() list row at %d\n",row->number()); QListIterator<DiagramItem> rit(*row); DiagramItem *di; DiagramItem *opi=0; int delta=0; bool first=TRUE; for (;(di=rit.current());++rit) { DiagramItem *pi=di->parentItem(); if (pi==opi && !first) { delta-=gridWidth; } first = pi!=opi; opi=pi; di->move(delta,0); // collapse all items in the same // list (except the first) di->putInList(); } } // re-organize the diagram items DiagramItem *root=getFirst()->getFirst(); while (layoutTree(root,0)) { } // move first items of the lists if (row) { QListIterator<DiagramItem> rit(*row); DiagramItem *di; while ((di=rit.current())) { DiagramItem *pi=di->parentItem(); if (pi->getChildren()->count()>1) { di->move(gridWidth,0); while (di && di->parentItem()==pi) { ++rit; di=rit.current(); } } else { ++rit; } } } }
void HostileRefManager::deleteReference(Unit *pCreature) { HostileReference* ref = getFirst(); while(ref) { HostileReference* nextRef = ref->next(); if(ref->getSource()->getOwner() == pCreature) { ref->removeReference(); delete ref; break; } ref = nextRef; } }
void HostileRefManager::UpdateVisibility() { HostileReference* ref = getFirst(); while (ref) { HostileReference* nextRef = ref->next(); if (!ref->GetSource()->getOwner()->CanSeeOrDetect(GetOwner())) { nextRef = ref->next(); ref->removeReference(); delete ref; } ref = nextRef; } }
void HostileRefManager::UpdateVisibility(bool checkThreat) { HostileReference* ref = getFirst(); while (ref) { HostileReference* nextRef = ref->next(); if ((!checkThreat || ref->GetSource()->getThreatList().size() <= 1) && !ref->GetSource()->GetOwner()->CanSeeOrDetect(GetOwner())) { nextRef = ref->next(); ref->removeReference(); delete ref; } ref = nextRef; } }
void HostilRefManager::threatAssist(Unit *pVictim, float fThreat, SpellEntry const *pThreatSpell, bool pSingleTarget) { HostilReference* ref; float size = pSingleTarget ? 1.0f : getSize(); // if pSingleTarget do not divide threat ref = getFirst(); while(ref != NULL) { float threat = ThreatCalcHelper::calcThreat(pVictim, iOwner, fThreat, (pThreatSpell ? GetSpellSchoolMask(pThreatSpell) : SPELL_SCHOOL_MASK_NORMAL), pThreatSpell); if(pVictim == getOwner()) ref->addThreat(threat / size); // It is faster to modify the threat durectly if possible else ref->getSource()->addThreat(pVictim, threat / size); ref = ref->next(); } }
CoreAttributesList::~CoreAttributesList() { if (autoDelete()) { /* We need to make sure that the CoreAttributes are first removed from * the list and then deleted. */ setAutoDelete(false); while (!isEmpty()) { CoreAttributes* tp = getFirst(); removeRef(tp); delete tp; } setAutoDelete(true); } }
void HostileRefManager::deleteReferencesOutOfRange(float range) { HostileReference* ref = getFirst(); range = range*range; while (ref) { HostileReference* nextRef = ref->next(); Unit* owner = ref->GetSource()->GetOwner(); if (!owner->isActiveObject() && owner->GetExactDist2dSq(GetOwner()) > range) { ref->removeReference(); delete ref; } ref = nextRef; } }