| 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 SkTDArray_DEFINED | 10 #ifndef SkTDArray_DEFINED |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 int count = SkMin32(max, fCount - index); | 275 int count = SkMin32(max, fCount - index); |
| 276 memcpy(dst, fArray + index, sizeof(T) * count); | 276 memcpy(dst, fArray + index, sizeof(T) * count); |
| 277 return count; | 277 return count; |
| 278 } | 278 } |
| 279 | 279 |
| 280 void copy(T* dst) const { | 280 void copy(T* dst) const { |
| 281 this->copyRange(dst, 0, fCount); | 281 this->copyRange(dst, 0, fCount); |
| 282 } | 282 } |
| 283 | 283 |
| 284 // routines to treat the array like a stack | 284 // routines to treat the array like a stack |
| 285 T* push() { return this->append(); } | 285 T* push() { return this->append(); } |
| 286 void push(const T& elem) { *this->append() = elem; } | 286 void push(const T& elem) { *this->append() = elem; } |
| 287 const T& top() const { return (*this)[fCount - 1]; } | 287 const T& top() const { return (*this)[fCount - 1]; } |
| 288 T& top() { return (*this)[fCount - 1]; } | 288 T& top() { return (*this)[fCount - 1]; } |
| 289 void pop(T* elem) { if (elem) *elem = (*this)[fCount - 1]; --fCount;
} | 289 void pop(T* elem) { SkASSERT(fCount > 0); if (elem) *elem = (*this)[fCou
nt - 1]; --fCount; } |
| 290 void pop() { --fCount; } | 290 void pop() { SkASSERT(fCount > 0); --fCount; } |
| 291 | 291 |
| 292 void deleteAll() { | 292 void deleteAll() { |
| 293 T* iter = fArray; | 293 T* iter = fArray; |
| 294 T* stop = fArray + fCount; | 294 T* stop = fArray + fCount; |
| 295 while (iter < stop) { | 295 while (iter < stop) { |
| 296 SkDELETE (*iter); | 296 SkDELETE (*iter); |
| 297 iter += 1; | 297 iter += 1; |
| 298 } | 298 } |
| 299 this->reset(); | 299 this->reset(); |
| 300 } | 300 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 fReserve = count + 4; | 380 fReserve = count + 4; |
| 381 fReserve += fReserve / 4; | 381 fReserve += fReserve / 4; |
| 382 fArray = (T*)sk_realloc_throw(fArray, fReserve * sizeof(T)); | 382 fArray = (T*)sk_realloc_throw(fArray, fReserve * sizeof(T)); |
| 383 #ifdef SK_DEBUG | 383 #ifdef SK_DEBUG |
| 384 fData = (ArrayT*)fArray; | 384 fData = (ArrayT*)fArray; |
| 385 #endif | 385 #endif |
| 386 } | 386 } |
| 387 }; | 387 }; |
| 388 | 388 |
| 389 #endif | 389 #endif |
| OLD | NEW |