| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkTArray_DEFINED | 8 #ifndef SkTArray_DEFINED |
| 9 #define SkTArray_DEFINED | 9 #define SkTArray_DEFINED |
| 10 | 10 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 * to separate T values. | 228 * to separate T values. |
| 229 */ | 229 */ |
| 230 T* push_back_n(int n, const T t[]) { | 230 T* push_back_n(int n, const T t[]) { |
| 231 SkASSERT(n >= 0); | 231 SkASSERT(n >= 0); |
| 232 this->checkRealloc(n); | 232 this->checkRealloc(n); |
| 233 for (int i = 0; i < n; ++i) { | 233 for (int i = 0; i < n; ++i) { |
| 234 new (fItemArray + fCount + i) T(t[i]); | 234 new (fItemArray + fCount + i) T(t[i]); |
| 235 } | 235 } |
| 236 fCount += n; | 236 fCount += n; |
| 237 return fItemArray + fCount - n; | 237 return fItemArray + fCount - n; |
| 238 } | |
| 239 | |
| 240 /** | |
| 241 * Version of above that uses the move constructor to set n items. | |
| 242 */ | |
| 243 T* move_back_n(int n, T* t) { | |
| 244 SkASSERT(n >= 0); | |
| 245 this->checkRealloc(n); | |
| 246 for (int i = 0; i < n; ++i) { | |
| 247 new (fItemArray + fCount + i) T(std::move(t[i])); | |
| 248 } | |
| 249 fCount += n; | |
| 250 return fItemArray + fCount - n; | |
| 251 } | 238 } |
| 252 | 239 |
| 253 /** | 240 /** |
| 254 * Removes the last element. Not safe to call when count() == 0. | 241 * Removes the last element. Not safe to call when count() == 0. |
| 255 */ | 242 */ |
| 256 void pop_back() { | 243 void pop_back() { |
| 257 SkASSERT(fCount > 0); | 244 SkASSERT(fCount > 0); |
| 258 --fCount; | 245 --fCount; |
| 259 fItemArray[fCount].~T(); | 246 fItemArray[fCount].~T(); |
| 260 this->checkRealloc(0); | 247 this->checkRealloc(0); |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 SkSTArray& operator= (const INHERITED& array) { | 538 SkSTArray& operator= (const INHERITED& array) { |
| 552 INHERITED::operator=(array); | 539 INHERITED::operator=(array); |
| 553 return *this; | 540 return *this; |
| 554 } | 541 } |
| 555 | 542 |
| 556 private: | 543 private: |
| 557 SkAlignedSTStorage<N,T> fStorage; | 544 SkAlignedSTStorage<N,T> fStorage; |
| 558 }; | 545 }; |
| 559 | 546 |
| 560 #endif | 547 #endif |
| OLD | NEW |