#include <SgUctTree.h>
Each thread has its own node allocator to allow lock-free usage of SgUctTree.
Definition at line 471 of file 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. | |
std::size_t | Create (const std::vector< SgMoveInfo > &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 |
SgUctAllocator::SgUctAllocator | ( | ) |
SgUctAllocator::~SgUctAllocator | ( | ) |
void SgUctAllocator::Clear | ( | ) |
Definition at line 545 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 29 of file SgUctTree.cpp.
std::size_t SgUctAllocator::Create | ( | const std::vector< SgMoveInfo > & | 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 562 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 576 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 555 of file SgUctTree.h.
References HasCapacity(), m_finish, and SG_ASSERT.
Referenced by SgUctTree::ApplyFilter().
const SgUctNode * SgUctAllocator::Finish | ( | ) | const |
SgUctNode * SgUctAllocator::Finish | ( | ) |
Definition at line 584 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 594 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 |
std::size_t SgUctAllocator::NuNodes | ( | ) | const |
Definition at line 604 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 41 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 609 of file SgUctTree.h.
References m_start.
Referenced by SgUctTree::DumpDebugInfo().
void SgUctAllocator::Swap | ( | SgUctAllocator & | allocator | ) |
Definition at line 34 of file SgUctTree.cpp.
References m_endOfStorage, m_finish, and m_start.
Referenced by SgUctTree::Swap().
SgUctNode* SgUctAllocator::m_endOfStorage [private] |
Definition at line 531 of file SgUctTree.h.
Referenced by HasCapacity(), MaxNodes(), SetMaxNodes(), and Swap().
SgUctNode* SgUctAllocator::m_finish [private] |
Definition at line 529 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 527 of file SgUctTree.h.
Referenced by Clear(), Contains(), MaxNodes(), NuNodes(), SetMaxNodes(), SgUctAllocator(), Start(), Swap(), and ~SgUctAllocator().