#include <SgNode.h>
Procedures for moving around in the tree return 0 if the desti- nation doesn't exist. References to "left" and "right" picture the tree with the root at the top and the main line of play going down the left side.
Definition at line 42 of file SgNode.h.
Public Types | |
PREVIOUS | |
NEXT | |
NEXT_RIGHTMOST | |
PREV_DEPTHFIRST | |
NEXT_DEPTHFIRST | |
PREV_TERMINAL | |
NEXT_TERMINAL | |
PREV_BRANCH | |
NEXT_BRANCH | |
LEFT_BROTHER | |
RIGHT_BROTHER | |
MAIN_BRANCH | |
START_OF_GAME | |
END_OF_GAME | |
enum | Direction { PREVIOUS, NEXT, NEXT_RIGHTMOST, PREV_DEPTHFIRST, NEXT_DEPTHFIRST, PREV_TERMINAL, NEXT_TERMINAL, PREV_BRANCH, NEXT_BRANCH, LEFT_BROTHER, RIGHT_BROTHER, MAIN_BRANCH, START_OF_GAME, END_OF_GAME } |
Public Member Functions | |
SgNode () | |
~SgNode () | |
SgNode * | CopyTree () const |
Return a newly allocated copy of this node and its subtree. | |
SgVector< SgPoint > | VectorProp (SgPropID prop) const |
bool | HasFather () const |
bool | IsRoot () const |
bool | HasLeftBrother () const |
bool | HasRightBrother () const |
bool | HasSon () const |
bool | HasBrother () const |
HasLeftBrother(node) OR HasRightBrother(node). | |
bool | IsOnMain () const |
True of the node is on the main branch of the tree, that is none of its ancestors has a left brother. | |
bool | IsTerminal () const |
NOT HasSon(node). | |
bool | IsBranchPoint () const |
NumSons(node) >= 2. | |
int | NumSons () const |
int | NumLeftBrothers () const |
SgNode * | Root () const |
SgNode * | Father () const |
SgNode * | LeftBrother () const |
SgNode * | RightBrother () const |
SgNode * | LeftMostSon () const |
SgNode * | RightMostSon () const |
SgNode * | NextDepthFirst () const |
Depth-first traversal of the tree. | |
SgNode * | PrevDepthFirst () const |
Inverse operation of NextDepthFirst. | |
SgNode * | NodeInDirection (Direction dir) const |
Return the next node in the given direction. | |
bool | ContainsText (const std::string &findText) |
Return whether this node contains a property that matches the given text. | |
void | PathToRoot (SgVectorOf< SgNode > *path) const |
Returns all nodes on path from this node up to the root. | |
void | ShortestPathTo (SgNode *node, int *numBack, SgVectorOf< SgNode > *path) const |
Find the closest common ancestor of the two nodes. | |
void | PromoteNode () |
Promote this node to first son. | |
void | PromotePath () |
The tree above this node is changed such that this node is on the main path. | |
void | DeleteSubtree () |
Deletes all nodes below this node, but not this node itself. | |
void | DeleteBranches () |
Deletes everything below the current node except the main branch. | |
void | DeleteTree () |
Deletes the tree that this node is part of. | |
SgNode * | NewFather () |
SgNode * | NewRightBrother () |
SgNode * | NewLeftMostSon () |
SgNode * | NewRightMostSon () |
Insert a node at the appropriate place in the tree. | |
void | AppendTo (SgNode *n) |
Append this tree to '*n'. | |
SgPropList & | Props () |
const SgPropList & | Props () const |
void | Add (const SgProp *prop) |
SgProp * | Get (SgPropID id) const |
bool | HasProp (SgPropID id) const |
HasProp also handles abstract node properties like SG_PROP_TERMINAL and SG_PROP_BRANCH, while Get only returns real properties. | |
bool | HasNodeMove () const |
has SG_PROP_MOVE_BLACK or SG_PROP_MOVE_WHITE | |
SgBlackWhite | NodePlayer () const |
Player of move. | |
SgPoint | NodeMove () const |
SgNode * | TopProp (SgPropID id) const |
Return the most recent node that has the given property, starting backwards from this node. | |
int | GetIntProp (SgPropID id) const |
Return the value of the given property at this node. | |
bool | GetIntProp (SgPropID id, int *value) const |
return if property exists. | |
double | GetRealProp (SgPropID id) const |
Value of the given property at this node. | |
void | SetIntProp (SgPropID id, int value) |
Set the value of the given property at this node to 'value'. | |
void | SetRealProp (SgPropID id, double value, int precision=0) |
Set the value of the given property at this node. | |
void | SetStringProp (SgPropID id, const std::string &value) |
Set the value of the given property at this node to 'value'. | |
bool | GetStringProp (SgPropID id, std::string *value) const |
Return the value of the given property at this node. | |
void | SetListProp (SgPropID id, const SgVector< SgPoint > &value) |
Set the value of the given property at this node to 'value'. | |
void | SetListProp (SgPropID id, const SgPointSet &value) |
void | AddComment (const std::string &comment) |
Add comment to existing SG_PROP_COMMENT of this node, or create a new SG_PROP_COMMENT with this text. | |
SgProp * | CopyPropFrom (const SgNode &sourceNode, SgPropID id) |
If it exists, copy the property with the given 'id' from 'sourceNode' to this node, and return it. | |
void | CopyAllPropsFrom (const SgNode &sourceNode) |
Copy all properties from 'sourceNode' to this node. | |
SgProp * | AddMoveProp (SgMove move, SgBlackWhite player) |
Add a move property to this node with 'move' played by 'player'. | |
SgBlackWhite | Player () const |
Return the player, if explicitely set. | |
int | CountNodes (bool fSetPropOnThisNode) |
Count the nodes in this subtree and sets SG_PROP_NUM_NODES for each interior node in the subtree that has at least two sons, plus for this node if 'fSetPropOnThisNode' is set. | |
Static Public Member Functions | |
static SgNode * | LinkTrees (const SgVectorOf< SgNode > &roots) |
Add a new node and add all trees in 'roots' as subtrees of that node. | |
static void | CopySubtree (const SgNode *node, SgNode *copy) |
static void | GetStatistics (int *numAlloc, int *numUsed) |
Total number of nodes allocated, still in use. | |
static void | MemCheck () |
static std::string | TreeIndex (const SgNode *node) |
Location of node in tree. | |
Private Member Functions | |
void | LinkWithBrother (SgNode *node) |
void | Mark () |
void | Unmark () |
bool | IsMarked () const |
SgNode (const SgNode &) | |
Not implemented. | |
SgNode & | operator= (const SgNode &) |
Not implemented. | |
Private Attributes | |
SgNode * | m_son |
SgNode * | m_father |
SgNode * | m_brother |
SgPropList | m_props |
bool | m_marked |
Static Private Attributes | |
static int | s_alloc = 0 |
static int | s_free = 0 |
enum SgNode::Direction |
SgNode::SgNode | ( | ) |
Definition at line 27 of file SgNode.cpp.
References s_alloc.
Referenced by CopyTree(), LinkTrees(), NewFather(), NewLeftMostSon(), and NewRightBrother().
SgNode::~SgNode | ( | ) |
Definition at line 39 of file SgNode.cpp.
References HasFather(), HasLeftBrother(), HasSon(), LeftBrother(), LinkWithBrother(), m_brother, m_father, m_son, s_free, and SG_ASSERT.
SgNode::SgNode | ( | const SgNode & | ) | [private] |
Not implemented.
void SgNode::Add | ( | const SgProp * | prop | ) |
Definition at line 226 of file SgNode.h.
References SgPropList::Add(), Father(), SgProp::Flag(), HasFather(), m_props, SG_ASSERT, and SG_PROPCLASS_ROOT.
Referenced by AddComment(), AddMoveProp(), CopyAllPropsFrom(), CopyPropFrom(), SgGameReader::HandleProperties(), SgSearchTracer::InitTracing(), SetIntProp(), SetListProp(), SetRealProp(), SetStringProp(), SgSearchTracer::TraceValue(), and SgGameWriter::WriteGame().
void SgNode::AddComment | ( | const std::string & | comment | ) |
Add comment to existing SG_PROP_COMMENT of this node, or create a new SG_PROP_COMMENT with this text.
Definition at line 323 of file SgNode.cpp.
References Add(), SgPropText::AppendText(), Get(), and SG_PROP_COMMENT.
Referenced by SgSearchTracer::StartOfDepth(), and SgSearchTracer::TraceComment().
SgProp * SgNode::AddMoveProp | ( | SgMove | move, | |
SgBlackWhite | player | |||
) |
Add a move property to this node with 'move' played by 'player'.
Definition at line 699 of file SgNode.cpp.
References Add(), SG_ASSERT_BW, SG_BLACK, SG_PROP_MOVE_BLACK, and SG_PROP_MOVE_WHITE.
Referenced by SgSearchTracer::AddMoveProp().
void SgNode::AppendTo | ( | SgNode * | n | ) |
Append this tree to '*n'.
Definition at line 530 of file SgNode.cpp.
References HasBrother(), HasFather(), HasSon(), m_brother, m_father, m_son, RightMostSon(), and SG_ASSERT.
Referenced by SgSearchTracer::AppendTrace().
bool SgNode::ContainsText | ( | const std::string & | findText | ) |
Return whether this node contains a property that matches the given text.
Doesn't handle text representing special properties.
Definition at line 315 of file SgNode.cpp.
References SgProp::ConvertFindTextToPropID(), SgPropList::GetPropContainingText(), m_props, SG_ASSERT, and SG_PROP_NONE.
void SgNode::CopyAllPropsFrom | ( | const SgNode & | sourceNode | ) |
Copy all properties from 'sourceNode' to this node.
Definition at line 677 of file SgNode.cpp.
References Add(), and Props().
Referenced by CopySubtree(), and CopyTree().
If it exists, copy the property with the given 'id' from 'sourceNode' to this node, and return it.
If the property doesn't exist, return 0.
Definition at line 686 of file SgNode.cpp.
References Add(), SgProp::Duplicate(), and Get().
Definition at line 76 of file SgNode.cpp.
References CopyAllPropsFrom(), LeftMostSon(), NewRightMostSon(), and RightBrother().
Referenced by CopyTree().
SgNode * SgNode::CopyTree | ( | ) | const |
Return a newly allocated copy of this node and its subtree.
Definition at line 87 of file SgNode.cpp.
References CopyAllPropsFrom(), CopySubtree(), and SgNode().
int SgNode::CountNodes | ( | bool | fSetPropOnThisNode | ) |
Count the nodes in this subtree and sets SG_PROP_NUM_NODES for each interior node in the subtree that has at least two sons, plus for this node if 'fSetPropOnThisNode' is set.
Return the number of nodes in the subtree, including this node.
Definition at line 715 of file SgNode.cpp.
References IsBranchPoint(), SetIntProp(), and SG_PROP_NUM_NODES.
void SgNode::DeleteBranches | ( | ) |
Deletes everything below the current node except the main branch.
Definition at line 444 of file SgNode.cpp.
References DeleteSubtree(), LeftMostSon(), and RightBrother().
void SgNode::DeleteSubtree | ( | ) |
Deletes all nodes below this node, but not this node itself.
Definition at line 436 of file SgNode.cpp.
References HasSon(), and LeftMostSon().
Referenced by DeleteBranches(), and DeleteTree().
void SgNode::DeleteTree | ( | ) |
Deletes the tree that this node is part of.
Same as:
SgNode* root = Root(); root->DeleteSubtree(); delete root;
Definition at line 461 of file SgNode.cpp.
References DeleteSubtree(), and Root().
SgNode* SgNode::Father | ( | ) | const |
Definition at line 125 of file SgNode.h.
References m_father.
Referenced by Add(), SgNodeUtil::GetMoveNumber(), HasLeftBrother(), LeftBrother(), SgNodeConstIterator::Next(), SgNodeIterator::Next(), NextDepthFirst(), NodeInDirection(), NumLeftBrothers(), PrevDepthFirst(), PromotePath(), Root(), SgSearchTracer::StartOfDepth(), SgSearchTracer::TakeBackTraceNode(), TopProp(), TreeIndex(), and SgNodeUtil::UpdateTime().
Definition at line 235 of file SgNode.h.
References SgPropList::Get(), and m_props.
Referenced by AddComment(), CopyPropFrom(), GetIntProp(), GetRealProp(), GetStringProp(), HasProp(), Player(), SetIntProp(), SetListProp(), SetRealProp(), SetStringProp(), TopProp(), and VectorProp().
bool SgNode::GetIntProp | ( | SgPropID | id, | |
int * | value | |||
) | const |
return if property exists.
If true, return its value in *value
Definition at line 563 of file SgNode.cpp.
References Get(), and SgPropInt::Value().
int SgNode::GetIntProp | ( | SgPropID | id | ) | const |
Return the value of the given property at this node.
Or 0 if there is no such property. The property must be of class SgPropInt (or a derived class).
Definition at line 554 of file SgNode.cpp.
References Get(), and SgPropInt::Value().
Referenced by SgTimeRecord::GetOTMovesFromTree(), SgGameWriter::HandleProps(), NodeMove(), SgNodeUtil::UpdateTime(), and SgGameWriter::WriteGame().
double SgNode::GetRealProp | ( | SgPropID | id | ) | const |
Value of the given property at this node.
Returns 0 if there is no such property. The property must be of class SgPropReal.
Definition at line 598 of file SgNode.cpp.
References Get(), and SgPropReal::Value().
Referenced by SgTimeRecord::GetTimeFromTree(), and SgNodeUtil::UpdateTime().
void SgNode::GetStatistics | ( | int * | numAlloc, | |
int * | numUsed | |||
) | [static] |
bool SgNode::GetStringProp | ( | SgPropID | id, | |
std::string * | value | |||
) | const |
Return the value of the given property at this node.
Or 0 if there is no such property. The property must be of class SgPropText (or a derived class).
Definition at line 633 of file SgNode.cpp.
References Get(), and SgPropText::Value().
bool SgNode::HasBrother | ( | ) | const |
HasLeftBrother(node) OR HasRightBrother(node).
Definition at line 97 of file SgNode.h.
References HasLeftBrother(), and HasRightBrother().
Referenced by AppendTo(), and NodeInDirection().
bool SgNode::HasFather | ( | ) | const |
Definition at line 74 of file SgNode.h.
References m_father.
Referenced by Add(), AppendTo(), HasLeftBrother(), LeftBrother(), SgNodeConstIterator::Next(), SgNodeIterator::Next(), NextDepthFirst(), NodeInDirection(), PrevDepthFirst(), Root(), SgSearchTracer::StartOfDepth(), TopProp(), and ~SgNode().
bool SgNode::HasLeftBrother | ( | ) | const |
Definition at line 98 of file SgNode.cpp.
References Father(), HasFather(), and LeftMostSon().
Referenced by HasBrother(), LeftBrother(), NewFather(), NodeInDirection(), PrevDepthFirst(), PromoteNode(), and ~SgNode().
bool SgNode::HasNodeMove | ( | ) | const |
has SG_PROP_MOVE_BLACK or SG_PROP_MOVE_WHITE
Definition at line 574 of file SgNode.cpp.
References HasProp(), SG_PROP_MOVE_BLACK, and SG_PROP_MOVE_WHITE.
Referenced by NodePlayer().
bool SgNode::HasProp | ( | SgPropID | id | ) | const |
HasProp also handles abstract node properties like SG_PROP_TERMINAL and SG_PROP_BRANCH, while Get only returns real properties.
Definition at line 335 of file SgNode.cpp.
References Get(), IsBranchPoint(), IsTerminal(), SG_PROP_BRANCH, and SG_PROP_TERMINAL.
Referenced by SgNodeUtil::GetMoveNumber(), HasNodeMove(), NodePlayer(), SgNodeUtil::UpdateTime(), SgGameWriter::WriteGame(), and SgGameWriter::WriteNode().
bool SgNode::HasRightBrother | ( | ) | const |
Definition at line 86 of file SgNode.h.
References m_brother.
Referenced by HasBrother(), LinkWithBrother(), SgNodeConstIterator::Next(), SgNodeIterator::Next(), NextDepthFirst(), NodeInDirection(), NumSons(), RightMostSon(), and SgGameWriter::WriteSubtree().
bool SgNode::HasSon | ( | ) | const |
Definition at line 91 of file SgNode.h.
References m_son.
Referenced by AppendTo(), DeleteSubtree(), NewRightMostSon(), SgNodeConstIterator::Next(), SgNodeIterator::Next(), NextDepthFirst(), NumSons(), SgTimeRecord::PlayedMove(), PrevDepthFirst(), SgNodeConstIterator::SgNodeConstIterator(), SgNodeIterator::SgNodeIterator(), and ~SgNode().
bool SgNode::IsBranchPoint | ( | ) | const |
NumSons(node) >= 2.
Definition at line 114 of file SgNode.h.
References m_brother, and m_son.
Referenced by CountNodes(), HasProp(), and NodeInDirection().
bool SgNode::IsMarked | ( | ) | const [private] |
bool SgNode::IsOnMain | ( | ) | const |
True of the node is on the main branch of the tree, that is none of its ancestors has a left brother.
Definition at line 103 of file SgNode.cpp.
bool SgNode::IsTerminal | ( | ) | const |
NOT HasSon(node).
Definition at line 108 of file SgNode.h.
References m_son.
Referenced by HasProp(), and NodeInDirection().
SgNode * SgNode::LeftBrother | ( | ) | const |
Definition at line 179 of file SgNode.cpp.
References Father(), HasFather(), HasLeftBrother(), LeftMostSon(), and RightBrother().
Referenced by NewFather(), NodeInDirection(), PrevDepthFirst(), and ~SgNode().
SgNode* SgNode::LeftMostSon | ( | ) | const |
Definition at line 137 of file SgNode.h.
References m_son.
Referenced by CopySubtree(), DeleteBranches(), DeleteSubtree(), HasLeftBrother(), LeftBrother(), SgNodeConstIterator::Next(), SgNodeIterator::Next(), NextDepthFirst(), NodeInDirection(), NumLeftBrothers(), NumSons(), RightMostSon(), SgNodeConstIterator::SgNodeConstIterator(), SgNodeIterator::SgNodeIterator(), TreeIndex(), and SgGameWriter::WriteSubtree().
SgNode * SgNode::LinkTrees | ( | const SgVectorOf< SgNode > & | roots | ) | [static] |
void SgNode::LinkWithBrother | ( | SgNode * | node | ) | [private] |
Definition at line 121 of file SgNode.cpp.
References HasRightBrother(), m_brother, m_father, and RightBrother().
Referenced by ~SgNode().
void SgNode::Mark | ( | ) | [private] |
void SgNode::MemCheck | ( | ) | [static] |
Definition at line 738 of file SgNode.cpp.
References s_alloc, s_free, and SG_ASSERT.
Referenced by SgMemCheck().
SgNode * SgNode::NewFather | ( | ) |
Definition at line 468 of file SgNode.cpp.
References HasLeftBrother(), LeftBrother(), m_brother, m_father, m_son, and SgNode().
SgNode * SgNode::NewLeftMostSon | ( | ) |
Definition at line 495 of file SgNode.cpp.
References m_brother, m_father, m_son, and SgNode().
Referenced by NewRightMostSon().
SgNode * SgNode::NewRightBrother | ( | ) |
Definition at line 486 of file SgNode.cpp.
References m_brother, m_father, and SgNode().
Referenced by NewRightMostSon().
SgNode * SgNode::NewRightMostSon | ( | ) |
Insert a node at the appropriate place in the tree.
Definition at line 504 of file SgNode.cpp.
References HasSon(), NewLeftMostSon(), NewRightBrother(), and RightMostSon().
Referenced by SgSearchTracer::AddTraceNode(), CopySubtree(), and SgSearchTracer::StartOfDepth().
SgNode * SgNode::NextDepthFirst | ( | ) | const |
Depth-first traversal of the tree.
Definition at line 200 of file SgNode.cpp.
References Father(), HasFather(), HasRightBrother(), HasSon(), LeftMostSon(), and RightBrother().
Referenced by SgNodeConstIterator::Next(), SgNodeIterator::Next(), and NodeInDirection().
Return the next node in the given direction.
Returns 0 if there is no such node.
Definition at line 238 of file SgNode.cpp.
References END_OF_GAME, Father(), HasBrother(), HasFather(), HasLeftBrother(), HasRightBrother(), IsBranchPoint(), IsTerminal(), LEFT_BROTHER, LeftBrother(), LeftMostSon(), MAIN_BRANCH, NEXT, NEXT_BRANCH, NEXT_DEPTHFIRST, NEXT_RIGHTMOST, NEXT_TERMINAL, NextDepthFirst(), PREV_BRANCH, PREV_DEPTHFIRST, PREV_TERMINAL, PrevDepthFirst(), PREVIOUS, RIGHT_BROTHER, RightBrother(), RightMostSon(), Root(), SG_ASSERT, and START_OF_GAME.
SgPoint SgNode::NodeMove | ( | ) | const |
Definition at line 587 of file SgNode.cpp.
References GetIntProp(), SG_NULLMOVE, SG_PROP_MOVE_BLACK, and SG_PROP_MOVE_WHITE.
SgBlackWhite SgNode::NodePlayer | ( | ) | const |
Player of move.
REQUIRES: HasNodeMove()
Definition at line 579 of file SgNode.cpp.
References HasNodeMove(), HasProp(), SG_ASSERT, SG_BLACK, SG_PROP_MOVE_BLACK, and SG_WHITE.
int SgNode::NumLeftBrothers | ( | ) | const |
int SgNode::NumSons | ( | ) | const |
Definition at line 139 of file SgNode.cpp.
References HasRightBrother(), HasSon(), LeftMostSon(), and RightBrother().
void SgNode::PathToRoot | ( | SgVectorOf< SgNode > * | path | ) | const |
Returns all nodes on path from this node up to the root.
Definition at line 230 of file SgNode.cpp.
References SgVector< void * >::Clear(), and SgVectorOf< T >::PushBack().
SgBlackWhite SgNode::Player | ( | ) | const |
Return the player, if explicitely set.
REQUIRES: Get(SG_PROP_PLAYER)
Definition at line 709 of file SgNode.cpp.
References Get(), SG_ASSERT, and SG_PROP_PLAYER.
SgNode * SgNode::PrevDepthFirst | ( | ) | const |
Inverse operation of NextDepthFirst.
Definition at line 215 of file SgNode.cpp.
References Father(), HasFather(), HasLeftBrother(), HasSon(), LeftBrother(), and RightMostSon().
Referenced by NodeInDirection().
void SgNode::PromoteNode | ( | ) |
Promote this node to first son.
Moves all its left brothers one position to the right.
Definition at line 412 of file SgNode.cpp.
References HasLeftBrother(), m_brother, m_father, and m_son.
Referenced by PromotePath().
void SgNode::PromotePath | ( | ) |
The tree above this node is changed such that this node is on the main path.
(first in depth-first search).
Definition at line 426 of file SgNode.cpp.
References Father(), and PromoteNode().
const SgPropList& SgNode::Props | ( | ) | const |
SgPropList& SgNode::Props | ( | ) |
Definition at line 216 of file SgNode.h.
References m_props.
Referenced by CopyAllPropsFrom(), SgGameWriter::WriteGame(), and SgGameWriter::WriteNode().
SgNode* SgNode::RightBrother | ( | ) | const |
Definition at line 132 of file SgNode.h.
References m_brother.
Referenced by CopySubtree(), DeleteBranches(), LeftBrother(), LinkWithBrother(), SgNodeConstIterator::Next(), SgNodeIterator::Next(), NextDepthFirst(), NodeInDirection(), NumLeftBrothers(), NumSons(), SgSonNodeConstIterator::operator++(), SgSonNodeIterator::operator++(), RightMostSon(), and TreeIndex().
SgNode * SgNode::RightMostSon | ( | ) | const |
Definition at line 189 of file SgNode.cpp.
References HasRightBrother(), LeftMostSon(), and RightBrother().
Referenced by AppendTo(), NewRightMostSon(), NodeInDirection(), and PrevDepthFirst().
SgNode * SgNode::Root | ( | ) | const |
Definition at line 171 of file SgNode.cpp.
References Father(), and HasFather().
Referenced by SgSearchTracer::AppendTrace(), DeleteTree(), NodeInDirection(), and SgGameReader::ReadGame().
void SgNode::SetIntProp | ( | SgPropID | id, | |
int | value | |||
) |
Set the value of the given property at this node to 'value'.
Create such a property if it doesn't exist yet. The property must be of class SgPropInt (or a derived class).
Definition at line 607 of file SgNode.cpp.
References Add(), SgProp::CreateProperty(), Get(), and SgPropInt::SetValue().
Referenced by CountNodes(), SgTimeRecord::PlayedMove(), and SgSearchTracer::StartOfDepth().
void SgNode::SetListProp | ( | SgPropID | id, | |
const SgPointSet & | value | |||
) |
Set the value of the given property at this node to 'value'.
Create such a property if it doesn't exist yet. The property must be of class SgPropPointList (or a derived class).
Definition at line 657 of file SgNode.cpp.
References Add(), SgProp::CreateProperty(), Get(), and SgPropPointList::SetValue().
Referenced by SetListProp().
void SgNode::SetRealProp | ( | SgPropID | id, | |
double | value, | |||
int | precision = 0 | |||
) |
Set the value of the given property at this node.
Create such a property if it doesn't exist yet. The property must be of class SgPropReal.
id | ||
value | ||
precision | Precision; 0 means default precision (6) |
Definition at line 620 of file SgNode.cpp.
References Add(), SgProp::CreateProperty(), Get(), and SgPropReal::SetValue().
Referenced by SgTimeRecord::PlayedMove(), SgTimeRecord::SetClock(), and SgTimeRecord::SetTimeInTree().
void SgNode::SetStringProp | ( | SgPropID | id, | |
const std::string & | value | |||
) |
Set the value of the given property at this node to 'value'.
Create such a property if it doesn't exist yet. The property must be of class SgPropText (or a derived class).
Definition at line 644 of file SgNode.cpp.
References Add(), SgProp::CreateProperty(), Get(), and SgPropText::SetValue().
void SgNode::ShortestPathTo | ( | SgNode * | node, | |
int * | numBack, | |||
SgVectorOf< SgNode > * | path | |||
) | const |
Find the closest common ancestor of the two nodes.
Returns the path from this node to 'node': how many times to go one node back, and a vector of the nodes to execute from there (excluding the common ancestor).
Definition at line 348 of file SgNode.cpp.
References SgVector< void * >::Clear(), IsMarked(), m_father, Mark(), SgVectorOf< T >::PushBack(), SgVector< void * >::Reverse(), SG_ASSERT, and Unmark().
Return the most recent node that has the given property, starting backwards from this node.
Return this node if it has the wanted property; return the root of the tree if no node with that property was found.
Definition at line 545 of file SgNode.cpp.
References Father(), Get(), and HasFather().
Referenced by SgTimeRecord::GetOTMovesFromTree(), and SgTimeRecord::GetTimeFromTree().
string SgNode::TreeIndex | ( | const SgNode * | node | ) | [static] |
Location of node in tree.
This function builds a unique string from the location of a node in the tree. It is a list of integers separated by dots, each integer represents the child index (counting from 1) for each node in the path from the root to the given node. For example
root -- node1 -- node2 | +- node3 root "1" node1 "1.1" node2 "1.1.1" node3 "1.2"
Definition at line 743 of file SgNode.cpp.
References Father(), LeftMostSon(), RightBrother(), and SG_ASSERT.
void SgNode::Unmark | ( | ) | [private] |
Definition at line 131 of file SgNode.cpp.
References Get(), and SgPropPointList::Value().
SgNode* SgNode::m_brother [private] |
Definition at line 380 of file SgNode.h.
Referenced by AppendTo(), HasRightBrother(), IsBranchPoint(), LinkTrees(), LinkWithBrother(), NewFather(), NewLeftMostSon(), NewRightBrother(), PromoteNode(), RightBrother(), and ~SgNode().
SgNode* SgNode::m_father [private] |
Definition at line 378 of file SgNode.h.
Referenced by AppendTo(), Father(), HasFather(), IsOnMain(), IsRoot(), LinkTrees(), LinkWithBrother(), NewFather(), NewLeftMostSon(), NewRightBrother(), PromoteNode(), ShortestPathTo(), and ~SgNode().
bool SgNode::m_marked [private] |
SgPropList SgNode::m_props [private] |
SgNode* SgNode::m_son [private] |
Definition at line 376 of file SgNode.h.
Referenced by AppendTo(), HasSon(), IsBranchPoint(), IsOnMain(), IsTerminal(), LeftMostSon(), LinkTrees(), NewFather(), NewLeftMostSon(), PromoteNode(), and ~SgNode().
int SgNode::s_alloc = 0 [static, private] |
int SgNode::s_free = 0 [static, private] |