Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  
Public Member Functions | Private Member Functions | Private Attributes

SgUctAllocator Class Reference
[Monte Carlo tree search]

Allocater for nodes used in the implementation of SgUctTree. More...

#include <SgUctTree.h>

List of all members.

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 SgUctNodeStart () const
SgUctNodeFinish ()
const SgUctNodeFinish () const
SgUctNodeCreateOne (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

SgUctAllocatoroperator= (const SgUctAllocator &tree)
 Not implemented.

Private Attributes

SgUctNodem_start
SgUctNodem_finish
SgUctNodem_endOfStorage

Detailed Description

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.


Constructor & Destructor Documentation

SgUctAllocator::SgUctAllocator (  ) 

Definition at line 571 of file SgUctTree.h.

References m_start.

SgUctAllocator::~SgUctAllocator (  ) 

Definition at line 19 of file SgUctTree.cpp.

References Clear(), and m_start.


Member Function Documentation

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())

Parameters:
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)

Parameters:
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().

SgUctNode * SgUctAllocator::CreateOne ( SgMove  move  ) 

Create a new node at the end of the storage.

REQUIRES: HasCapacity(1)

Parameters:
move The constructor argument.
Returns:
A pointer to new newly created node.

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 (  ) 
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().


Member Data Documentation

Definition at line 563 of file SgUctTree.h.

Referenced by HasCapacity(), MaxNodes(), SetMaxNodes(), and Swap().


The documentation for this class was generated from the following files:


Sun Mar 13 2011 Doxygen 1.7.1