本文整理汇总了C++中elementAt函数的典型用法代码示例。如果您正苦于以下问题:C++ elementAt函数的具体用法?C++ elementAt怎么用?C++ elementAt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elementAt函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: locker
CreatureObject* ThreatMap::getHighestDamagePlayer() {
Locker locker(&lockMutex);
uint32 maxDamage = 0;
VectorMap<uint64,uint32> damageMap;
CreatureObject* player = NULL;
for (int i = 0; i < size(); ++i) {
ThreatMapEntry* entry = &elementAt(i).getValue();
uint32 totalDamage = 0;
for (int j = 0; j < entry->size(); ++j) {
uint32 damage = entry->elementAt(j).getValue();
totalDamage += damage;
}
CreatureObject* creature = elementAt(i).getKey();
if (creature->isPlayerCreature()) {
if(!damageMap.contains(creature->getObjectID())){
damageMap.put(creature->getObjectID(),totalDamage);
} else {
damageMap.get(creature->getObjectID()) += totalDamage;
}
if (damageMap.get(creature->getObjectID()) > maxDamage) {
maxDamage = damageMap.get(creature->getObjectID());
player = cast<CreatureObject*>(creature);
}
} else if (creature->isPet()) {
CreatureObject* owner = creature->getLinkedCreature().get();
if (owner != NULL && owner->isPlayerCreature()) {
if(!damageMap.contains(owner->getObjectID())){
damageMap.put(owner->getObjectID(),totalDamage);
} else {
damageMap.get(owner->getObjectID()) += totalDamage;
}
if (damageMap.get(owner->getObjectID()) > maxDamage) {
maxDamage = damageMap.get(owner->getObjectID());
player = cast<CreatureObject*>(owner);
}
}
}
}
return player;
}
示例2: while
Groundfloor::StringVectorRange *Groundfloor::StringVector::translatePosToChunkedIndex( unsigned long iPos ) {
Groundfloor::StringVectorRange *range = new Groundfloor::StringVectorRange();
unsigned int cChunkLen = 0;
unsigned int iCurChunk = 0;
unsigned long iLenTodo = iPos;
while ( iLenTodo != 0 ) {
Groundfloor::String *sChunk = static_cast<Groundfloor::String *>( elementAt(iCurChunk) );
if ( sChunk != NULL ) {
cChunkLen = sChunk->getLength();
if ( cChunkLen > iLenTodo ) {
range->start_ind = iCurChunk;
range->start_pos = iLenTodo;
break;
}
iLenTodo -= cChunkLen;
iCurChunk++;
} else {
break;
}
}
return range;
}
示例3: getIndex
virtual int getIndex(const XMLCh* const qName ) const
{
for(XMLSize_t i=0;i<size();i++)
if(XMLString::equals(elementAt(i)->qName,qName))
return (int)i;
return -1;
}
示例4: locker
void ThreatMap::addDamage(CreatureObject* target, uint32 damage, String xp) {
Locker locker(&lockMutex);
ManagedReference<TangibleObject*> strongSelf = self.get();
if (strongSelf == NULL || strongSelf.get() == target)
return;
int idx = find(target);
String xpToAward = "";
if (xp == "") {
WeaponObject* weapon = target->getWeapon();
xpToAward = weapon->getXpType();
} else
xpToAward = xp;
if (idx == -1) {
ThreatMapEntry entry;
entry.addDamage(xpToAward, damage);
entry.addAggro(1);
put(target, entry);
registerObserver(target);
} else {
ThreatMapEntry* entry = &elementAt(idx).getValue();
entry->addDamage(xpToAward, damage);
entry->addAggro(1);
}
}
示例5: size
void* UStack::pop(void) {
int32_t n = size() - 1;
void* result = 0;
if (n >= 0) {
result = elementAt(n);
removeElementAt(n);
}
return result;
}
示例6: locker
void DamageOverTimeList::clear(CreatureObject* creature) {
Locker locker(&guard);
dot = false;
for (int i = 0; i < size(); ++i) {
uint64 type = elementAt(i).getKey();
Vector<DamageOverTime>* vector = &elementAt(i).getValue();
for (int j = 0; j < vector->size(); ++j) {
DamageOverTime* dot = &vector->elementAt(j);
creature->clearState(dot->getType());
}
}
removeAll();
}
示例7: elementAt
void Groundfloor::StringVector::endMinusOne( Groundfloor::StringVectorRange *range ) {
if ( range->end_pos == 0 ) {
range->end_ind--;
Groundfloor::String *sChunk = static_cast<Groundfloor::String *>( elementAt(range->end_ind) );
range->end_pos = sChunk->getLength() - 1;
} else {
range->end_pos--;
}
}
示例8: valueAt
bool Xml::valueAt(QDomElement parent, QString path, QString &value) {
value.clear();
QDomElement element;
if(elementAt(parent, path, element)) {
value = element.text().trimmed();
return true;
}
return false;
}
示例9: find
void ThreatMapEntry::addDamage(String xp, uint32 damage) {
int idx = find(xp);
if (idx == -1) {
put(xp, damage);
} else {
uint32* dmg = &elementAt(idx).getValue();
*dmg = *dmg + damage;
}
}