PointTreeNode Class Reference

#include <point-tree-node.h>

Inheritance diagram for PointTreeNode:

TreeNode List of all members.

Detailed Description

A TreeNode containing a Point.

A TreeNode has an integer identifier. It also contains the IDs of its parent and children, but makes no effort to maintain them.

To augment a TreeNode with your own data, there are three functions you need to provide: (1) reading the data from a stream, (2) writing the data to a stream, and (3) how to combine two nodes. The definition of "combine" will vary depending on what you're doing, but the general idea is that sometimes you will have two TreeNodes with the same ID that you want to insert into a tree. It is advisable that you make the output of Combine() symmetric, since there are no guarantees on what Tree does with duplicate-ID bins other than calling Combine().

Remember that if you implement a copy constructor for your TreeNode, you should have your copy constructor call the base class's copy constructor:
MyNode::MyNode(const MyNode& other) : TreeNode(other) {
// your copy code
}


Public Member Functions

 PointTreeNode ()
 PointTreeNode (int node_id)
 PointTreeNode (const PointTreeNode &other)
 A copy constructor, which copies the ID and parent/child info.
const Pointpoint () const
Pointmutable_point ()
void set_point (const Point &point)
bool has_point () const
virtual ~PointTreeNode ()
virtual void Combine (const TreeNode &other)
 This should not happen for PointTreeNodes, so this method will always fail.
int id () const
int parent () const
int child (int child_index) const
int child_size () const
bool has_parent () const
bool has_child () const
void set_id (int id)
void set_parent (int id)
void add_child (int id)
 Adds a child to the end of the child list.
void remove_child (int child_index)
 Removes the <child_index>th child.
void ReadFromStream (istream &input_stream)
 Read the data, including the index, from a stream.
void WriteToStream (ostream &output_stream) const
 Write the data, including the index, to a stream.

Static Public Attributes

static const int kInvalidNodeID = -1

Protected Member Functions

virtual void ReadData (istream &input_stream)
 Read the data, excluding the index, from a stream.
virtual void WriteData (ostream &output_stream) const
 Write the data, excluding the index, to a stream.


Constructor & Destructor Documentation

PointTreeNode (  ) 

PointTreeNode ( int  node_id  ) 

PointTreeNode ( const PointTreeNode other  ) 

A copy constructor, which copies the ID and parent/child info.

virtual ~PointTreeNode (  )  [inline, virtual]


Member Function Documentation

const Point& point (  )  const [inline]

Point* mutable_point (  )  [inline]

void set_point ( const Point point  )  [inline]

bool has_point (  )  const [inline]

void Combine ( const TreeNode other  )  [virtual]

This should not happen for PointTreeNodes, so this method will always fail.

Implements TreeNode.

void ReadData ( istream &  input_stream  )  [protected, virtual]

Read the data, excluding the index, from a stream.

Implements TreeNode.

void WriteData ( ostream &  output_stream  )  const [protected, virtual]

Write the data, excluding the index, to a stream.

Implements TreeNode.

int id (  )  const [inline, inherited]

int parent (  )  const [inline, inherited]

int child ( int  child_index  )  const [inline, inherited]

int child_size (  )  const [inline, inherited]

bool has_parent (  )  const [inline, inherited]

bool has_child (  )  const [inline, inherited]

void set_id ( int  id  )  [inline, inherited]

void set_parent ( int  id  )  [inline, inherited]

void add_child ( int  id  )  [inline, inherited]

Adds a child to the end of the child list.

This does not check for dupes, i.e., it is possible for a node to have two children with the same ID using this, so be careful!

void remove_child ( int  child_index  )  [inherited]

Removes the <child_index>th child.

void ReadFromStream ( istream &  input_stream  )  [inherited]

Read the data, including the index, from a stream.

Calling this will override the node's current index. The format is:

It will then call ReadData().
See also:
ReadData()

void WriteToStream ( ostream &  output_stream  )  const [inherited]

Write the data, including the index, to a stream.

This will simply write the index to the stream, followed by WriteData().

See also:
WriteData().


Member Data Documentation

const int kInvalidNodeID = -1 [static, inherited]


The documentation for this class was generated from the following files:
Generated on Fri Sep 21 11:39:06 2007 for libpmk2 by  doxygen 1.5.1