We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.
Add Iterator object of cocos2d::Array
Add Iterator object of cocos2d::Array
Feature #2525 [Closed]
CCArray is not a template, it can contain a Object* in it, but it doesn’t know the real type of the element. So should be used it like this
auto children = layer.getChildren(); for( auto child : children ) { Node *node = static_cast(child); node->setPosition( Point(10,10) ); // the return type is Object*, don't know the real type. }
Status: | Closed | |
---|---|---|
Start date: | 2013-08-13 | |
Priority: | High | |
Due date: | ||
Assignee: | ||
% Done: | 100% |
|
Category: | all | |
Target version: | 3.0-alpha0 |
Array
should support iterators, includingbegin()
andend()
.If we add that, the trantision to v3.0 will be much easier, since it won’t matter if we use
Array
ofstd::vector
or any other container.And we should deprecate the macro
CCARRAY_FOREACH
.Users should be able to do something like this:
And that code should ALWAYS work. It should not depend if we use
Array
, orstd::vector
orstd::list
or any other container.