Lit::Node Class Reference

#include <Node.h>

List of all members.

Public Member Functions

 Node (const Node *parent, const Event &event, int mod)
 ~Node ()
const NodeAdd (const Event &event, unsigned int depth)
void SetNodeL (Node *node)
void SetNodeR (Node *node)
const EventGetEvent () const
const NodeGetNodeL () const
const NodeGetNodeR () const
const NodeGetNodeP () const
double GetWeight () const
short GetType () const
VarType GetVarDis () const
VarType GetVarMin () const
VarType GetVarMax () const
unsigned int GetMod () const
void Print () const
void Print (std::ostream &os, const std::string &offset="") const

Private Member Functions

 Node ()
 Node (const Node &)
const Nodeoperator= (const Node &)

Private Attributes

const NodefNodeP
NodefNodeL
NodefNodeR
const Event fEvent
const VarType fVarDis
VarType fVarMin
VarType fVarMax
const unsigned int fMod

Detailed Description

Definition at line 24 of file Node.h.


Constructor & Destructor Documentation

Lit::Node::Node ( const Node parent,
const Event event,
int  mod 
)

Definition at line 9 of file Node.cxx.

00010    :fNodeP(parent),
00011     fNodeL(0),
00012     fNodeR(0),
00013     fEvent(event),
00014     fVarDis(event.GetVar(mod)),
00015     fVarMin(fVarDis),
00016     fVarMax(fVarDis),
00017     fMod(mod)
00018 {   
00019 }

Lit::Node::~Node (  ) 

Definition at line 22 of file Node.cxx.

References fNodeL, and fNodeR.

00023 {
00024    if(fNodeL) delete fNodeL;
00025    if(fNodeR) delete fNodeR;
00026 }

Lit::Node::Node (  )  [private]

Referenced by Add().

Lit::Node::Node ( const Node  )  [private]

Member Function Documentation

const Lit::Node * Lit::Node::Add ( const Event event,
unsigned int  depth 
)

Definition at line 29 of file Node.cxx.

References fMod, fNodeL, fNodeR, fVarDis, fVarMax, fVarMin, Lit::Event::GetNVar(), max, min, and Node().

00030 {
00031    assert(fMod == depth % event.GetNVar());
00032    
00033    const VarType value = event.GetVar(fMod);
00034 
00035    fVarMin = std::min(fVarMin, value);
00036    fVarMax = std::max(fVarMax, value);
00037 
00038    Node *node = 0;
00039    if(value < fVarDis)
00040    {
00041       if(fNodeL)
00042       {
00043          return fNodeL -> Add(event, depth + 1);
00044       }
00045       else
00046       {
00047          fNodeL = new Node(this, event, (depth + 1) % event.GetNVar());
00048          node = fNodeL;
00049       }
00050    }
00051    else
00052    {
00053       if(fNodeR)
00054       {
00055          return fNodeR -> Add(event, depth + 1);
00056       }
00057       else
00058       {
00059          fNodeR = new Node(this, event, (depth + 1) % event.GetNVar());
00060          node = fNodeR;
00061       }      
00062    }
00063    
00064    return node;
00065 }

const Event & Lit::Node::GetEvent (  )  const [inline]

Definition at line 88 of file Node.h.

References fEvent.

00089    {
00090       return fEvent;
00091    }

unsigned int Lit::Node::GetMod (  )  const [inline]

Definition at line 124 of file Node.h.

References fMod.

00125    {
00126       return fMod;
00127    }

const Node * Lit::Node::GetNodeL (  )  const [inline]

Definition at line 92 of file Node.h.

References fNodeL.

00093    {
00094       return fNodeL;
00095    }

const Node * Lit::Node::GetNodeP (  )  const [inline]

Definition at line 100 of file Node.h.

References fNodeP.

00101    {
00102       return fNodeP;
00103    }

const Node * Lit::Node::GetNodeR (  )  const [inline]

Definition at line 96 of file Node.h.

References fNodeR.

00097    {
00098       return fNodeR;
00099    }

short Lit::Node::GetType (  )  const [inline]

Definition at line 108 of file Node.h.

