Ice Sheet System Model  4.18
Code documentation
Public Member Functions | Private Attributes
Covertree::CoverTreeNode Class Reference

Public Member Functions

 CoverTreeNode (const Observation &o)
 
void addChild (int level, CoverTreeNode *p)
 
void addObservation (const Observation &o)
 
double distance (const CoverTreeNode &p) const
 
bool isSingle () const
 
bool hasObservation (const Observation &o) const
 
std::vector< CoverTreeNode * > getChildren (int level) const
 
const ObservationgetObservation () const
 
const std::vector< Observation > & getObservations ()
 
void removeChild (int level, CoverTreeNode *p)
 
void removeObservation (const Observation &o)
 
std::vector< CoverTreeNode * > getAllChildren () const
 

Private Attributes

std::map< int, std::vector< CoverTreeNode * > > _childMap
 
std::vector< Observation_observations
 

Detailed Description

Definition at line 12 of file Covertree.h.

Constructor & Destructor Documentation

◆ CoverTreeNode()

Covertree::CoverTreeNode::CoverTreeNode ( const Observation o)

Definition at line 342 of file Covertree.cpp.

342  {/*{{{*/
343  _observations.push_back(p);
344 }/*}}}*/

Member Function Documentation

◆ addChild()

void Covertree::CoverTreeNode::addChild ( int  level,
CoverTreeNode p 
)

Returns the children of the node at level i. Note that this means the children exist in cover set i-1, not level i.

Does not include the node itself, though technically every node has itself as a child in a cover tree.

Definition at line 335 of file Covertree.cpp.

335  {/*{{{*/
336  _childMap[level].push_back(p);
337 }/*}}}*/

◆ addObservation()

void Covertree::CoverTreeNode::addObservation ( const Observation o)

Definition at line 338 of file Covertree.cpp.

338  {/*{{{*/
339  if(find(_observations.begin(), _observations.end(), p) == _observations.end())
340  _observations.push_back(p);
341 }/*}}}*/

◆ distance()

double Covertree::CoverTreeNode::distance ( const CoverTreeNode p) const

Definition at line 345 of file Covertree.cpp.

345  {/*{{{*/
346  return _observations[0].distance(p.getObservation());
347 }/*}}}*/

◆ isSingle()

bool Covertree::CoverTreeNode::isSingle ( ) const

Definition at line 373 of file Covertree.cpp.

373  {/*{{{*/
374  return _observations.size() == 1;
375 }/*}}}*/

◆ hasObservation()

bool Covertree::CoverTreeNode::hasObservation ( const Observation o) const

Definition at line 370 of file Covertree.cpp.

370  {/*{{{*/
371  return find(_observations.begin(), _observations.end(), p) != _observations.end();
372 }/*}}}*/

◆ getChildren()

std::vector< Covertree::CoverTreeNode * > Covertree::CoverTreeNode::getChildren ( int  level) const

Definition at line 356 of file Covertree.cpp.

356  {/*{{{*/
357  std::map<int,std::vector<CoverTreeNode*> >::const_iterator
358  it = _childMap.find(level);
359  if(it!=_childMap.end()) {
360  return it->second;
361  }
362  return std::vector<CoverTreeNode*>();
363 }/*}}}*/

◆ getObservation()

const Observation & Covertree::CoverTreeNode::getObservation ( ) const

Definition at line 364 of file Covertree.cpp.

364  {/*{{{*/
365  return _observations[0];
366 }/*}}}*/

◆ getObservations()

const std::vector<Observation>& Covertree::CoverTreeNode::getObservations ( )
inline

Definition at line 34 of file Covertree.h.

34 { return _observations; }

◆ removeChild()

void Covertree::CoverTreeNode::removeChild ( int  level,
CoverTreeNode p 
)

Definition at line 415 of file Covertree.cpp.

415  {/*{{{*/
416  std::vector<CoverTreeNode*>& v = _childMap[level];
417  for(unsigned int i=0;i<v.size();i++) {
418  if(v[i]==p) {
419  v[i]=v.back();
420  v.pop_back();
421  break;
422  }
423  }
424 }/*}}}*/

◆ removeObservation()

void Covertree::CoverTreeNode::removeObservation ( const Observation o)

Definition at line 425 of file Covertree.cpp.

425  {/*{{{*/
426  std::vector<Observation>::iterator it =
427  find(_observations.begin(), _observations.end(), p);
428  if(it != _observations.end())
429  _observations.erase(it);
430 }/*}}}*/

◆ getAllChildren()

std::vector< Covertree::CoverTreeNode * > Covertree::CoverTreeNode::getAllChildren ( ) const

Return every child of the node from any level. This is handy for the destructor.

Definition at line 348 of file Covertree.cpp.

348  {/*{{{*/
349  std::vector<CoverTreeNode*> children;
350  std::map<int,std::vector<CoverTreeNode*> >::const_iterator it;
351  for(it=_childMap.begin();it!=_childMap.end();++it) {
352  children.insert(children.end(), it->second.begin(), it->second.end());
353  }
354  return children;
355 }/*}}}*/

Field Documentation

◆ _childMap

std::map<int,std::vector<CoverTreeNode*> > Covertree::CoverTreeNode::_childMap
private

Definition at line 15 of file Covertree.h.

◆ _observations

std::vector<Observation> Covertree::CoverTreeNode::_observations
private

Definition at line 17 of file Covertree.h.


The documentation for this class was generated from the following files:
Covertree::CoverTreeNode::_observations
std::vector< Observation > _observations
Definition: Covertree.h:17
Covertree::CoverTreeNode::_childMap
std::map< int, std::vector< CoverTreeNode * > > _childMap
Definition: Covertree.h:15