FastLED 3.9.15
Loading...
Searching...
No Matches

◆ insertImpl()

template<typename T, typename Compare = less<T>, typename Allocator = allocator_slab<char>>
template<typename U>
fl::pair< iterator, bool > fl::RedBlackTree< T, Compare, Allocator >::insertImpl ( U && value)
inlineprivate

Definition at line 266 of file rbtree.h.

266 {
267 RBNode* parent = nullptr;
269
270 while (current != nullptr) {
271 parent = current;
272 if (mComp(value, current->data)) {
273 current = current->left;
274 } else if (mComp(current->data, value)) {
275 current = current->right;
276 } else {
277 return fl::pair<iterator, bool>(iterator(current, this), false);
278 }
279 }
280
281 RBNode* newNode = mAlloc.allocate(1);
282 if (newNode == nullptr) {
283 return fl::pair<iterator, bool>(iterator(nullptr, this), false);
284 }
285
287
288 if (parent == nullptr) {
289 mRoot = newNode;
290 } else if (mComp(newNode->data, parent->data)) {
291 parent->left = newNode;
292 } else {
293 parent->right = newNode;
294 }
295
297 ++mSize;
298
299 return fl::pair<iterator, bool>(iterator(newNode, this), true);
300 }
NodeAllocator mAlloc
Definition rbtree.h:64
fl::size mSize
Definition rbtree.h:62
Compare mComp
Definition rbtree.h:63
void insertFixup(RBNode *z)
Definition rbtree.h:103
RBNode * mRoot
Definition rbtree.h:61

Referenced by fl::RedBlackTree< value_type, PairCompare, Allocator >::insert(), and fl::RedBlackTree< value_type, PairCompare, Allocator >::insert().

+ Here is the caller graph for this function: