OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkTemplates_DEFINED | 10 #ifndef SkTemplates_DEFINED |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 */ | 247 */ |
248 T* get() const { return fArray; } | 248 T* get() const { return fArray; } |
249 | 249 |
250 /** Return the nth element in the array | 250 /** Return the nth element in the array |
251 */ | 251 */ |
252 T& operator[](int index) const { | 252 T& operator[](int index) const { |
253 SkASSERT((unsigned)index < (unsigned)fCount); | 253 SkASSERT((unsigned)index < (unsigned)fCount); |
254 return fArray[index]; | 254 return fArray[index]; |
255 } | 255 } |
256 | 256 |
| 257 void swap(SkAutoTArray& other) { |
| 258 SkTSwap(fArray, other.fArray); |
| 259 SkDEBUGCODE(SkTSwap(fCount, other.fCount)); |
| 260 } |
| 261 |
257 private: | 262 private: |
258 T* fArray; | 263 T* fArray; |
259 SkDEBUGCODE(int fCount;) | 264 SkDEBUGCODE(int fCount;) |
260 }; | 265 }; |
261 | 266 |
262 /** Wraps SkAutoTArray, with room for up to N elements preallocated | 267 /** Wraps SkAutoTArray, with room for up to N elements preallocated |
263 */ | 268 */ |
264 template <int N, typename T> class SkAutoSTArray : SkNoncopyable { | 269 template <int N, typename T> class SkAutoSTArray : SkNoncopyable { |
265 public: | 270 public: |
266 /** Initialize with no objects */ | 271 /** Initialize with no objects */ |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 /** | 499 /** |
495 * Returns void* because this object does not initialize the | 500 * Returns void* because this object does not initialize the |
496 * memory. Use placement new for types that require a cons. | 501 * memory. Use placement new for types that require a cons. |
497 */ | 502 */ |
498 void* get() { return fStorage.get(); } | 503 void* get() { return fStorage.get(); } |
499 private: | 504 private: |
500 SkAlignedSStorage<sizeof(T)*N> fStorage; | 505 SkAlignedSStorage<sizeof(T)*N> fStorage; |
501 }; | 506 }; |
502 | 507 |
503 #endif | 508 #endif |
OLD | NEW |