NEST main@f146f75
Loading...
Searching...
No Matches
nest::Ntree< D, T, max_capacity, max_depth > Class Template Reference

A Ntree object represents a subtree or leaf in a Ntree structure. More...

#include <ntree.h>

Collaboration diagram for nest::Ntree< D, T, max_capacity, max_depth >:
[legend]

Classes

class  iterator
 Iterator iterating the nodes in a Quadtree. More...
class  masked_iterator
 Iterator iterating the nodes in a Quadtree inside a Mask. More...

Public Types

typedef Position< D > key_type
typedef T mapped_type
typedef std::pair< Position< D >, T > value_type
typedef value_type & reference
typedef const value_type & const_reference

Public Member Functions

 Ntree (const Position< D > &lower_left, const Position< D > &extent, std::bitset< D > periodic=0, Ntree *parent=0, int subquad=0)
 Create a Ntree that covers the region defined by the two input positions.
 ~Ntree ()
 Delete Ntree recursively.
iterator insert (Position< D > pos, const T &node)
 Traverse quadtree structure from current ntree.
iterator insert (const value_type &val)
 std::multimap like insert method
iterator insert (iterator, const value_type &val)
 STL container compatible insert method (the first argument is ignored).
void push_back (const value_type &val)
 STL container compatible push_back method.
std::vector< value_type > get_nodes ()
std::vector< value_type > get_nodes (const Mask< D > &mask, const Position< D > &anchor)
 Applies a Mask to this ntree.
iterator begin ()
 This function returns a node iterator which will traverse the subtree below this Ntree.
iterator end ()
masked_iterator masked_begin (const Mask< D > &mask, const Position< D > &anchor)
 This function returns a masked node iterator which will traverse the subtree below this Ntree, skipping nodes outside the mask.
masked_iterator masked_end ()
bool is_leaf () const

Static Public Attributes

static const int N = 1 << D

Protected Member Functions

void split_ ()
 Change a leaf ntree to a regular ntree with four children regions.
void append_nodes_ (std::vector< value_type > &)
 Append this ntree's nodes to the vector.
void append_nodes_ (std::vector< value_type > &, const Mask< D > &, const Position< D > &)
 Append this ntree's nodes inside the mask to the vector.
int subquad_ (const Position< D > &)

Protected Attributes

Position< D > lower_left_
Position< D > extent_
bool leaf_
std::vector< value_type > nodes_
Ntree * parent_
int my_subquad_
 This Ntree's subquad number within parent.
int my_depth_
 This Ntree's depth in the tree.
Ntree * children_ [N]
std::bitset< D > periodic_
 periodic b.c.

Friends

class iterator
class masked_iterator

Detailed Description

template<int D, class T, int max_capacity = 100, int max_depth = 10>
class nest::Ntree< D, T, max_capacity, max_depth >

A Ntree object represents a subtree or leaf in a Ntree structure.

Any ntree covers a specific region in space. A leaf ntree contains a list of items and their corresponding positions. A branch ntree contains a list of N=1<<D other ntrees, each covering a region corresponding to the upper-left, lower-left, upper-right and lower-left corner of their mother ntree.

Member Typedef Documentation

◆ const_reference

template<int D, class T, int max_capacity = 100, int max_depth = 10>
typedef const value_type& nest::Ntree< D, T, max_capacity, max_depth >::const_reference

◆ key_type

template<int D, class T, int max_capacity = 100, int max_depth = 10>
typedef Position< D > nest::Ntree< D, T, max_capacity, max_depth >::key_type

◆ mapped_type

template<int D, class T, int max_capacity = 100, int max_depth = 10>
typedef T nest::Ntree< D, T, max_capacity, max_depth >::mapped_type

◆ reference

template<int D, class T, int max_capacity = 100, int max_depth = 10>
typedef value_type& nest::Ntree< D, T, max_capacity, max_depth >::reference

◆ value_type

template<int D, class T, int max_capacity = 100, int max_depth = 10>
typedef std::pair< Position< D >, T > nest::Ntree< D, T, max_capacity, max_depth >::value_type

Constructor & Destructor Documentation

◆ Ntree()

