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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // Set fCount to 0 before calling checkRealloc so that no elements are m
oved. | 114 // Set fCount to 0 before calling checkRealloc so that no elements are m
oved. |
115 fCount = 0; | 115 fCount = 0; |
116 this->checkRealloc(n); | 116 this->checkRealloc(n); |
117 fCount = n; | 117 fCount = n; |
118 for (int i = 0; i < fCount; ++i) { | 118 for (int i = 0; i < fCount; ++i) { |
119 new (fItemArray + i) T; | 119 new (fItemArray + i) T; |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 /** | 123 /** |
| 124 * Ensures there is enough reserved space for n elements. |
| 125 */ |
| 126 void reserve(int n) { |
| 127 if (fCount < n) { |
| 128 this->checkRealloc(n - fCount); |
| 129 } |
| 130 } |
| 131 |
| 132 /** |
124 * Resets to a copy of a C array. | 133 * Resets to a copy of a C array. |
125 */ | 134 */ |
126 void reset(const T* array, int count) { | 135 void reset(const T* array, int count) { |
127 for (int i = 0; i < fCount; ++i) { | 136 for (int i = 0; i < fCount; ++i) { |
128 fItemArray[i].~T(); | 137 fItemArray[i].~T(); |
129 } | 138 } |
130 fCount = 0; | 139 fCount = 0; |
131 this->checkRealloc(count); | 140 this->checkRealloc(count); |
132 fCount = count; | 141 fCount = count; |
133 this->copy(array); | 142 this->copy(array); |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 SkSTArray& operator= (const INHERITED& array) { | 538 SkSTArray& operator= (const INHERITED& array) { |
530 INHERITED::operator=(array); | 539 INHERITED::operator=(array); |
531 return *this; | 540 return *this; |
532 } | 541 } |
533 | 542 |
534 private: | 543 private: |
535 SkAlignedSTStorage<N,T> fStorage; | 544 SkAlignedSTStorage<N,T> fStorage; |
536 }; | 545 }; |
537 | 546 |
538 #endif | 547 #endif |
OLD | NEW |