Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use size_t instead of long in Array #4416

Merged
merged 1 commit into from Dec 4, 2013
Merged

Conversation

minggo
Copy link
Contributor

@minggo minggo commented Dec 3, 2013

  1. use size_t instead of long in Array API
  2. remove unneeded spaces
  3. add spaces before and after binary operation, such as +

@minggo
Copy link
Contributor Author

minggo commented Dec 3, 2013

@ricardoquesada
Could you please review it?

@minggo
Copy link
Contributor Author

minggo commented Dec 3, 2013

I will add other commit after this one is merged.

@minggo
Copy link
Contributor Author

minggo commented Dec 3, 2013

I will change the API first, then fix warnings later.

@ricardoquesada
Copy link
Contributor

Sure. I'll review tomorrow Tuesday.

@minggo
Copy link
Contributor Author

minggo commented Dec 3, 2013

I am not sure if i use too much size_t. May be only count and capacity should use size_t.

@ricardoquesada
Copy link
Contributor

@minggo
Looks good to me.

You are using size_t for size and index, and that is the expected use:
http://stackoverflow.com/a/1951548

@minggo
Copy link
Contributor Author

minggo commented Dec 4, 2013

Ok.

minggo added a commit that referenced this pull request Dec 4, 2013
[ci skip]use size_t instead of long in Array
@minggo minggo merged commit c019521 into cocos2d:develop Dec 4, 2013
@minggo
Copy link
Contributor Author

minggo commented Dec 4, 2013

I change the type of Array::getIndexOfObject() to size_t, then what's the return value when the object is not contained in the Array?

@minggo
Copy link
Contributor Author

minggo commented Dec 4, 2013

Ok, i can return the max value of size_t.

@ricardoquesada
Copy link
Contributor

Good point.

2 options:

  • return std::max() or something like that
  • or assert() if the object doesn't exist

@minggo
Copy link
Contributor Author

minggo commented Dec 5, 2013

Thanks. Since we will return ssize_t instead of size_t, i think it can return -1.

angeltown pushed a commit to angeltown/cocos2d-x that referenced this pull request Apr 28, 2014
[ci skip]use size_t instead of long in Array
angeltown pushed a commit to angeltown/cocos2d-x that referenced this pull request Apr 29, 2014
[ci skip]use size_t instead of long in Array
angeltown pushed a commit to angeltown/cocos2d-x that referenced this pull request Apr 30, 2014
[ci skip]use size_t instead of long in Array
angeltown pushed a commit to angeltown/cocos2d-x that referenced this pull request Apr 30, 2014
[ci skip]use size_t instead of long in Array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants