Allocater for nodes used in the implementation of SgUctTree. More...
#include <SgUctTree.h>
Public Member Functions | |
SgUctAllocator () | |
~SgUctAllocator () | |
void | Clear () |
bool | HasCapacity (std::size_t n) const |
Does the allocator have the capacity for n more nodes? | |
std::size_t | NuNodes () const |
std::size_t | MaxNodes () const |
void | SetMaxNodes (std::size_t maxNodes) |
bool | Contains (const SgUctNode &node) const |
Check if allocator contains node. | |
const SgUctNode * | Start () const |
SgUctNode * | Finish () |
const SgUctNode * | Finish () const |
SgUctNode * | CreateOne (SgMove move) |
Create a new node at the end of the storage. | |
SgUctValue | Create (const std::vector< SgUctMoveInfo > &moves) |
Create a number of new nodes with a given list of moves at the end of the storage. | |
void | CreateN (std::size_t n) |
Create a number of new nodes at the end of the storage. | |
void | Swap (SgUctAllocator &allocator) |
Private Member Functions | |
SgUctAllocator & | operator= (const SgUctAllocator &tree) |
Not implemented. | |
Private Attributes | |
SgUctNode * | m_start |
SgUctNode * | m_finish |
SgUctNode * | m_endOfStorage |
Allocater for nodes used in the implementation of SgUctTree.
Each thread has its own node allocator to allow lock-free usage of SgUctTree.
Definition at line 507 of file SgUctTree.h.
SgUctAllocator::SgUctAllocator | ( | ) |
Definition at line 571 of file SgUctTree.h.
References m_start.
SgUctAllocator::~SgUctAllocator | ( | ) |
Definition at line 19 of file SgUctTree.cpp.
void SgUctAllocator::Clear | ( | ) |
Definition at line 576 of file SgUctTree.h.
References m_finish, and m_start.
Referenced by SgUctTree::Clear(), SetMaxNodes(), and ~SgUctAllocator().
bool SgUctAllocator::Contains | ( | const SgUctNode & | node | ) | const |
Check if allocator contains node.
This function uses pointer comparisons. Since the result of comparisons for pointers to elements in different containers is platform-dependent, it is only guaranteed that it returns true, if not node belongs to the allocator, but not that it returns false for nodes not in the allocator.
Definition at line 28 of file SgUctTree.cpp.
References m_finish, and m_start.
Referenced by SgUctTree::Contains().
SgUctValue SgUctAllocator::Create | ( | const std::vector< SgUctMoveInfo > & | moves | ) |
Create a number of new nodes with a given list of moves at the end of the storage.
Returns the sum of counts of moves. REQUIRES: HasCapacity(moves.size())
moves | The list of moves. |
Definition at line 593 of file SgUctTree.h.
References HasCapacity(), m_finish, and SG_ASSERT.
Referenced by SgUctTree::CreateChildren(), and SgUctTree::MergeChildren().
void SgUctAllocator::CreateN | ( | std::size_t | n | ) |
Create a number of new nodes at the end of the storage.
REQUIRES: HasCapacity(n)
n | The number of nodes to create. |
Definition at line 607 of file SgUctTree.h.
References HasCapacity(), m_finish, SG_ASSERT, and SG_NULLMOVE.
Referenced by SgUctTree::CopySubtree().
Create a new node at the end of the storage.
REQUIRES: HasCapacity(1)
move | The constructor argument. |
Definition at line 586 of file SgUctTree.h.
References HasCapacity(), m_finish, and SG_ASSERT.
Referenced by SgUctTree::ApplyFilter().
const SgUctNode * SgUctAllocator::Finish | ( | ) | const |
Definition at line 620 of file SgUctTree.h.
References m_finish.
SgUctNode * SgUctAllocator::Finish | ( | ) |
Definition at line 615 of file SgUctTree.h.
References m_finish.
Referenced by SgUctTree::ApplyFilter(), SgUctTree::CopySubtree(), SgUctTree::CreateChildren(), SgUctTree::DumpDebugInfo(), and SgUctTree::MergeChildren().
bool SgUctAllocator::HasCapacity | ( | std::size_t | n | ) | const |
Does the allocator have the capacity for n more nodes?
Definition at line 625 of file SgUctTree.h.
References m_endOfStorage, and m_finish.
Referenced by SgUctTree::CopySubtree(), Create(), SgUctTree::CreateChildren(), CreateN(), CreateOne(), SgUctTree::HasCapacity(), and SgUctTree::MergeChildren().
std::size_t SgUctAllocator::MaxNodes | ( | ) | const |
Definition at line 630 of file SgUctTree.h.
References m_endOfStorage, and m_start.
std::size_t SgUctAllocator::NuNodes | ( | ) | const |
Definition at line 635 of file SgUctTree.h.
References m_finish, and m_start.
Referenced by SgUctTree::DumpDebugInfo(), and SgUctTree::NuNodes().
SgUctAllocator& SgUctAllocator::operator= | ( | const SgUctAllocator & | tree | ) | [private] |
Not implemented.
Cannot be copied because array contains pointers to elements. Use Swap() instead.
void SgUctAllocator::SetMaxNodes | ( | std::size_t | maxNodes | ) |
Definition at line 40 of file SgUctTree.cpp.
References Clear(), m_endOfStorage, m_finish, and m_start.
Referenced by SgUctTree::SetMaxNodes().
const SgUctNode * SgUctAllocator::Start | ( | ) | const |
Definition at line 640 of file SgUctTree.h.
References m_start.
Referenced by SgUctTree::DumpDebugInfo().
void SgUctAllocator::Swap | ( | SgUctAllocator & | allocator | ) |
Definition at line 33 of file SgUctTree.cpp.
References m_endOfStorage, m_finish, and m_start.
Referenced by SgUctTree::Swap().
SgUctNode* SgUctAllocator::m_endOfStorage [private] |
Definition at line 563 of file SgUctTree.h.
Referenced by HasCapacity(), MaxNodes(), SetMaxNodes(), and Swap().
SgUctNode* SgUctAllocator::m_finish [private] |
Definition at line 561 of file SgUctTree.h.
Referenced by Clear(), Contains(), Create(), CreateN(), CreateOne(), Finish(), HasCapacity(), NuNodes(), SetMaxNodes(), and Swap().
SgUctNode* SgUctAllocator::m_start [private] |
Definition at line 559 of file SgUctTree.h.
Referenced by Clear(), Contains(), MaxNodes(), NuNodes(), SetMaxNodes(), SgUctAllocator(), Start(), Swap(), and ~SgUctAllocator().