69 iColor{ aColor }, iParent{ aColor !=
NIL ? nullptr : this }, iLeft{ aColor !=
NIL ? nullptr : this }, iRight{ aColor !=
NIL ? nullptr : this }, iPrevious{ nullptr }, iNext{ nullptr }, iSize { 0 }
73 iColor{ aOther.iColor }, iParent{ aOther.iColor !=
NIL ? nullptr : this }, iLeft{ aOther.iColor !=
NIL ? nullptr : this }, iRight{ aOther.iColor !=
NIL ? nullptr : this }, iPrevious{ nullptr }, iNext{ nullptr }, iSize{ 0 }
87 return iColor !=
NIL ? iColor :
BLACK;
104 if (iLeft !=
nullptr)
114 if (iRight !=
nullptr)
128 iPrevious = aPrevoius;
140 return iColor !=
NIL ? iSize : 0;
180 if (aNil->
parent() == aGarbage)
182 if (aNil->
left() == aGarbage)
184 if (aNil->
right() == aGarbage)
198 typedef typename std::allocator_traits<allocator_type>:: template rebind_alloc<node> node_allocator_type;
202 iAllocator{ aAllocator },
208 iNil = std::allocator_traits<node_allocator_type>::allocate(iAllocator, 1);
211 std::allocator_traits<node_allocator_type>::construct(iAllocator, iNil,
node(
node::NIL));
215 std::allocator_traits<node_allocator_type>::deallocate(iAllocator, iNil, 1);
221 iAllocator{ aOther.iAllocator },
227 iNil = std::allocator_traits<node_allocator_type>::allocate(iAllocator, 1);
230 std::allocator_traits<node_allocator_type>::construct(iAllocator, iNil,
node(
node::NIL));
234 std::allocator_traits<node_allocator_type>::deallocate(iAllocator, iNil, 1);
240 iAllocator{
std::move(other.iAllocator) },
253 std::allocator_traits<node_allocator_type>::destroy(iAllocator, iNil);
254 std::allocator_traits<node_allocator_type>::deallocate(iAllocator, iNil, 1);
288 return aNode ? aNode->
size() : 0;
296 return aNode && aNode->
left() ? aNode->
left()->
size() : 0;
308 if (aPosition < index)
331 previousIndex = index;
333 if (aPosition <= index)
349 if (aPosition <= previousIndex)
368 y = tree_successor(z);
400 if (performDeleteFixup)
405 std::swap(iAllocator, aOther.iAllocator);
413 void insert_fixup(node* aNode)
416 while (z->parent()->color() ==
node::RED)
418 if (z->parent() == z->parent()->parent()->left())
420 node* y = z->parent()->parent()->right();
425 z->parent()->parent()->set_color(
node::RED);
426 z = z->parent()->parent();
430 if (z == z->parent()->right())
436 z->parent()->parent()->set_color(
node::RED);
437 right_rotate(z->parent()->parent());
442 node* y = z->parent()->parent()->left();
447 z->parent()->parent()->set_color(
node::RED);
448 z = z->parent()->parent();
452 if (z == z->parent()->left())
458 z->parent()->parent()->set_color(
node::RED);
459 left_rotate(z->parent()->parent());
465 void left_rotate(node* aNode)
468 node* y = x->right();
469 x->set_right(y->left());
471 y->left()->set_parent(x);
472 y->set_parent(x->parent());
477 if (x == x->parent()->left())
478 x->parent()->set_left(y);
480 x->parent()->set_right(y);
486 y->iSize = x->size();
487 x->iSize -= previousSize;
488 x->iSize += x->right()->size();
490 void right_rotate(node* aNode)
494 y->set_left(x->right());
496 x->right()->set_parent(y);
497 x->set_parent(y->parent());
502 if (y == y->parent()->right())
503 y->parent()->set_right(x);
505 y->parent()->set_left(x);
511 x->iSize = y->size();
512 y->iSize -= previousSize;
513 y->iSize += y->left()->size();
515 node* tree_minimum(node* aNode)
522 node* tree_successor(node* aNode)
526 return tree_minimum(x->right());
527 node* y = x->parent();
535 void delete_fixup(node* aNode)
540 if (x == x->parent()->left())
542 node* w = x->parent()->right();
547 left_rotate(x->parent());
548 w = x->parent()->right();
562 w = x->parent()->right();
564 w->set_color(x->parent()->color());
567 left_rotate(x->parent());
573 node* w = x->parent()->left();
578 right_rotate(x->parent());
579 w = x->parent()->left();
593 w = x->parent()->left();
595 w->set_color(x->parent()->color());
598 right_rotate(x->parent());
607 node_allocator_type iAllocator;
void swap(plf::hive< element_type, allocator_type > &a, plf::hive< element_type, allocator_type > &b) noexcept(std::allocator_traits< allocator_type >::propagate_on_container_swap::value||std::allocator_traits< allocator_type >::is_always_equal::value)