mirror of https://github.com/axmolengine/axmol.git
Removes Vector<T>::forEach, please use std::for_each instead. The same as Vector<T>::sort.
This commit is contained in:
parent
8d6fa58cc5
commit
d16fa07661
|
@ -158,7 +158,7 @@ Vector<Node*> ActionManager::pauseAllRunningActions()
|
|||
|
||||
void ActionManager::resumeTargets(const Vector<Node*>& targetsToResume)
|
||||
{
|
||||
targetsToResume.forEach([this](Node* node){
|
||||
std::for_each(targetsToResume.begin(), targetsToResume.end(), [this](Node* node){
|
||||
this->resumeTarget(node);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -40,7 +40,8 @@ static void setProgram(Node *n, GLProgram *p)
|
|||
{
|
||||
n->setShaderProgram(p);
|
||||
|
||||
n->getChildren().forEach([p](Node* child){
|
||||
auto& children = n->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [p](Node* child){
|
||||
setProgram(child, p);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -305,7 +305,7 @@ void Label::alignText()
|
|||
LabelTextFormatter::alignText(this);
|
||||
|
||||
int strLen = cc_wcslen(_currentUTF16String);
|
||||
_children.forEach([this,&strLen](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [this,&strLen](Node* child){
|
||||
if (child)
|
||||
{
|
||||
int tag = child->getTag();
|
||||
|
@ -522,7 +522,7 @@ void Label::draw()
|
|||
_shaderProgram->setUniformLocationWith3f(_uniformEffectColor, _effectColor.r/255.0f,_effectColor.g/255.0f,_effectColor.b/255.0f);
|
||||
}
|
||||
|
||||
_children.forEach([](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [](Node* child){
|
||||
child->updateTransform();
|
||||
});
|
||||
|
||||
|
@ -710,7 +710,7 @@ void Label::setOpacityModifyRGB(bool isOpacityModifyRGB)
|
|||
{
|
||||
_isOpacityModifyRGB = isOpacityModifyRGB;
|
||||
|
||||
_children.forEach([this](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [this](Node* child){
|
||||
if (child)
|
||||
{
|
||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(child);
|
||||
|
@ -752,7 +752,7 @@ void Label::updateDisplayedOpacity(GLubyte parentOpacity)
|
|||
{
|
||||
_displayedOpacity = _realOpacity * parentOpacity/255.0;
|
||||
|
||||
_children.forEach([this](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [this](Node* child){
|
||||
Sprite *item = static_cast<Sprite*>( child );
|
||||
item->updateDisplayedOpacity(_displayedOpacity);
|
||||
});
|
||||
|
@ -818,7 +818,7 @@ void Label::updateDisplayedColor(const Color3B& parentColor)
|
|||
_displayedColor.g = _realColor.g * parentColor.g/255.0;
|
||||
_displayedColor.b = _realColor.b * parentColor.b/255.0;
|
||||
|
||||
_children.forEach([this](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [this](Node* child){
|
||||
Sprite *item = static_cast<Sprite*>( child );
|
||||
item->updateDisplayedColor(_displayedColor);
|
||||
});
|
||||
|
|
|
@ -747,7 +747,7 @@ void LabelBMFont::setString(unsigned short *newString, bool needUpdateLabel)
|
|||
CC_SAFE_DELETE_ARRAY(tmp);
|
||||
}
|
||||
|
||||
_children.forEach([](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [](Node* child){
|
||||
child->setVisible(false);
|
||||
});
|
||||
|
||||
|
@ -823,7 +823,7 @@ void LabelBMFont::setOpacity(GLubyte opacity)
|
|||
void LabelBMFont::setOpacityModifyRGB(bool var)
|
||||
{
|
||||
_isOpacityModifyRGB = var;
|
||||
_children.forEach([this](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [this](Node* child){
|
||||
if (child)
|
||||
{
|
||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(child);
|
||||
|
@ -843,7 +843,7 @@ void LabelBMFont::updateDisplayedOpacity(GLubyte parentOpacity)
|
|||
{
|
||||
_displayedOpacity = _realOpacity * parentOpacity/255.0f;
|
||||
|
||||
_children.forEach([this](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(),[this](Node* child){
|
||||
Sprite *item = static_cast<Sprite*>( child );
|
||||
item->updateDisplayedOpacity(_displayedOpacity);
|
||||
});
|
||||
|
@ -855,7 +855,7 @@ void LabelBMFont::updateDisplayedColor(const Color3B& parentColor)
|
|||
_displayedColor.g = _realColor.g * parentColor.g/255.0f;
|
||||
_displayedColor.b = _realColor.b * parentColor.b/255.0f;
|
||||
|
||||
_children.forEach([this](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(),[this](Node* child){
|
||||
Sprite *item = static_cast<Sprite*>( child );
|
||||
item->updateDisplayedColor(_displayedColor);
|
||||
});
|
||||
|
|
|
@ -507,7 +507,7 @@ void LayerRGBA::updateDisplayedOpacity(GLubyte parentOpacity)
|
|||
|
||||
if (_cascadeOpacityEnabled)
|
||||
{
|
||||
_children.forEach([this](Node* obj){
|
||||
std::for_each(_children.begin(), _children.end(),[this](Node* obj){
|
||||
RGBAProtocol *item = dynamic_cast<RGBAProtocol*>(obj);
|
||||
if (item)
|
||||
{
|
||||
|
@ -525,7 +525,7 @@ void LayerRGBA::updateDisplayedColor(const Color3B& parentColor)
|
|||
|
||||
if (_cascadeColorEnabled)
|
||||
{
|
||||
_children.forEach([this](Node* obj){
|
||||
std::for_each(_children.begin(), _children.end(),[this](Node* obj){
|
||||
RGBAProtocol *item = dynamic_cast<RGBAProtocol*>(obj);
|
||||
if (item)
|
||||
{
|
||||
|
@ -952,7 +952,7 @@ LayerMultiplex::LayerMultiplex()
|
|||
|
||||
LayerMultiplex::~LayerMultiplex()
|
||||
{
|
||||
_layers.forEach([](Layer* layer){
|
||||
std::for_each(_layers.begin(), _layers.end(), [](Layer* layer){
|
||||
layer->cleanup();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -291,7 +291,7 @@ void Menu::alignItemsVerticallyWithPadding(float padding)
|
|||
{
|
||||
float height = -padding;
|
||||
|
||||
_children.forEach([&](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [&](Node* child){
|
||||
if (child)
|
||||
{
|
||||
height += child->getContentSize().height * child->getScaleY() + padding;
|
||||
|
@ -300,7 +300,7 @@ void Menu::alignItemsVerticallyWithPadding(float padding)
|
|||
|
||||
float y = height / 2.0f;
|
||||
|
||||
_children.forEach([&](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [&](Node* child){
|
||||
if (child)
|
||||
{
|
||||
child->setPosition(Point(0, y - child->getContentSize().height * child->getScaleY() / 2.0f));
|
||||
|
@ -317,7 +317,7 @@ void Menu::alignItemsHorizontally(void)
|
|||
void Menu::alignItemsHorizontallyWithPadding(float padding)
|
||||
{
|
||||
float width = -padding;
|
||||
_children.forEach([&](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [&](Node* child){
|
||||
if (child)
|
||||
{
|
||||
width += child->getContentSize().width * child->getScaleX() + padding;
|
||||
|
@ -326,7 +326,7 @@ void Menu::alignItemsHorizontallyWithPadding(float padding)
|
|||
|
||||
float x = -width / 2.0f;
|
||||
|
||||
_children.forEach([&](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [&](Node* child){
|
||||
if (child)
|
||||
{
|
||||
child->setPosition(Point(x + child->getContentSize().width * child->getScaleX() / 2.0f, 0));
|
||||
|
@ -365,7 +365,7 @@ void Menu::alignItemsInColumnsWithArray(const ValueVector& rows)
|
|||
int columnsOccupied = 0;
|
||||
int rowColumns = 0;
|
||||
|
||||
_children.forEach([&](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [&](Node* child){
|
||||
if (child)
|
||||
{
|
||||
CCASSERT(row < rows.size(), "");
|
||||
|
@ -401,7 +401,7 @@ void Menu::alignItemsInColumnsWithArray(const ValueVector& rows)
|
|||
float x = 0.0;
|
||||
float y = (float)(height / 2);
|
||||
|
||||
_children.forEach([&](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [&](Node* child){
|
||||
if (child)
|
||||
{
|
||||
if (child)
|
||||
|
@ -469,7 +469,7 @@ void Menu::alignItemsInRowsWithArray(const ValueVector& columns)
|
|||
int rowsOccupied = 0;
|
||||
int columnRows;
|
||||
|
||||
_children.forEach([&](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [&](Node* child){
|
||||
if (child)
|
||||
{
|
||||
// check if too many menu items for the amount of rows/columns
|
||||
|
@ -511,7 +511,7 @@ void Menu::alignItemsInRowsWithArray(const ValueVector& columns)
|
|||
float x = (float)(-width / 2);
|
||||
float y = 0.0;
|
||||
|
||||
_children.forEach([&](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [&](Node* child){
|
||||
if (child)
|
||||
{
|
||||
if (columnRows == 0)
|
||||
|
|
|
@ -918,7 +918,7 @@ void MenuItemToggle::addSubItem(MenuItem *item)
|
|||
|
||||
MenuItemToggle::~MenuItemToggle()
|
||||
{
|
||||
_subItems.forEach([](MenuItem* item){
|
||||
std::for_each(_subItems.begin(), _subItems.end(), [](MenuItem* item){
|
||||
item->cleanup();
|
||||
});
|
||||
}
|
||||
|
@ -970,7 +970,7 @@ void MenuItemToggle::setEnabled(bool enabled)
|
|||
{
|
||||
MenuItem::setEnabled(enabled);
|
||||
|
||||
_subItems.forEach([&enabled](MenuItem* item){
|
||||
std::for_each(_subItems.begin(), _subItems.end(), [&enabled](MenuItem* item){
|
||||
item->setEnabled(enabled);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -576,7 +576,7 @@ void Node::cleanup()
|
|||
}
|
||||
|
||||
// timers
|
||||
_children.forEach([](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [](Node* child){
|
||||
child->cleanup();
|
||||
});
|
||||
}
|
||||
|
@ -939,7 +939,7 @@ void Node::onEnter()
|
|||
{
|
||||
_isTransitionFinished = false;
|
||||
|
||||
_children.forEach([](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [](Node* child){
|
||||
child->onEnter();
|
||||
});
|
||||
|
||||
|
@ -960,7 +960,7 @@ void Node::onEnterTransitionDidFinish()
|
|||
{
|
||||
_isTransitionFinished = true;
|
||||
|
||||
_children.forEach([](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [](Node* child){
|
||||
child->onEnterTransitionDidFinish();
|
||||
});
|
||||
|
||||
|
@ -975,7 +975,7 @@ void Node::onEnterTransitionDidFinish()
|
|||
|
||||
void Node::onExitTransitionDidStart()
|
||||
{
|
||||
_children.forEach([](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [](Node* child){
|
||||
child->onExitTransitionDidStart();
|
||||
});
|
||||
|
||||
|
@ -1001,7 +1001,7 @@ void Node::onExit()
|
|||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
|
||||
}
|
||||
|
||||
_children.forEach([](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [](Node* child){
|
||||
child->onExit();
|
||||
});
|
||||
}
|
||||
|
@ -1413,7 +1413,7 @@ bool Node::updatePhysicsTransform()
|
|||
void Node::updateTransform()
|
||||
{
|
||||
// Recursively iterate over children
|
||||
_children.forEach([](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [](Node* child){
|
||||
child->updateTransform();
|
||||
});
|
||||
}
|
||||
|
@ -1524,7 +1524,7 @@ void NodeRGBA::updateDisplayedOpacity(GLubyte parentOpacity)
|
|||
|
||||
if (_cascadeOpacityEnabled)
|
||||
{
|
||||
_children.forEach([this](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [this](Node* child){
|
||||
RGBAProtocol* item = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (item)
|
||||
{
|
||||
|
@ -1579,7 +1579,7 @@ void NodeRGBA::updateDisplayedColor(const Color3B& parentColor)
|
|||
|
||||
if (_cascadeColorEnabled)
|
||||
{
|
||||
_children.forEach([this](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [this](Node* child){
|
||||
RGBAProtocol *item = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (item)
|
||||
{
|
||||
|
|
|
@ -385,7 +385,7 @@ void ParticleBatchNode::removeChildAtIndex(int index, bool doCleanup)
|
|||
|
||||
void ParticleBatchNode::removeAllChildrenWithCleanup(bool doCleanup)
|
||||
{
|
||||
_children.forEach([](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [](Node* child){
|
||||
static_cast<ParticleSystem*>(child)->setBatchNode(nullptr);
|
||||
});
|
||||
|
||||
|
@ -481,7 +481,7 @@ void ParticleBatchNode::updateAllAtlasIndexes()
|
|||
{
|
||||
int index = 0;
|
||||
|
||||
_children.forEach([&index](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [&index](Node* child){
|
||||
ParticleSystem* partiSys = static_cast<ParticleSystem*>(child);
|
||||
partiSys->setAtlasIndex(index);
|
||||
index += partiSys->getTotalParticles();
|
||||
|
|
|
@ -529,7 +529,7 @@ void RenderTexture::draw()
|
|||
//! make sure all children are drawn
|
||||
sortAllChildren();
|
||||
|
||||
_children.forEach([this](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [this](Node* child){
|
||||
if (child != _sprite)
|
||||
{
|
||||
child->visit();
|
||||
|
|
|
@ -145,7 +145,8 @@ void Scene::addChildToPhysicsWorld(Node* child)
|
|||
_physicsWorld->addBody(node->getPhysicsBody());
|
||||
}
|
||||
|
||||
node->getChildren().forEach([addToPhysicsWorldFunc](Node* n){
|
||||
auto& children = node->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [addToPhysicsWorldFunc](Node* n){
|
||||
addToPhysicsWorldFunc(n);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -809,7 +809,7 @@ Vector<Object*> Scheduler::pauseAllTargetsWithMinPriority(int minPriority)
|
|||
|
||||
void Scheduler::resumeTargets(const Vector<Object*>& targetsToResume)
|
||||
{
|
||||
targetsToResume.forEach([this](Object* obj){
|
||||
std::for_each(targetsToResume.begin(), targetsToResume.end(), [this](Object* obj){
|
||||
this->resumeTarget(obj);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -817,7 +817,7 @@ void Sprite::removeAllChildrenWithCleanup(bool cleanup)
|
|||
{
|
||||
if (_batchNode)
|
||||
{
|
||||
_children.forEach([this](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [this](Node* child){
|
||||
Sprite* sprite = dynamic_cast<Sprite*>(child);
|
||||
if (sprite)
|
||||
{
|
||||
|
@ -863,7 +863,7 @@ void Sprite::sortAllChildren()
|
|||
|
||||
if ( _batchNode)
|
||||
{
|
||||
_children.forEach([](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [](Node* child){
|
||||
child->sortAllChildren();
|
||||
});
|
||||
}
|
||||
|
@ -900,7 +900,7 @@ void Sprite::setDirtyRecursively(bool bValue)
|
|||
// recursively set dirty
|
||||
if (_hasChildren)
|
||||
{
|
||||
_children.forEach([](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [](Node* child){
|
||||
Sprite* sp = dynamic_cast<Sprite*>(child);
|
||||
if (sp)
|
||||
{
|
||||
|
|
|
@ -270,7 +270,7 @@ void SpriteBatchNode::sortAllChildren()
|
|||
if (!_children.empty())
|
||||
{
|
||||
//first sort all children recursively based on zOrder
|
||||
_children.forEach([](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [](Node* child){
|
||||
child->sortAllChildren();
|
||||
});
|
||||
|
||||
|
@ -278,7 +278,7 @@ void SpriteBatchNode::sortAllChildren()
|
|||
|
||||
//fast dispatch, give every child a new atlasIndex based on their relative zOrder (keep parent -> child relations intact)
|
||||
// and at the same time reorder descendants and the quads to the right index
|
||||
_children.forEach([this, &index](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [this, &index](Node* child){
|
||||
Sprite* sp = static_cast<Sprite*>(child);
|
||||
updateAtlasIndex(sp, &index);
|
||||
});
|
||||
|
@ -324,7 +324,7 @@ void SpriteBatchNode::updateAtlasIndex(Sprite* sprite, ssize_t* curIndex)
|
|||
needNewIndex = false;
|
||||
}
|
||||
|
||||
array.forEach([&](Node* child){
|
||||
std::for_each(array.begin(), array.end(), [&](Node* child){
|
||||
Sprite* sp = static_cast<Sprite*>(child);
|
||||
if (needNewIndex && sp->getZOrder() >= 0)
|
||||
{
|
||||
|
@ -390,7 +390,7 @@ void SpriteBatchNode::draw(void)
|
|||
|
||||
CC_NODE_DRAW_SETUP();
|
||||
|
||||
_children.forEach([](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [](Node* child){
|
||||
child->updateTransform();
|
||||
});
|
||||
|
||||
|
@ -426,7 +426,7 @@ ssize_t SpriteBatchNode::rebuildIndexInOrder(Sprite *parent, ssize_t index)
|
|||
|
||||
auto& children = parent->getChildren();
|
||||
|
||||
children.forEach([this, &index](Node* child){
|
||||
std::for_each(children.begin(), children.end(), [this, &index](Node* child){
|
||||
Sprite* sp = static_cast<Sprite*>(child);
|
||||
if (sp && (sp->getZOrder() < 0))
|
||||
{
|
||||
|
@ -441,7 +441,7 @@ ssize_t SpriteBatchNode::rebuildIndexInOrder(Sprite *parent, ssize_t index)
|
|||
index++;
|
||||
}
|
||||
|
||||
children.forEach([this, &index](Node* child){
|
||||
std::for_each(children.begin(), children.end(), [this, &index](Node* child){
|
||||
Sprite* sp = static_cast<Sprite*>(child);
|
||||
if (sp && (sp->getZOrder() >= 0))
|
||||
{
|
||||
|
@ -559,7 +559,8 @@ void SpriteBatchNode::appendChild(Sprite* sprite)
|
|||
_textureAtlas->insertQuad(&quad, index);
|
||||
|
||||
// add children recursively
|
||||
sprite->getChildren().forEach([this](Node* child){
|
||||
auto& children = sprite->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [this](Node* child){
|
||||
appendChild(static_cast<Sprite*>(child));
|
||||
});
|
||||
}
|
||||
|
@ -586,7 +587,7 @@ void SpriteBatchNode::removeSpriteFromAtlas(Sprite *sprite)
|
|||
|
||||
// remove children recursively
|
||||
auto& children = sprite->getChildren();
|
||||
children.forEach([this](Node* obj){
|
||||
std::for_each(children.begin(), children.end(), [this](Node* obj){
|
||||
Sprite* child = static_cast<Sprite*>(obj);
|
||||
if (child)
|
||||
{
|
||||
|
|
|
@ -389,7 +389,7 @@ Sprite * TMXLayer::insertTileForGID(unsigned int gid, const Point& pos)
|
|||
|
||||
// update possible children
|
||||
|
||||
_children.forEach([&indexForZ](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [&indexForZ](Node* child){
|
||||
Sprite* sp = static_cast<Sprite*>(child);
|
||||
if (child)
|
||||
{
|
||||
|
@ -594,7 +594,7 @@ void TMXLayer::removeTileAt(const Point& pos)
|
|||
_textureAtlas->removeQuadAtIndex(atlasIndex);
|
||||
|
||||
// update possible children
|
||||
_children.forEach([&atlasIndex](Node* obj){
|
||||
std::for_each(_children.begin(), _children.end(), [&atlasIndex](Node* obj){
|
||||
Sprite* child = static_cast<Sprite*>(obj);
|
||||
if (child)
|
||||
{
|
||||
|
|
|
@ -168,7 +168,8 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo)
|
|||
|
||||
int idx=0;
|
||||
|
||||
mapInfo->getLayers().forEach([&idx, this, &mapInfo](TMXLayerInfo* layerInfo){
|
||||
auto& layers = mapInfo->getLayers();
|
||||
std::for_each(layers.begin(), layers.end(), [&idx, this, &mapInfo](TMXLayerInfo* layerInfo){
|
||||
if (layerInfo && layerInfo->_visible)
|
||||
{
|
||||
TMXLayer *child = parseLayer(layerInfo, mapInfo);
|
||||
|
|
|
@ -64,7 +64,7 @@ void AutoreleasePool::clear()
|
|||
int nIndex = _managedObjectArray.size() - 1;
|
||||
#endif
|
||||
|
||||
_managedObjectArray.forEachReverse([&](Object* obj){
|
||||
std::for_each(_managedObjectArray.rbegin(), _managedObjectArray.rend(), [&](Object* obj){
|
||||
--(obj->_autoReleaseCount);
|
||||
//(*it)->release();
|
||||
//delete (*it);
|
||||
|
@ -118,7 +118,7 @@ void PoolManager::finalize()
|
|||
{
|
||||
if (!_releasePoolStack.empty())
|
||||
{
|
||||
_releasePoolStack.forEach([](AutoreleasePool* pool){
|
||||
std::for_each(_releasePoolStack.begin(), _releasePoolStack.end(), [](AutoreleasePool* pool){
|
||||
pool->clear();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -303,8 +303,10 @@ public:
|
|||
/** @brief Remove a certain object.
|
||||
* @param object The object to be removed.
|
||||
* @param toRelease Whether to decrease the referece count of the deleted object.
|
||||
* @return An iterator pointing to the new location of the element that followed the last element erased by the function call.
|
||||
* This is the container end if the operation erased the last element in the sequence.
|
||||
*/
|
||||
void eraseObject(T object, bool toRelease = true)
|
||||
iterator eraseObject(T object, bool toRelease = true)
|
||||
{
|
||||
CCASSERT(object != nullptr, "The object should not be nullptr");
|
||||
auto iter = std::find(_data.begin(), _data.end(), object);
|
||||
|
@ -410,65 +412,6 @@ public:
|
|||
_data.shrink_to_fit();
|
||||
}
|
||||
|
||||
/** Traverses through the vector and applys the callback function for each element */
|
||||
void forEach(const std::function<void(T)>& callback)
|
||||
{
|
||||
if (empty())
|
||||
return;
|
||||
|
||||
std::for_each(_data.cbegin(), _data.cend(), [&callback](const T& obj){
|
||||
callback(obj);
|
||||
});
|
||||
}
|
||||
|
||||
/** Traverses through the vector and applys the callback function for each element */
|
||||
void forEach(const std::function<void(T)>& callback) const
|
||||
{
|
||||
if (empty())
|
||||
return;
|
||||
|
||||
std::for_each(_data.cbegin(), _data.cend(), [&callback](const T& obj){
|
||||
callback(obj);
|
||||
});
|
||||
}
|
||||
|
||||
/** Traverses through the vector in reversed order and applys the callback function for each element */
|
||||
void forEachReverse(const std::function<void(T)>& callback)
|
||||
{
|
||||
if (empty())
|
||||
return;
|
||||
|
||||
std::for_each(_data.crbegin(), _data.crend(), [&callback](const T& obj){
|
||||
callback(obj);
|
||||
});
|
||||
}
|
||||
|
||||
/** Traverses through the vector in reversed order and applys the callback function for each element */
|
||||
void forEachReverse(const std::function<void(T)>& callback) const
|
||||
{
|
||||
if (empty())
|
||||
return;
|
||||
|
||||
std::for_each(_data.crbegin(), _data.crend(), [&callback](const T& obj){
|
||||
callback(obj);
|
||||
});
|
||||
}
|
||||
|
||||
/** @brief Sorts all elements in the vector according the binary callback function.
|
||||
* @param callback Binary function that accepts two elements in the vector as arguments,
|
||||
* and returns a value convertible to bool.
|
||||
* The value returned indicates whether the element passed as first argument is considered to go before the second in the specific strict weak ordering it defines.
|
||||
*/
|
||||
void sort(const std::function<bool(T, T)>& callback)
|
||||
{
|
||||
if (empty())
|
||||
return;
|
||||
|
||||
std::sort(_data.begin(), _data.end(), [&callback](T a, T b) -> bool{
|
||||
return callback(a, b);
|
||||
});
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
/** Retains all the objects in the vector */
|
||||
|
|
|
@ -293,7 +293,8 @@ void CCBReader::cleanUpNodeGraph(Node *node)
|
|||
{
|
||||
node->setUserObject(nullptr);
|
||||
|
||||
node->getChildren().forEach([this](Node* obj){
|
||||
auto& children = node->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [this](Node* obj){
|
||||
cleanUpNodeGraph(obj);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ void Bone::update(float delta)
|
|||
|
||||
DisplayFactory::updateDisplay(this, delta, _boneTransformDirty || _armature->getArmatureTransformDirty());
|
||||
|
||||
_children.forEach([&delta](Node* obj){
|
||||
std::for_each(_children.begin(), _children.end(), [&delta](Node* obj){
|
||||
Bone *childBone = static_cast<Bone*>(obj);
|
||||
childBone->update(delta);
|
||||
});
|
||||
|
|
|
@ -111,7 +111,7 @@ void Control::sendActionsForControlEvents(EventType controlEvents)
|
|||
// Call invocations
|
||||
const auto& invocationList = this->dispatchListforControlEvent((Control::EventType)(1<<i));
|
||||
|
||||
invocationList.forEach([this](Invocation* invocation){
|
||||
std::for_each(invocationList.begin(), invocationList.end(),[this](Invocation* invocation){
|
||||
invocation->invoke(this);
|
||||
});
|
||||
|
||||
|
@ -192,8 +192,10 @@ void Control::removeTargetWithActionForControlEvent(Object* target, Handler acti
|
|||
}
|
||||
else
|
||||
{
|
||||
std::vector<Invocation*> tobeRemovedInvocations;
|
||||
|
||||
//normally we would use a predicate, but this won't work here. Have to do it manually
|
||||
eventInvocationList.forEach([&](Invocation* invocation){
|
||||
std::for_each(eventInvocationList.begin(), eventInvocationList.end(), [&](Invocation* invocation){
|
||||
bool shouldBeRemoved=true;
|
||||
if (target)
|
||||
{
|
||||
|
@ -206,9 +208,13 @@ void Control::removeTargetWithActionForControlEvent(Object* target, Handler acti
|
|||
// Remove the corresponding invocation object
|
||||
if (shouldBeRemoved)
|
||||
{
|
||||
eventInvocationList.eraseObject(invocation, bDeleteObjects);
|
||||
tobeRemovedInvocations.push_back(invocation);
|
||||
}
|
||||
});
|
||||
|
||||
std::for_each(tobeRemovedInvocations.begin(), tobeRemovedInvocations.end(), [&](Invocation* invocation){
|
||||
eventInvocationList.eraseObject(invocation, bDeleteObjects);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,7 +224,7 @@ void Control::setOpacityModifyRGB(bool bOpacityModifyRGB)
|
|||
{
|
||||
_isOpacityModifyRGB=bOpacityModifyRGB;
|
||||
|
||||
_children.forEach([&](Node* obj){
|
||||
std::for_each(_children.begin(), _children.end(), [&](Node* obj){
|
||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(obj);
|
||||
if (rgba)
|
||||
{
|
||||
|
|
|
@ -700,7 +700,8 @@ void Scale9Sprite::setOpacityModifyRGB(bool var)
|
|||
}
|
||||
_opacityModifyRGB = var;
|
||||
|
||||
_scale9Image->getChildren().forEach([this](Node* child){
|
||||
auto& children = _scale9Image->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [this](Node* child){
|
||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (rgba)
|
||||
{
|
||||
|
@ -789,7 +790,8 @@ void Scale9Sprite::setColor(const Color3B& color)
|
|||
|
||||
NodeRGBA::setColor(color);
|
||||
|
||||
_scale9Image->getChildren().forEach([&color](Node* child){
|
||||
auto& children = _scale9Image->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [&color](Node* child){
|
||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (rgba)
|
||||
{
|
||||
|
@ -811,7 +813,8 @@ void Scale9Sprite::setOpacity(GLubyte opacity)
|
|||
}
|
||||
NodeRGBA::setOpacity(opacity);
|
||||
|
||||
_scale9Image->getChildren().forEach([&opacity](Node* child){
|
||||
auto& children = _scale9Image->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [&opacity](Node* child){
|
||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (rgba)
|
||||
{
|
||||
|
@ -833,7 +836,8 @@ void Scale9Sprite::updateDisplayedColor(const cocos2d::Color3B &parentColor)
|
|||
}
|
||||
NodeRGBA::updateDisplayedColor(parentColor);
|
||||
|
||||
_scale9Image->getChildren().forEach([&parentColor](Node* child){
|
||||
auto& children = _scale9Image->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [&parentColor](Node* child){
|
||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (rgba)
|
||||
{
|
||||
|
@ -850,7 +854,8 @@ void Scale9Sprite::updateDisplayedOpacity(GLubyte parentOpacity)
|
|||
}
|
||||
NodeRGBA::updateDisplayedOpacity(parentOpacity);
|
||||
|
||||
_scale9Image->getChildren().forEach([&parentOpacity](Node* child){
|
||||
auto& children = _scale9Image->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [&parentOpacity](Node* child){
|
||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (rgba)
|
||||
{
|
||||
|
|
|
@ -153,14 +153,16 @@ void ScrollView::pause(Object* sender)
|
|||
{
|
||||
_container->pause();
|
||||
|
||||
_container->getChildren().forEach([](Node* child){
|
||||
auto& children = _container->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [](Node* child){
|
||||
child->pause();
|
||||
});
|
||||
}
|
||||
|
||||
void ScrollView::resume(Object* sender)
|
||||
{
|
||||
_container->getChildren().forEach([](Node* child){
|
||||
auto& children = _container->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [](Node* child){
|
||||
child->resume();
|
||||
});
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ void TableView::reloadData()
|
|||
{
|
||||
_oldDirection = Direction::NONE;
|
||||
|
||||
_cellsUsed.forEach([this](TableViewCell* cell){
|
||||
std::for_each(_cellsUsed.begin(), _cellsUsed.end(), [this](TableViewCell* cell){
|
||||
if(_tableViewDelegate != NULL) {
|
||||
_tableViewDelegate->tableCellWillRecycle(this, cell);
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ void TableView::scrollViewDidScroll(ScrollView* view)
|
|||
if (_isUsedCellsDirty)
|
||||
{
|
||||
_isUsedCellsDirty = false;
|
||||
_cellsUsed.sort([](TableViewCell *a, TableViewCell *b) -> bool{
|
||||
std::sort(_cellsUsed.begin(), _cellsUsed.end(), [](TableViewCell *a, TableViewCell *b) -> bool{
|
||||
return a->getIdx() < b->getIdx();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -47,7 +47,8 @@ void Bug422Layer::reset()
|
|||
|
||||
void Bug422Layer::check(Node* t)
|
||||
{
|
||||
t->getChildren().forEach([this](Node* child){
|
||||
auto& children = t->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [this](Node* child){
|
||||
log("%p, rc: %d", child, child->retainCount());
|
||||
check(child);
|
||||
});
|
||||
|
|
|
@ -119,7 +119,8 @@ static void setEnableRecursiveCascading(Node* node, bool enable)
|
|||
rgba->setCascadeOpacityEnabled(enable);
|
||||
}
|
||||
|
||||
node->getChildren().forEach([enable](Node* child){
|
||||
auto& children = node->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [enable](Node* child){
|
||||
setEnableRecursiveCascading(child, enable);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -88,7 +88,9 @@ MenuLayerMainMenu::MenuLayerMainMenu()
|
|||
auto s = Director::getInstance()->getWinSize();
|
||||
|
||||
int i=0;
|
||||
menu->getChildren().forEach([&i, &s](Node* child){
|
||||
auto& children = menu->getChildren();
|
||||
|
||||
std::for_each(children.begin(), children.end(), [&i, &s](Node* child){
|
||||
auto dstPoint = child->getPosition();
|
||||
int offset = (int) (s.width/2 + 50);
|
||||
if( i % 2 == 0)
|
||||
|
|
|
@ -1530,7 +1530,7 @@ void MultipleParticleSystems::update(float dt)
|
|||
|
||||
unsigned int count = 0;
|
||||
|
||||
getChildren().forEach([&count](Node* child){
|
||||
std::for_each(_children.begin(), _children.end(), [&count](Node* child){
|
||||
auto item = dynamic_cast<ParticleSystem*>(child);
|
||||
if (item != NULL)
|
||||
{
|
||||
|
@ -1582,7 +1582,8 @@ void MultipleParticleSystemsBatched::update(float dt)
|
|||
|
||||
auto batchNode = getChildByTag(2);
|
||||
|
||||
batchNode->getChildren().forEach([&count](Node* child){
|
||||
auto& children = batchNode->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [&count](Node* child){
|
||||
auto item = dynamic_cast<ParticleSystem*>(child);
|
||||
if (item != NULL)
|
||||
{
|
||||
|
@ -1671,7 +1672,8 @@ void AddAndDeleteParticleSystems::update(float dt)
|
|||
|
||||
auto batchNode = getChildByTag(2);
|
||||
|
||||
batchNode->getChildren().forEach([&count](Node* child){
|
||||
auto& children = batchNode->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [&count](Node* child){
|
||||
auto item = dynamic_cast<ParticleSystem*>(child);
|
||||
if (item != NULL)
|
||||
{
|
||||
|
@ -1807,7 +1809,8 @@ void ReorderParticleSystems::update(float dt)
|
|||
|
||||
auto batchNode = getChildByTag(2);
|
||||
|
||||
batchNode->getChildren().forEach([&count](Node* child){
|
||||
auto& children = batchNode->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [&count](Node* child){
|
||||
auto item = dynamic_cast<ParticleSystem*>(child);
|
||||
if (item != nullptr)
|
||||
{
|
||||
|
|
|
@ -311,10 +311,12 @@ void LabelMainScene::updateText(float dt)
|
|||
char text[20];
|
||||
sprintf(text,"%.2f",_accumulativeTime);
|
||||
|
||||
auto& children = _labelContainer->getChildren();
|
||||
|
||||
switch (_s_labelCurCase)
|
||||
{
|
||||
case kCaseLabelTTFUpdate:
|
||||
_labelContainer->getChildren().forEach([&text](Node* child){
|
||||
std::for_each(children.begin(), children.end(), [&text](Node* child){
|
||||
if (child)
|
||||
{
|
||||
LabelTTF* label = (LabelTTF*)child;
|
||||
|
@ -323,7 +325,7 @@ void LabelMainScene::updateText(float dt)
|
|||
});
|
||||
break;
|
||||
case kCaseLabelBMFontUpdate:
|
||||
_labelContainer->getChildren().forEach([&text](Node* child){
|
||||
std::for_each(children.begin(), children.end(), [&text](Node* child){
|
||||
if (child)
|
||||
{
|
||||
LabelBMFont* label = (LabelBMFont*)child;
|
||||
|
@ -332,7 +334,7 @@ void LabelMainScene::updateText(float dt)
|
|||
});
|
||||
break;
|
||||
case kCaseLabelUpdate:
|
||||
_labelContainer->getChildren().forEach([&text](Node* child){
|
||||
std::for_each(children.begin(), children.end(), [&text](Node* child){
|
||||
if (child)
|
||||
{
|
||||
Label* label = (Label*)child;
|
||||
|
|
|
@ -679,7 +679,8 @@ void ShaderRetroEffect::update(float dt)
|
|||
_accum += dt;
|
||||
|
||||
int i=0;
|
||||
_label->getChildren().forEach([&i, this](Node* sprite){
|
||||
auto& children = _label->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [&i, this](Node* sprite){
|
||||
i++;
|
||||
auto oldPosition = sprite->getPosition();
|
||||
sprite->setPosition(Point( oldPosition.x, sinf( _accum * 2 + i/2.0) * 20 ));
|
||||
|
|
|
@ -1 +1 @@
|
|||
e4cdac1cca25440803dbf150fc336b61c44edb93
|
||||
de445fcbdc65bcfb39c12f4e5c05f48b7ce64ab7
|
|
@ -128,9 +128,9 @@ TMXOrthoTest::TMXOrthoTest()
|
|||
Size CC_UNUSED s = map->getContentSize();
|
||||
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
||||
|
||||
auto& pChildrenArray = map->getChildren();
|
||||
auto& children = map->getChildren();
|
||||
|
||||
pChildrenArray.forEach([](Node* obj){
|
||||
std::for_each(children.begin(), children.end(), [](Node* obj){
|
||||
auto child = static_cast<SpriteBatchNode*>(obj);
|
||||
child->getTexture()->setAntiAliasTexParameters();
|
||||
});
|
||||
|
@ -171,10 +171,10 @@ TMXOrthoTest2::TMXOrthoTest2()
|
|||
Size CC_UNUSED s = map->getContentSize();
|
||||
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
||||
|
||||
auto& pChildrenArray = map->getChildren();
|
||||
auto& children = map->getChildren();
|
||||
SpriteBatchNode* child = NULL;
|
||||
|
||||
pChildrenArray.forEach([&child](Node* obj){
|
||||
std::for_each(children.begin(), children.end(), [&child](Node* obj){
|
||||
child = static_cast<SpriteBatchNode*>(obj);
|
||||
child->getTexture()->setAntiAliasTexParameters();
|
||||
});
|
||||
|
@ -203,7 +203,7 @@ TMXOrthoTest3::TMXOrthoTest3()
|
|||
auto& children = map->getChildren();
|
||||
SpriteBatchNode* child = NULL;
|
||||
|
||||
children.forEach([&child](Node* node){
|
||||
std::for_each(children.begin(), children.end(), [&child](Node* node){
|
||||
child = static_cast<SpriteBatchNode*>(node);
|
||||
child->getTexture()->setAntiAliasTexParameters();
|
||||
});
|
||||
|
@ -231,7 +231,10 @@ TMXOrthoTest4::TMXOrthoTest4()
|
|||
CCLOG("ContentSize: %f, %f", s1.width,s1.height);
|
||||
|
||||
SpriteBatchNode* child = nullptr;
|
||||
map->getChildren().forEach([&child](Node* node){
|
||||
|
||||
auto& children = map->getChildren();
|
||||
|
||||
std::for_each(children.begin(), children.end(), [&child](Node* node){
|
||||
child = static_cast<SpriteBatchNode*>(node);
|
||||
child->getTexture()->setAntiAliasTexParameters();
|
||||
});
|
||||
|
@ -529,7 +532,9 @@ TMXUncompressedTest::TMXUncompressedTest()
|
|||
|
||||
// testing release map
|
||||
TMXLayer* layer;
|
||||
map->getChildren().forEach([&layer](Node* node){
|
||||
|
||||
auto& children = map->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [&layer](Node* node){
|
||||
layer= static_cast<TMXLayer*>(node);
|
||||
layer->releaseMap();
|
||||
});
|
||||
|
@ -1097,7 +1102,8 @@ TMXOrthoFlipTest::TMXOrthoFlipTest()
|
|||
Size CC_UNUSED s = map->getContentSize();
|
||||
log("ContentSize: %f, %f", s.width,s.height);
|
||||
|
||||
map->getChildren().forEach([](Node* node){
|
||||
auto& children = map->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [](Node* node){
|
||||
auto child = static_cast<SpriteBatchNode*>(node);
|
||||
child->getTexture()->setAntiAliasTexParameters();
|
||||
});
|
||||
|
@ -1125,7 +1131,8 @@ TMXOrthoFlipRunTimeTest::TMXOrthoFlipRunTimeTest()
|
|||
auto s = map->getContentSize();
|
||||
log("ContentSize: %f, %f", s.width,s.height);
|
||||
|
||||
map->getChildren().forEach([](Node* node){
|
||||
auto& children = map->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [](Node* node){
|
||||
auto child = static_cast<SpriteBatchNode*>(node);
|
||||
child->getTexture()->setAntiAliasTexParameters();
|
||||
});
|
||||
|
@ -1202,7 +1209,8 @@ TMXOrthoFromXMLTest::TMXOrthoFromXMLTest()
|
|||
auto s = map->getContentSize();
|
||||
log("ContentSize: %f, %f", s.width,s.height);
|
||||
|
||||
map->getChildren().forEach([](Node* node){
|
||||
auto& children = map->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [](Node* node){
|
||||
auto child = static_cast<SpriteBatchNode*>(node);
|
||||
child->getTexture()->setAntiAliasTexParameters();
|
||||
});
|
||||
|
@ -1229,7 +1237,8 @@ TMXBug987::TMXBug987()
|
|||
Size CC_UNUSED s1 = map->getContentSize();
|
||||
CCLOG("ContentSize: %f, %f", s1.width,s1.height);
|
||||
|
||||
map->getChildren().forEach([](Node* child){
|
||||
auto& children = map->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [](Node* child){
|
||||
auto node = static_cast<TMXLayer*>(child);
|
||||
node->getTexture()->setAntiAliasTexParameters();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue