OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 SkTLList_DEFINED | 8 #ifndef SkTLList_DEFINED |
9 #define SkTLList_DEFINED | 9 #define SkTLList_DEFINED |
10 | 10 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 T* addToTail() { | 96 T* addToTail() { |
97 this->validate(); | 97 this->validate(); |
98 Node* node = this->createNode(); | 98 Node* node = this->createNode(); |
99 fList.addToTail(node); | 99 fList.addToTail(node); |
100 new (node->fObj) T; | 100 new (node->fObj) T; |
101 this->validate(); | 101 this->validate(); |
102 return reinterpret_cast<T*>(node->fObj); | 102 return reinterpret_cast<T*>(node->fObj); |
103 } | 103 } |
104 | 104 |
105 /** Adds a new element to the list before the location indicated by the iter
ator. If the | 105 /** Adds a new element to the list before the location indicated by the iter
ator. If the |
106 iterator refers to a NULL location then the new element is added at the
tail */ | 106 iterator refers to a nullptr location then the new element is added at t
he tail */ |
107 T* addBefore(const T& t, const Iter& location) { | 107 T* addBefore(const T& t, const Iter& location) { |
108 return new (this->internalAddBefore(location)) T(t); | 108 return new (this->internalAddBefore(location)) T(t); |
109 } | 109 } |
110 | 110 |
111 /** Adds a new element to the list after the location indicated by the itera
tor. If the | 111 /** Adds a new element to the list after the location indicated by the itera
tor. If the |
112 iterator refers to a NULL location then the new element is added at the
head */ | 112 iterator refers to a nullptr location then the new element is added at t
he head */ |
113 T* addAfter(const T& t, const Iter& location) { | 113 T* addAfter(const T& t, const Iter& location) { |
114 return new (this->internalAddAfter(location)) T(t); | 114 return new (this->internalAddAfter(location)) T(t); |
115 } | 115 } |
116 | 116 |
117 /** Convenience methods for getting an iterator initialized to the head/tail
of the list. */ | 117 /** Convenience methods for getting an iterator initialized to the head/tail
of the list. */ |
118 Iter headIter() const { return Iter(*this, Iter::kHead_IterStart); } | 118 Iter headIter() const { return Iter(*this, Iter::kHead_IterStart); } |
119 Iter tailIter() const { return Iter(*this, Iter::kTail_IterStart); } | 119 Iter tailIter() const { return Iter(*this, Iter::kTail_IterStart); } |
120 | 120 |
121 T* head() { return Iter(*this, Iter::kHead_IterStart).get(); } | 121 T* head() { return Iter(*this, Iter::kHead_IterStart).get(); } |
122 T* tail() { return Iter(*this, Iter::kTail_IterStart).get(); } | 122 T* tail() { return Iter(*this, Iter::kTail_IterStart).get(); } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 Iter& operator= (const Iter& iter) { INHERITED::operator=(iter); return
*this; } | 215 Iter& operator= (const Iter& iter) { INHERITED::operator=(iter); return
*this; } |
216 | 216 |
217 private: | 217 private: |
218 friend class SkTLList; | 218 friend class SkTLList; |
219 Node* getNode() { return INHERITED::get(); } | 219 Node* getNode() { return INHERITED::get(); } |
220 | 220 |
221 T* nodeToObj(Node* node) { | 221 T* nodeToObj(Node* node) { |
222 if (node) { | 222 if (node) { |
223 return reinterpret_cast<T*>(node->fObj); | 223 return reinterpret_cast<T*>(node->fObj); |
224 } else { | 224 } else { |
225 return NULL; | 225 return nullptr; |
226 } | 226 } |
227 } | 227 } |
228 }; | 228 }; |
229 | 229 |
230 // For use with operator new | 230 // For use with operator new |
231 enum Placement { | 231 enum Placement { |
232 kBefore_Placement, | 232 kBefore_Placement, |
233 kAfter_Placement, | 233 kAfter_Placement, |
234 }; | 234 }; |
235 | 235 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 #define SkNEW_INSERT_IN_LLIST_AFTER(list, location, type_name, args) \ | 394 #define SkNEW_INSERT_IN_LLIST_AFTER(list, location, type_name, args) \ |
395 (new ((list), SkTLList< type_name >::kAfter_Placement, (location)) type_name
args) | 395 (new ((list), SkTLList< type_name >::kAfter_Placement, (location)) type_name
args) |
396 | 396 |
397 #define SkNEW_INSERT_AT_LLIST_HEAD(list, type_name, args) \ | 397 #define SkNEW_INSERT_AT_LLIST_HEAD(list, type_name, args) \ |
398 SkNEW_INSERT_IN_LLIST_BEFORE((list), (list)->headIter(), type_name, args) | 398 SkNEW_INSERT_IN_LLIST_BEFORE((list), (list)->headIter(), type_name, args) |
399 | 399 |
400 #define SkNEW_INSERT_AT_LLIST_TAIL(list, type_name, args) \ | 400 #define SkNEW_INSERT_AT_LLIST_TAIL(list, type_name, args) \ |
401 SkNEW_INSERT_IN_LLIST_AFTER((list), (list)->tailIter(), type_name, args) | 401 SkNEW_INSERT_IN_LLIST_AFTER((list), (list)->tailIter(), type_name, args) |
402 | 402 |
403 #endif | 403 #endif |
OLD | NEW |