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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } | 238 } |
239 | 239 |
240 /** | 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 } |
| 252 |
| 253 /** |
241 * Removes the last element. Not safe to call when count() == 0. | 254 * Removes the last element. Not safe to call when count() == 0. |
242 */ | 255 */ |
243 void pop_back() { | 256 void pop_back() { |
244 SkASSERT(fCount > 0); | 257 SkASSERT(fCount > 0); |
245 --fCount; | 258 --fCount; |
246 fItemArray[fCount].~T(); | 259 fItemArray[fCount].~T(); |
247 this->checkRealloc(0); | 260 this->checkRealloc(0); |
248 } | 261 } |
249 | 262 |
250 /** | 263 /** |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 SkSTArray& operator= (const INHERITED& array) { | 551 SkSTArray& operator= (const INHERITED& array) { |
539 INHERITED::operator=(array); | 552 INHERITED::operator=(array); |
540 return *this; | 553 return *this; |
541 } | 554 } |
542 | 555 |
543 private: | 556 private: |
544 SkAlignedSTStorage<N,T> fStorage; | 557 SkAlignedSTStorage<N,T> fStorage; |
545 }; | 558 }; |
546 | 559 |
547 #endif | 560 #endif |
OLD | NEW |