template<int D, class T, int max_capacity, int max_depth>
nest::Ntree< D, T, max_capacity, max_depth >::Ntree ( const Position< D > & lower_left,
const Position< D > & extent,
std::bitset< D > periodic = 0,
Ntree< D, T, max_capacity, max_depth > * parent = 0,
int subquad = 0 )

Create a Ntree that covers the region defined by the two input positions.

Parameters
lower_leftLower left corner of ntree.
extentSize (width,height) of ntree.

References extent_, leaf_, lower_left_, my_depth_, my_subquad_, Ntree(), parent_, and periodic_.

Referenced by nest::Ntree< D, T, max_capacity, max_depth >::iterator::iterator(), nest::Ntree< D, T, max_capacity, max_depth >::iterator::iterator(), nest::Ntree< D, T, max_capacity, max_depth >::masked_iterator::masked_iterator(), Ntree(), and split_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~Ntree()

template<int D, class T, int max_capacity, int max_depth>
nest::Ntree< D, T, max_capacity, max_depth >::~Ntree ( )

Delete Ntree recursively.

References children_, leaf_, and N.

Member Function Documentation

◆ append_nodes_() [1/2]

template<int D, class T, int max_capacity = 100, int max_depth = 10>
void nest::Ntree< D, T, max_capacity, max_depth >::append_nodes_ ( std::vector< value_type > & )
protected

Append this ntree's nodes to the vector.

Referenced by get_nodes(), and get_nodes().

Here is the caller graph for this function:

◆ append_nodes_() [2/2]

template<int D, class T, int max_capacity = 100, int max_depth = 10>
void nest::Ntree< D, T, max_capacity, max_depth >::append_nodes_ ( std::vector< value_type > & ,
const Mask< D > & ,
const Position< D > &  )
protected

Append this ntree's nodes inside the mask to the vector.

◆ begin()

template<int D, class T, int max_capacity = 100, int max_depth = 10>
iterator nest::Ntree< D, T, max_capacity, max_depth >::begin ( )
inline

This function returns a node iterator which will traverse the subtree below this Ntree.

Returns
iterator for nodes in quadtree.

References iterator.

Here is the call graph for this function:

◆ end()

template<int D, class T, int max_capacity = 100, int max_depth = 10>
iterator nest::Ntree< D, T, max_capacity, max_depth >::end ( )
inline

References iterator.

Here is the call graph for this function:

◆ get_nodes() [1/2]

template<int D, class T, int max_capacity, int max_depth>
std::vector< std::pair< Position< D >, T > > nest::Ntree< D, T, max_capacity, max_depth >::get_nodes ( )
Returns
member nodes in ntree and their position.

References append_nodes_().

Here is the call graph for this function:

◆ get_nodes() [2/2]

template<int D, class T, int max_capacity, int max_depth>
std::vector< std::pair< Position< D >, T > > nest::Ntree< D, T, max_capacity, max_depth >::get_nodes ( const Mask< D > & mask,
const Position< D > & anchor )

Applies a Mask to this ntree.

Parameters
maskmask to apply.
anchorposition to center mask in.
Returns
member nodes in ntree inside mask.

References append_nodes_().

Here is the call graph for this function:

◆ insert() [1/3]

template<int D, class T, int max_capacity = 100, int max_depth = 10>
iterator nest::Ntree< D, T, max_capacity, max_depth >::insert ( const value_type & val)

std::multimap like insert method

◆ insert() [2/3]

template<int D, class T, int max_capacity = 100, int max_depth = 10>
iterator nest::Ntree< D, T, max_capacity, max_depth >::insert ( iterator ,
const value_type & val )

STL container compatible insert method (the first argument is ignored).

◆ insert() [3/3]

template<int D, class T, int max_capacity, int max_depth>
Ntree< D, T, max_capacity, max_depth >::iterator nest::Ntree< D, T, max_capacity, max_depth >::insert ( Position< D > pos,
const T & node )

Traverse quadtree structure from current ntree.

Inserts node in correct leaf in quadtree.

Returns
iterator pointing to inserted node.

References children_, extent_, iterator, leaf_, lower_left_, my_depth_, nodes_, periodic_, split_(), and subquad_().

Referenced by push_back().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_leaf()

template<int D, class T, int max_capacity, int max_depth>
bool nest::Ntree< D, T, max_capacity, max_depth >::is_leaf ( ) const
Returns
true if ntree is a leaf.

References leaf_.

◆ masked_begin()

