OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 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 SkPtrSet_DEFINED | 10 #ifndef SkPtrSet_DEFINED |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 * incPtr() and decPtr() are not called during this operation. | 51 * incPtr() and decPtr() are not called during this operation. |
52 */ | 52 */ |
53 void copyToArray(void* array[]) const; | 53 void copyToArray(void* array[]) const; |
54 | 54 |
55 /** | 55 /** |
56 * Call decPtr() on each ptr in the set, and the reset the size of the set | 56 * Call decPtr() on each ptr in the set, and the reset the size of the set |
57 * to 0. | 57 * to 0. |
58 */ | 58 */ |
59 void reset(); | 59 void reset(); |
60 | 60 |
| 61 /** |
| 62 * Set iterator. |
| 63 */ |
| 64 class Iter { |
| 65 public: |
| 66 Iter(const SkPtrSet& set) |
| 67 : fSet(set) |
| 68 , fIndex(0) {} |
| 69 |
| 70 /** |
| 71 * Return the next ptr in the set or null if the end was reached. |
| 72 */ |
| 73 void* next() { |
| 74 return fIndex < fSet.fList.count() ? fSet.fList[fIndex++].fPtr : NUL
L; |
| 75 } |
| 76 |
| 77 private: |
| 78 const SkPtrSet& fSet; |
| 79 int fIndex; |
| 80 }; |
| 81 |
61 protected: | 82 protected: |
62 virtual void incPtr(void*) {} | 83 virtual void incPtr(void*) {} |
63 virtual void decPtr(void*) {} | 84 virtual void decPtr(void*) {} |
64 | 85 |
65 private: | 86 private: |
66 struct Pair { | 87 struct Pair { |
67 void* fPtr; // never NULL | 88 void* fPtr; // never NULL |
68 uint32_t fIndex; // 1...N | 89 uint32_t fIndex; // 1...N |
69 }; | 90 }; |
70 | 91 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 const char* getNextAddedFactoryName(); | 163 const char* getNextAddedFactoryName(); |
143 private: | 164 private: |
144 int fNextAddedFactory; | 165 int fNextAddedFactory; |
145 SkFactorySet fFactorySet; | 166 SkFactorySet fFactorySet; |
146 SkTDArray<const char*> fNames; | 167 SkTDArray<const char*> fNames; |
147 | 168 |
148 typedef SkRefCnt INHERITED; | 169 typedef SkRefCnt INHERITED; |
149 }; | 170 }; |
150 | 171 |
151 #endif | 172 #endif |
OLD | NEW |