| OLD | NEW |
| 1 // | 1 // |
| 2 // SkTRefArray.h | 2 // SkTRefArray.h |
| 3 // core | 3 // core |
| 4 // | 4 // |
| 5 // Created by Mike Reed on 7/17/12. | 5 // Created by Mike Reed on 7/17/12. |
| 6 // Copyright (c) 2012 __MyCompanyName__. All rights reserved. | 6 // Copyright (c) 2012 __MyCompanyName__. All rights reserved. |
| 7 // | 7 // |
| 8 | 8 |
| 9 #ifndef SkTRefArray_DEFINED | 9 #ifndef SkTRefArray_DEFINED |
| 10 #define SkTRefArray_DEFINED | 10 #define SkTRefArray_DEFINED |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 const T& at(int index) const { | 67 const T& at(int index) const { |
| 68 SkASSERT((unsigned)index < (unsigned)fCount); | 68 SkASSERT((unsigned)index < (unsigned)fCount); |
| 69 return this->begin()[index]; | 69 return this->begin()[index]; |
| 70 } | 70 } |
| 71 const T& operator[](int index) const { return this->at(index); } | 71 const T& operator[](int index) const { return this->at(index); } |
| 72 | 72 |
| 73 // For the writable methods, we assert that we are the only owner if we | 73 // For the writable methods, we assert that we are the only owner if we |
| 74 // call these, since other owners are not informed if we change an element. | 74 // call these, since other owners are not informed if we change an element. |
| 75 | 75 |
| 76 T* writableBegin() { | 76 T* writableBegin() { |
| 77 SkASSERT(1 == this->getRefCnt()); | 77 SkASSERT(this->unique()); |
| 78 return (T*)(this + 1); | 78 return (T*)(this + 1); |
| 79 } | 79 } |
| 80 T* writableEnd() { | 80 T* writableEnd() { |
| 81 return this->writableBegin() + fCount; | 81 return this->writableBegin() + fCount; |
| 82 } | 82 } |
| 83 T& writableAt(int index) { | 83 T& writableAt(int index) { |
| 84 SkASSERT((unsigned)index < (unsigned)fCount); | 84 SkASSERT((unsigned)index < (unsigned)fCount); |
| 85 return this->writableBegin()[index]; | 85 return this->writableBegin()[index]; |
| 86 } | 86 } |
| 87 | 87 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 103 private: | 103 private: |
| 104 int fCount; | 104 int fCount; |
| 105 | 105 |
| 106 // hide this | 106 // hide this |
| 107 virtual ~SkTRefArray() {} | 107 virtual ~SkTRefArray() {} |
| 108 | 108 |
| 109 typedef SkRefCnt INHERITED; | 109 typedef SkRefCnt INHERITED; |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 #endif | 112 #endif |
| OLD | NEW |