template<int D, class T, int max_capacity = 100, int max_depth = 10>
masked_iterator nest::Ntree< D, T, max_capacity, max_depth >::masked_begin ( const Mask< D > & mask,
const Position< D > & anchor )
inline

This function returns a masked node iterator which will traverse the subtree below this Ntree, skipping nodes outside the mask.

Returns
iterator for nodes in quadtree.

References masked_iterator.

Here is the call graph for this function:

◆ masked_end()

template<int D, class T, int max_capacity = 100, int max_depth = 10>
masked_iterator nest::Ntree< D, T, max_capacity, max_depth >::masked_end ( )
inline

References masked_iterator.

Here is the call graph for this function:

◆ push_back()

template<int D, class T, int max_capacity, int max_depth>
void nest::Ntree< D, T, max_capacity, max_depth >::push_back ( const value_type & val)

STL container compatible push_back method.

References insert().

Here is the call graph for this function:

◆ split_()

template<int D, class T, int max_capacity, int max_depth>
void nest::Ntree< D, T, max_capacity, max_depth >::split_ ( )
protected

Change a leaf ntree to a regular ntree with four children regions.

References children_, extent_, leaf_, lower_left_, N, nodes_, Ntree(), and subquad_().

Referenced by insert().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ subquad_()

template<int D, class T, int max_capacity, int max_depth>
int nest::Ntree< D, T, max_capacity, max_depth >::subquad_ ( const Position< D > & pos)
protected
Returns
the subquad number for this position

References extent_, and lower_left_.

Referenced by insert(), and split_().

Here is the caller graph for this function:

◆ iterator

template<int D, class T, int max_capacity = 100, int max_depth = 10>
friend class iterator
friend

Referenced by begin(), end(), and insert().

◆ masked_iterator

template<int D, class T, int max_capacity = 100, int max_depth = 10>
friend class masked_iterator
friend

Referenced by masked_begin(), and masked_end().

Member Data Documentation

◆ children_

template<int D, class T, int max_capacity = 100, int max_depth = 10>
Ntree* nest::Ntree< D, T, max_capacity, max_depth >::children_[N]
protected

Referenced by insert(), split_(), and ~Ntree().

◆ extent_

template<int D, class T, int max_capacity = 100, int max_depth = 10>
Position< D > nest::Ntree< D, T, max_capacity, max_depth >::extent_
protected

Referenced by insert(), Ntree(), split_(), and subquad_().

◆ leaf_

template<int D, class T, int max_capacity = 100, int max_depth = 10>
bool nest::Ntree< D, T, max_capacity, max_depth >::leaf_
protected

Referenced by insert(), is_leaf(), Ntree(), split_(), and ~Ntree().

◆ lower_left_

template<int D, class T, int max_capacity = 100, int max_depth = 10>
Position< D > nest::Ntree< D, T, max_capacity, max_depth >::lower_left_
protected

Referenced by insert(), Ntree(), split_(), and subquad_().

◆ my_depth_

template<int D, class T, int max_capacity = 100, int max_depth = 10>
int nest::Ntree< D, T, max_capacity, max_depth >::my_depth_
protected

This Ntree's depth in the tree.

Referenced by insert(), and Ntree().

◆ my_subquad_

template<int D, class T, int max_capacity = 100, int max_depth = 10>
int nest::Ntree< D, T, max_capacity, max_depth >::my_subquad_
protected

This Ntree's subquad number within parent.

Referenced by Ntree().

◆ N

template<int D, class T, int max_capacity = 100, int max_depth = 10>
const int nest::Ntree< D, T, max_capacity, max_depth >::N = 1 << D
static

◆ nodes_

template<int D, class T, int max_capacity = 100, int max_depth = 10>
std::vector< value_type > nest::Ntree< D, T, max_capacity, max_depth >::nodes_
protected

◆ parent_

template<int D, class T, int max_capacity = 100, int max_depth = 10>
Ntree* nest::Ntree< D, T, max_capacity, max_depth >::parent_
protected

Referenced by Ntree().

◆ periodic_

template<int D, class T, int max_capacity = 100, int max_depth = 10>
std::bitset< D > nest::Ntree< D, T, max_capacity, max_depth >::periodic_
protected

periodic b.c.

Referenced by insert(), and Ntree().


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