Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Unified Diff: include/core/SkTDArray.h

Issue 12315131: Make SkTDArray accessors const-friendly (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | include/core/SkTDict.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkTDArray.h
===================================================================
--- include/core/SkTDArray.h (revision 7881)
+++ include/core/SkTDArray.h (working copy)
@@ -102,16 +102,26 @@
*/
size_t bytes() const { return fCount * sizeof(T); }
- T* begin() const { return fArray; }
- T* end() const { return fArray ? fArray + fCount : NULL; }
- T& operator[](int index) const {
+ T* begin() { return fArray; }
+ const T* begin() const { return fArray; }
+ T* end() { return fArray ? fArray + fCount : NULL; }
+ const T* end() const { return fArray ? fArray + fCount : NULL; }
+
+ T& operator[](int index) {
SkASSERT((unsigned)index < fCount);
return fArray[index];
}
+ const T& operator[](int index) const {
+ SkASSERT((unsigned)index < fCount);
+ return fArray[index];
+ }
- T& getAt(int index) const {
+ T& getAt(int index) {
return (*this)[index];
}
+ const T& getAt(int index) const {
+ return (*this)[index];
+ }
void reset() {
if (fArray) {
@@ -306,7 +316,7 @@
this->reset();
}
- void visitAll(void visitor(T&)) const {
+ void visitAll(void visitor(T&)) {
T* stop = this->end();
for (T* curr = this->begin(); curr < stop; curr++) {
if (*curr) {
« no previous file with comments | « no previous file | include/core/SkTDict.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698