A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/tree__model_8hpp_source.html below:

NCBI C++ ToolKit: include/gui/widgets/phylo_tree/tree_model.hpp Source File

1 #ifndef GUI_WIDGETS_PHY_TREE___TREE_MODEL__HPP 2 #define GUI_WIDGETS_PHY_TREE___TREE_MODEL__HPP 51 #define NULL_TREE_IDX static_cast<TTreeIdx>(-1) 55 template

<

class

TData>

179 template

<

class

TNode>

247

{

return m_Nodes

[size_t(idx)].GetValue(); }

249 

{

return m_Nodes

[size_t(idx)].GetValue(); }

354 template

<

class

TTreeModel,

class

Fun>

357  typedef typename

TTreeModel::TNodeType TNodeType;

362

stop_scan = func(tree_model, node_idx, delta_level);

372

TNodeType* tr = &tree_model[node_idx];

374  typedef typename

TNodeType::TNodeList_I TTreeNodeIterator;

376

TTreeNodeIterator it = tr->SubNodeBegin();

377

TTreeNodeIterator it_end = tr->SubNodeEnd();

382

stack<TTreeNodeIterator> tree_stack;

385

tr = &tree_model[*it];

386

stop_scan = func(tree_model, *it, delta_level);

395

(delta_level >= 0) &&

398

it = tr->SubNodeBegin();

399

it_end = tr->SubNodeEnd();

405  if

