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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 94 } |
95 | 95 |
96 bool isEmpty() const { return fCount == 0; } | 96 bool isEmpty() const { return fCount == 0; } |
97 | 97 |
98 /** | 98 /** |
99 * Return the number of elements in the array | 99 * Return the number of elements in the array |
100 */ | 100 */ |
101 int count() const { return fCount; } | 101 int count() const { return fCount; } |
102 | 102 |
103 /** | 103 /** |
| 104 * Return the total number of elements allocated. |
| 105 * reserved() - count() gives you the number of elements you can add |
| 106 * without causing an allocation. |
| 107 */ |
| 108 int reserved() const { return fReserve; } |
| 109 |
| 110 /** |
104 * return the number of bytes in the array: count * sizeof(T) | 111 * return the number of bytes in the array: count * sizeof(T) |
105 */ | 112 */ |
106 size_t bytes() const { return fCount * sizeof(T); } | 113 size_t bytes() const { return fCount * sizeof(T); } |
107 | 114 |
108 T* begin() { return fArray; } | 115 T* begin() { return fArray; } |
109 const T* begin() const { return fArray; } | 116 const T* begin() const { return fArray; } |
110 T* end() { return fArray ? fArray + fCount : NULL; } | 117 T* end() { return fArray ? fArray + fCount : NULL; } |
111 const T* end() const { return fArray ? fArray + fCount : NULL; } | 118 const T* end() const { return fArray ? fArray + fCount : NULL; } |
112 | 119 |
113 T& operator[](int index) { | 120 T& operator[](int index) { |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 #ifdef SK_DEBUG | 367 #ifdef SK_DEBUG |
361 fData = (ArrayT*)fArray; | 368 fData = (ArrayT*)fArray; |
362 #endif | 369 #endif |
363 fReserve = size; | 370 fReserve = size; |
364 } | 371 } |
365 fCount += extra; | 372 fCount += extra; |
366 } | 373 } |
367 }; | 374 }; |
368 | 375 |
369 #endif | 376 #endif |
OLD | NEW |