11#ifndef INCLUDED_BSLSTL_TREENODEPOOL_CPP03
12#define INCLUDED_BSLSTL_TREENODEPOOL_CPP03
63#ifdef COMPILING_BSLSTL_TREENODEPOOL_H
81template <
class VALUE,
class ALLOCATOR>
85 typedef SimplePool<TreeNode<VALUE>, ALLOCATOR> Pool;
99 TreeNodePool(
const TreeNodePool&);
100 TreeNodePool& operator=(
const TreeNodePool&);
110 typedef typename AllocatorTraits::size_type
size_type;
117 explicit TreeNodePool(
const ALLOCATOR&
allocator);
148#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
151#ifndef BSLSTL_TREENODEPOOL_VARIADIC_LIMIT
152#define BSLSTL_TREENODEPOOL_VARIADIC_LIMIT 10
154#ifndef BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_A
155#define BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_A BSLSTL_TREENODEPOOL_VARIADIC_LIMIT
157#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_A >= 0
162#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_A >= 1
163 template <
class Args_01>
168#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_A >= 2
169 template <
class Args_01,
176#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_A >= 3
177 template <
class Args_01,
186#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_A >= 4
187 template <
class Args_01,
198#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_A >= 5
199 template <
class Args_01,
212#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_A >= 6
213 template <
class Args_01,
228#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_A >= 7
229 template <
class Args_01,
246#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_A >= 8
247 template <
class Args_01,
266#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_A >= 9
267 template <
class Args_01,
288#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_A >= 10
289 template <
class Args_01,
315 template <
class... Args>
346 void swap(TreeNodePool& other);
381template <
class VALUE,
class ALLOCATOR>
383TreeNodePool<VALUE, ALLOCATOR>::TreeNodePool(
const ALLOCATOR& allocator)
388template <
class VALUE,
class ALLOCATOR>
390TreeNodePool<VALUE, ALLOCATOR>::TreeNodePool(
392: d_pool(MoveUtil::move(MoveUtil::access(original).d_pool))
397template <
class VALUE,
class ALLOCATOR>
402 TreeNodePool& lvalue = pool;
403 d_pool.adopt(MoveUtil::move(lvalue.d_pool));
406template <
class VALUE,
class ALLOCATOR>
408typename SimplePool<TreeNode<VALUE>, ALLOCATOR>::AllocatorType&
409TreeNodePool<VALUE, ALLOCATOR>::allocator()
411 return d_pool.allocator();
414template <
class VALUE,
class ALLOCATOR>
419 return emplaceIntoNewNode(
420 static_cast<const TreeNode<VALUE>&
>(original).value());
423#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
426#ifndef BSLSTL_TREENODEPOOL_VARIADIC_LIMIT
427#define BSLSTL_TREENODEPOOL_VARIADIC_LIMIT 10
429#ifndef BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_B
430#define BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_B BSLSTL_TREENODEPOOL_VARIADIC_LIMIT
432#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_B >= 0
433template <
class VALUE,
class ALLOCATOR>
436TreeNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
439 TreeNode<VALUE> *node = d_pool.allocate();
442 AllocatorTraits::construct(allocator(),
449#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_B >= 1
450template <
class VALUE,
class ALLOCATOR>
451template <
class Args_01>
454TreeNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
457 TreeNode<VALUE> *node = d_pool.allocate();
460 AllocatorTraits::construct(allocator(),
468#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_B >= 2
469template <
class VALUE,
class ALLOCATOR>
470template <
class Args_01,
474TreeNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
478 TreeNode<VALUE> *node = d_pool.allocate();
481 AllocatorTraits::construct(allocator(),
490#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_B >= 3
491template <
class VALUE,
class ALLOCATOR>
492template <
class Args_01,
497TreeNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
502 TreeNode<VALUE> *node = d_pool.allocate();
505 AllocatorTraits::construct(allocator(),
515#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_B >= 4
516template <
class VALUE,
class ALLOCATOR>
517template <
class Args_01,
523TreeNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
529 TreeNode<VALUE> *node = d_pool.allocate();
532 AllocatorTraits::construct(allocator(),
543#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_B >= 5
544template <
class VALUE,
class ALLOCATOR>
545template <
class Args_01,
552TreeNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
559 TreeNode<VALUE> *node = d_pool.allocate();
562 AllocatorTraits::construct(allocator(),
574#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_B >= 6
575template <
class VALUE,
class ALLOCATOR>
576template <
class Args_01,
584TreeNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
592 TreeNode<VALUE> *node = d_pool.allocate();
595 AllocatorTraits::construct(allocator(),
608#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_B >= 7
609template <
class VALUE,
class ALLOCATOR>
610template <
class Args_01,
619TreeNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
628 TreeNode<VALUE> *node = d_pool.allocate();
631 AllocatorTraits::construct(allocator(),
645#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_B >= 8
646template <
class VALUE,
class ALLOCATOR>
647template <
class Args_01,
657TreeNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
667 TreeNode<VALUE> *node = d_pool.allocate();
670 AllocatorTraits::construct(allocator(),
685#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_B >= 9
686template <
class VALUE,
class ALLOCATOR>
687template <
class Args_01,
698TreeNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
709 TreeNode<VALUE> *node = d_pool.allocate();
712 AllocatorTraits::construct(allocator(),
728#if BSLSTL_TREENODEPOOL_VARIADIC_LIMIT_B >= 10
729template <
class VALUE,
class ALLOCATOR>
730template <
class Args_01,
742TreeNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
754 TreeNode<VALUE> *node = d_pool.allocate();
757 AllocatorTraits::construct(allocator(),
777template <
class VALUE,
class ALLOCATOR>
778template <
class... Args>
781TreeNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
784 TreeNode<VALUE> *node = d_pool.allocate();
787 AllocatorTraits::construct(allocator(),
796template <
class VALUE,
class ALLOCATOR>
802 TreeNode<VALUE> *treeNode =
static_cast<TreeNode<VALUE> *
>(node);
803 AllocatorTraits::destroy(allocator(),
805 d_pool.deallocate(treeNode);
808template <
class VALUE,
class ALLOCATOR>
813 return emplaceIntoNewNode(
814 MoveUtil::move(
static_cast<TreeNode<VALUE> *
>(original)->value()));
817template <
class VALUE,
class ALLOCATOR>
819void TreeNodePool<VALUE, ALLOCATOR>::reserveNodes(size_type numNodes)
823 d_pool.reserve(numNodes);
826template <
class VALUE,
class ALLOCATOR>
828void TreeNodePool<VALUE, ALLOCATOR>::swap(
829 TreeNodePool<VALUE, ALLOCATOR>& other)
833 d_pool.swap(other.d_pool);
836template <
class VALUE,
class ALLOCATOR>
838void TreeNodePool<VALUE, ALLOCATOR>::swapExchangeAllocators(
839 TreeNodePool<VALUE, ALLOCATOR>& other)
841 d_pool.quickSwapExchangeAllocators(other.d_pool);
844template <
class VALUE,
class ALLOCATOR>
846void TreeNodePool<VALUE, ALLOCATOR>::swapRetainAllocators(
847 TreeNodePool<VALUE, ALLOCATOR>& other)
851 d_pool.quickSwapRetainAllocators(other.d_pool);
855template <
class VALUE,
class ALLOCATOR>
857const typename SimplePool<TreeNode<VALUE>, ALLOCATOR>::AllocatorType&
858TreeNodePool<VALUE, ALLOCATOR>::allocator()
const
860 return d_pool.allocator();
863template <
class VALUE,
class ALLOCATOR>
865bool TreeNodePool<VALUE, ALLOCATOR>::hasFreeNodes()
const
867 return d_pool.hasFreeBlocks();
874# error Not valid except when included from bslstl_treenodepool.h
Definition bslalg_rbtreenode.h:376
Definition bslma_deallocatorproctor.h:312
Definition bslmf_movableref.h:751
Types::AllocatorType AllocatorType
Definition bslstl_simplepool.h:341
Types::AllocatorTraits AllocatorTraits
Definition bslstl_simplepool.h:345
void reserveNodes(size_type numNodes)
Definition bslstl_treenodepool.h:510
void adopt(bslmf::MovableRef< TreeNodePool > pool)
Definition bslstl_treenodepool.h:446
AllocatorTraits::size_type size_type
Alias for the size_type of the allocator defined by SimplePool.
Definition bslstl_treenodepool.h:318
bslalg::RbTreeNode * moveIntoNewNode(bslalg::RbTreeNode *original)
Definition bslstl_treenodepool.h:502
Pool::AllocatorType AllocatorType
Alias for the allocator type defined by SimplePool.
Definition bslstl_treenodepool.h:315
void swap(TreeNodePool &other)
Definition bslstl_treenodepool.h:519
AllocatorType & allocator()
Definition bslstl_treenodepool.h:455
bslalg::RbTreeNode * emplaceIntoNewNode(Args &&... args)
Definition bslstl_treenodepool.h:474
void swapExchangeAllocators(TreeNodePool &other)
Definition bslstl_treenodepool.h:529
void deleteNode(bslalg::RbTreeNode *node)
Definition bslstl_treenodepool.h:489
bool hasFreeNodes() const
Definition bslstl_treenodepool.h:556
bslalg::RbTreeNode * cloneNode(const bslalg::RbTreeNode &original)
Definition bslstl_treenodepool.h:462
void swapRetainAllocators(TreeNodePool &other)
Definition bslstl_treenodepool.h:537
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2012
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
#define BSLS_UTIL_ADDRESSOF(OBJ)
Definition bsls_util.h:289
Definition bslstl_algorithm.h:82
Definition bslmf_movableref.h:791