(tree_stack.empty()) {

408

it = tree_stack.top();

410

tr = &tree_model[*it];

411

it_end = tree_model[tr->GetParent()].SubNodeEnd();

420

func(tree_model, node_idx, -1);

427 template

<

class

TTreeModel,

class

Fun>

430  return TreeDepthFirst

(tree_model, tree_model.GetRootIdx(), func);

437 template

<

class

TTreeModel>

462 template

<

class

TTreeModel,

class

Fun>

465  typedef typename

TTreeModel::TNodeType TNodeType;

466  typedef typename

TNodeType::TNodeList_I TTreeNodeIterator;

471

stop_scan = func(tree_model, node_idx, delta_level);

481

TNodeType* tr = &tree_model[node_idx];

485

TTreeNodeIterator it_end = node_iter.

m_node_list

.end();

487  if

(node_iter.

m_it

== it_end)

490

stack<NodeListIter<TTreeModel> > tree_stack;

493

tr = &tree_model[*node_iter.

m_it

];

494

stop_scan = func(tree_model, *node_iter.

m_it

, delta_level);

503

(delta_level >= 0) &&

505

tree_stack.push(node_iter);

513  if

(node_iter.

m_it

== it_end) {

514  if

(tree_stack.empty()) {

517

node_iter = tree_stack.top();

519

tr = &tree_model[*node_iter.

m_it

];

529

func(tree_model, node_idx, -1);

535 template

<

class

TTreeModel,

class

Fun>

559 template

<

class

TTreeModel,

class

Fun>

562  typedef typename

TTreeModel::TNodeType TNodeType;

568

stop_scan = func(tree_model, node_idx, delta_level);

577  typedef typename

TNodeType::TNodeList_I TTreeNodeIterator;

579

queue<TTreeIdx> node_queue;

580

node_queue.push(node_idx);

584  while

(!node_queue.empty()) {

585  TTreeIdx

node_idx = node_queue.front();

588

TNodeType* tr = &tree_model[node_idx];

590

TTreeNodeIterator it = tr->SubNodeBegin();

591

TTreeNodeIterator it_end = tr->SubNodeEnd();

592  for

(; it != it_end; ++it) {

593

stop_scan = func(tree_model, *it, delta_level);

602

node_queue.push(*it);

609  if

(--level_count == 0) {

610

level_count = node_queue.size();

616

func(tree_model, node_idx, -1);

622 template

<

class

TTreeModel,

class

Fun>

635 template

<

class

TData>

639 template

<

class

TData>

643  if

(HasChild(child_idx)) {

644  LOG_POST

(

"Trying to add duplicate child node: "

<< child_idx <<

" to another node"

);

649

m_ChildNodes.push_back(child_idx);

652 template

<

class

TData>

655

vector<TTreeIdx>::iterator iter = find(m_ChildNodes.begin(), m_ChildNodes.end(), child_idx);

657  if

(iter==m_ChildNodes.end()) {

661

m_ChildNodes.erase(iter);

664 template

<

class

TData>

667  return

( std::find(m_ChildNodes.begin(), m_ChildNodes.end(), child_idx) != m_ChildNodes.end());

677 template

<

class

TNode>

680 template

<

class

TNode>

689 template

<

class

TNode>

692  if

(node.GetParent() == TNodeType::Null())

695  return

m_Nodes[node.GetParent()];

698 template

<

class

TNode>

701  if

(node.GetParent() == TNodeType::Null())

704  return

m_Nodes[node.GetParent()];

707 template

<

class

TNode>

710

m_Nodes[size_t(parent_idx)].RemoveChild(child_idx);

711

m_Nodes[size_t(child_idx)].SetParent(Null());

714 template

<

class

TNode>

717

m_Nodes[size_t(parent_idx)].AddChild(child_idx);

718

m_Nodes[size_t(child_idx)].SetParent(parent_idx);

721 template

<

class

TNode>

724  if

(m_RootIdx == idx)

727  if

(idx >= m_Nodes.size())

730

x_ConvertUpstream(idx);

735 template

<

class

TNode>

738  TTreeIdx

parent_idx = m_Nodes[node_idx].GetParent();

740  if

(parent_idx != Null()) {

741

RemoveChild(parent_idx, node_idx);

742

x_ConvertUpstream(parent_idx);

743

AddChild(node_idx, parent_idx);

748 template

<

class

TNode>

751

m_Nodes.push_back(TNode());

752  size_t

idx = m_Nodes.size()-1;

757 template

<

class

TNode>

760  size_t

idx = m_Nodes.size();

762

m_Nodes.push_back(node);

766 template

<

class

TNode>

770

m_Nodes.reserve(target_size);

Base class for nodes in the tree.

const TData & operator*() const

const TData & GetValue() const

void RemoveChild(TTreeIdx child_idx)

Remove child node if it is a child of this node.

TData m_Data

Data object.

void RemoveParent()

Set the parent index to Null() e.g. for root node.

TNodeList::reverse_iterator TNodeList_RI

TNodeList_RI SubNodeRBegin()

Return reverse iterator to (reverse) begin of subnode array.

TTreeIdx GetParent() const

Get node's parent.

void ClearConnections()

Remove connections to parent and children of this node.

TTreeIdx m_ParentNode

Index of parent node to this node. ==Null() if this is the root node.

TData & operator*()

Return the value object for the node using de-referenceing semantics.

TNodeList_CI SubNodeEnd() const

Return const iterator to end of subnode list.

TNodeList & GetChildren()

Return the indices of this node's child nodes.

TNodeList::iterator TNodeList_I

void SetParent(TTreeIdx parent_idx)

Set index of nodes parent.

TNodeList_CRI SubNodeRBegin() const

Return const reverse iterator to (reverse) of begin of subnode array.

TNodeList_CRI SubNodeREnd() const

Return const reverse iterator to (reverse) end of subnode array.

bool HasChild(TTreeIdx child_idx) const

Check if another node is a child of this node.

CTreeModelNode()

Construct an empty node (null parent)

TData & GetValue()

Return the value object for the node.

TNodeList_I SubNodeBegin()

Return iterator to first subnode index.

TNodeList_RI SubNodeREnd()

Return reverse iterator to (reverse) end of subnode array.

TNodeList::const_reverse_iterator TNodeList_CRI

bool HasParent() const

Check if the node has a parent.

TNodeList::const_iterator TNodeList_CI

const TNodeList & GetChildren() const

const TData * operator->() const

vector< TTreeIdx > TNodeList

TNodeList_I SubNodeEnd()

Return iterator to end of subnode list.

bool IsLeaf() const

Report whether this is a leaf node.

static TTreeIdx Null()

Static function that returns the null value.

TNodeList_CI SubNodeBegin() const

Return const iterator to first subnode index.

vector< TTreeIdx > m_ChildNodes

Indices of all the children of this node.

void AddChild(TTreeIdx child_idx)

Add a child node.

void SetValue(const TData &data)

Set the value-object for the node.

int m_NumNodes

Number of nodes in tree (not including collapsed/hidden nodes)

const TNode & operator[](TTreeIdx idx) const

void ReRoot(TTreeIdx idx)

Sets the root idx to be 'idx' and updates the tree so that all nodes above the new root become childr...

virtual void x_ConvertUpstream(TTreeIdx node_idx)

Convert parents of node_idx to be its children.

const TValueType & GetNodeValue(TTreeIdx idx) const

const TNode & GetRoot() const

TNodeType & GetParent(TNodeType &node)

Return a reference to the parent node of the given node.

TNodeType::TNodeList_I TNodeList_I

TNodeVecType m_Nodes

The list of nodes in the tree.

TTreeIdx AddNode(const TNode &node)

Add a copy of node 'node' to the tree and return its index.

TValueType & GetNodeValue(TTreeIdx idx)

Return a reference to the 'value' object of a node.

const TNodeType & GetParent(TNodeType &node) const

TNodeType & operator[](TTreeIdx idx)

Use operator[] to return a reference to the node at 'idx'.

void Reserve(size_t target_size)

Allocate the memory in advance, if you know how big the tree will be.

size_t GetNumNodes() const

Get the number of displayed nodes in current tree layout.

static TTreeIdx Null()

Return the index value that represents a NULL node.

size_t GetSize() const

Get the number of nodes currently in the array.

void SetNumNodes(int count)

Set the number of displayed nodes in current tree layout.

CTreeModel()

Create empty tree. Tree is not valid at this point (no nodes)

TNodeType & GetNode(TTreeIdx idx)

Return a reference to the node at the given index.

TNodeType::TNodeList_CRI TNodeList_CRI

TNodeType::TNodeList_CI TNodeList_CI

void Clear()

Remove all nodes (empty array) and set root index to Null.

TNodeType::TNodeList_RI TNodeList_RI

TNodeType & GetRoot()

Return a reference to the root node of the tree.

void AddChild(TTreeIdx parent_idx, TTreeIdx child_idx)

Add the node at 'child_idx' to the children 'parent_idx'.

TNodeType::TNodeList TNodeList

const TNode & GetNode(TTreeIdx idx) const

std::vector< TNodeType > TNodeVecType

TTreeIdx GetRootIdx() const

Return the index of the root node.

TNode::TValueType TValueType

TTreeIdx AddNode()

Add a new default node to the tree and return its index.

void RemoveChild(TTreeIdx parent_idx, TTreeIdx child_idx)

Remove the node at 'child_idx' from its parent 'parent_idx' Nothing is done if the node 'child_idx' i...

void SetRootIdx(TTreeIdx idx)

Set the index of the root node of the tree.

TTreeIdx m_RootIdx

The index of the root node within the tree.

Include a standard set of the NCBI C++ Toolkit most basic headers.

#define LOG_POST(message)

This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...

#define NCBI_THROW(exception_class, err_code, message)

Generic macro to throw an exception, given the exception class, error code and message string.

#define END_NCBI_SCOPE

End previously defined NCBI scope.

#define BEGIN_NCBI_SCOPE

Define ncbi namespace.

ETreeTraverseCode

Tree traverse code returned by the traverse predicate function.

@ eTreeTraverseStop

Stop traversal (return form algorithm)

@ eTreeTraverse

Keep traversal.

@ eTreeTraverseStepOver

Do not traverse current node (pick the next one)

Depth-first tree traversal which allows the traversed tree to update the list of child nodes at the c...

NodeListIter(const NodeListIter &rhs)

void SetNode(TNodeType *tr)

TTreeModel::TNodeType TNodeType

TTreeModel::TNodeList TNodeList

NodeListIter & operator=(const NodeListIter &rhs)

TNodeType::TNodeList_I TTreeNodeIterator

NodeListIter(TNodeType *tr)

Fun TreeBreadthFirst(TTreeModel &tree_model, typename TTreeModel::TTreeIdx node_idx, Fun func)

Breadth-first tree traversall.

#define NULL_TREE_IDX

Global define for a NULL link in the tree used for comparison.

Fun TreeDepthFirst(TTreeModel &tree_model, typename TTreeModel::TTreeIdx node_idx, Fun func)

Depth-first tree traversal algorithm.

size_t TTreeIdx

Bi-directionaly linked N way tree allocated in a contiguous memory block.

Fun TreeDepthFirstInvarient(TTreeModel &tree_model, typename TTreeModel::TTreeIdx node_idx, Fun func)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4