References fEvent, and Lit::Event::GetType().

Referenced by Anp::FillkNN::Find(), and Anp::FillkNN::PidKer().

00109    {
00110       return fEvent.GetType();
00111    }

VarType Lit::Node::GetVarDis (  )  const [inline]

Definition at line 112 of file Node.h.

References fVarDis.

00113    {
00114       return fVarDis;
00115    }

VarType Lit::Node::GetVarMax (  )  const [inline]

Definition at line 120 of file Node.h.

References fVarMax.

00121    {
00122       return fVarMax;
00123    }

VarType Lit::Node::GetVarMin (  )  const [inline]

Definition at line 116 of file Node.h.

References fVarMin.

00117    {
00118       return fVarMin;
00119    }

double Lit::Node::GetWeight (  )  const [inline]

Definition at line 104 of file Node.h.

References fEvent, and Lit::Event::GetWeight().

Referenced by Anp::FillkNN::Find(), Anp::FillkNN::PidKer(), and Print().

00105    {
00106       return fEvent.GetWeight();
00107    }

const Node& Lit::Node::operator= ( const Node  )  [private]
void Lit::Node::Print ( std::ostream &  os,
const std::string &  offset = "" 
) const

Definition at line 294 of file Node.cxx.

References fEvent, fMod, fNodeL, fNodeR, fVarDis, GetWeight(), and Print().

00295 {
00296    os << offset << "-----------------------------------------------------------" << std::endl;
00297    os << offset << "Node: mod " << fMod 
00298       << " at " << fVarDis 
00299       << " with weight: " << GetWeight() << std::endl
00300       << offset << fEvent;
00301    
00302    if(fNodeL)
00303    {
00304       os << offset << "Has left node " << std::endl;
00305    }
00306    if(fNodeR)
00307    {
00308       os << offset << "Has right node" << std::endl;
00309    }
00310 
00311    if(fNodeL)
00312    {
00313       os << offset << "Print left node " << std::endl;
00314       fNodeL -> Print(os, offset + " ");
00315    }
00316    if(fNodeR)
00317    {
00318       os << offset << "Print right node" << std::endl;
00319       fNodeR -> Print(os, offset + " ");
00320    }
00321    
00322    if(!fNodeL && !fNodeR)
00323    {
00324       os << std::endl;
00325    }
00326 }

void Lit::Node::Print ( void   )  const

Definition at line 288 of file Node.cxx.

Referenced by Lit::operator<<(), and Print().

00289 {
00290    Print(std::cout);
00291 }

void Lit::Node::SetNodeL ( Node node  )  [inline]

Definition at line 80 of file Node.h.

References fNodeL.

00081    {
00082       fNodeL = node;
00083    }

void Lit::Node::SetNodeR ( Node node  )  [inline]

Definition at line 84 of file Node.h.

References fNodeR.

00085    {
00086       fNodeR = node;
00087    }


Member Data Documentation

const Event Lit::Node::fEvent [private]

Definition at line 68 of file Node.h.

Referenced by GetEvent(), GetType(), GetWeight(), and Print().

const unsigned int Lit::Node::fMod [private]

Definition at line 75 of file Node.h.

Referenced by Add(), GetMod(), and Print().

Node* Lit::Node::fNodeL [private]

Definition at line 65 of file Node.h.

Referenced by Add(), GetNodeL(), Print(), SetNodeL(), and ~Node().

const Node* Lit::Node::fNodeP [private]

Definition at line 63 of file Node.h.

Referenced by GetNodeP().

Node* Lit::Node::fNodeR [private]

Definition at line 66 of file Node.h.

Referenced by Add(), GetNodeR(), Print(), SetNodeR(), and ~Node().

const VarType Lit::Node::fVarDis [private]

Definition at line 70 of file Node.h.

Referenced by Add(), GetVarDis(), and Print().

Definition at line 73 of file Node.h.

Referenced by Add(), and GetVarMax().

Definition at line 72 of file Node.h.

Referenced by Add(), and GetVarMin().


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

Generated on 3 Oct 2018 for loon by  doxygen 1.6.1