eng::Node::SortedNodes Class Reference

Flyweight container of Nodes sorted by priority (holds children/siblings). More...

#include <eng_node.hh>

List of all members.

Public Member Functions

 SortedNodes (void)
 SortedNodes (const SortedNodes &src)
SortedNodesoperator= (const SortedNodes &src)
 ~SortedNodes ()
const SortableNodeoperator[] (uint i) const
const SortableNodefront (void) const
const SortableNodeback (void) const
uint size (void) const
bool empty (void) const
void clear (void)
pair< bool, uintfind_last (const SortableNode &sortableNode) const
uint insert (const SortableNode &sortableNode)
bool remove_first (const SortableNode &sortableNode)
void remove_idx (const uint idx)

Private Attributes

SortedArray
< SortableNode > * 
mSortedNodes


Detailed Description

Flyweight container of Nodes sorted by priority (holds children/siblings).

Most Nodes don't have children. Therefore, to minimize Node, SortedNodes lazy-allocates the underlying SortedArray. Doing lazy-allocation and NULL checks here in this tiny class proved to be much easier than in the Node class.


Constructor & Destructor Documentation

eng::Node::SortedNodes::SortedNodes ( void   ) 

SortedNodes methods. The underlying array is lazy-allocated to minimize Node footprint.

eng::Node::SortedNodes::SortedNodes ( const SortedNodes src  ) 

eng::Node::SortedNodes::~SortedNodes (  ) 


Member Function Documentation

Node::SortedNodes & eng::Node::SortedNodes::operator= ( const SortedNodes src  ) 

const SortableNode& eng::Node::SortedNodes::operator[] ( uint  i  )  const [inline]

const Node::SortableNode & eng::Node::SortedNodes::front ( void   )  const

const Node::SortableNode & eng::Node::SortedNodes::back ( void   )  const

uint eng::Node::SortedNodes::size ( void   )  const [inline]

bool eng::Node::SortedNodes::empty ( void   )  const [inline]

void eng::Node::SortedNodes::clear ( void   ) 

pair< bool, uint > eng::Node::SortedNodes::find_last ( const SortableNode sortableNode  )  const

Returns:
If found, returns (true,index of _LAST_ match), or (false,undefined).

uint eng::Node::SortedNodes::insert ( const SortableNode sortableNode  ) 

Returns:
Index of node inserted into sorted position. Node::Ptr is to be encapsulated into a SortableNode object in order for SortedArray to do sorting.
Reindexing siblings may seem grossly inefficient but is actually fast. The reason is that PolygonNodes would be the only type of Node that will exist as multitudes of siblings, but new PolygonNodes are inserted as the LAST among equals, so ReindexSiblings() in fact indexs only the last one. Fast indexing depends on PolygonNodes having equal values. Defining PolygonNode::Value::operator<() to sort by vix etc would be counter-productive.

bool eng::Node::SortedNodes::remove_first ( const SortableNode sortableNode  ) 

Remove the first Node having an equal priority.

Returns:
True if Node was removed, false if Node was absent (NOP).

void eng::Node::SortedNodes::remove_idx ( const uint  idx  ) 

Directly remove Node by index.


Member Data Documentation

SortedArray<SortableNode>* eng::Node::SortedNodes::mSortedNodes [private]


The documentation for this class was generated from the following files: Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:22 2007