Occurrences Class Reference

Count subtree occurences Count the number of occurences of each subtree of a root tree. More...

#include <occurrences.hh>

Collaboration diagram for Occurrences:
[legend]

List of all members.

Public Member Functions

 Occurrences (Tree root)
 Count the number of occurrences of each subtree of root.
int getCount (Tree t)
 Get the number of occurrences of t.

Private Member Functions

Tree specificKey (Tree root)
 Creates a specific property key for occurrences count in root.
void countOccurrences (Tree t)
 Increment the occurrences count of t and its subtrees.
void setCount (Tree t, int c)
 Set the number of occurrences of t.

Private Attributes

Tree fKey

Detailed Description

Count subtree occurences Count the number of occurences of each subtree of a root tree.

Definition at line 32 of file occurrences.hh.


Constructor & Destructor Documentation

Occurrences::Occurrences ( Tree  root  ) 

Count the number of occurrences of each subtree of root.

Definition at line 38 of file occurrences.cpp.

References countOccurrences(), fKey, setCount(), and specificKey().

00039 {
00040     fKey = specificKey(root);
00041     countOccurrences(root);
00042     setCount(root,0);   // root as no occurences in itself
00043 }   

Here is the call graph for this function:


Member Function Documentation

void Occurrences::countOccurrences ( Tree  t  )  [private]

Increment the occurrences count of t and its subtrees.

Definition at line 78 of file occurrences.cpp.

References CTree::arity(), CTree::branch(), getCount(), and setCount().

Referenced by Occurrences().

00079 {   
00080     setCount(t, getCount(t)+1); // increment t occurrences count
00081     for (int i=0; i<t->arity(); i++) {
00082         countOccurrences(t->branch(i));
00083     }
00084 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Occurrences::getCount ( Tree  t  ) 

Get the number of occurrences of t.

Definition at line 48 of file occurrences.cpp.

References fKey, Node::getInt(), getProperty(), and CTree::node().

Referenced by countOccurrences().

00049 {
00050     Tree c;
00051     return (getProperty(t, fKey, c)) ? c->node().getInt() : 0;
00052 }   

Here is the call graph for this function:

Here is the caller graph for this function:

void Occurrences::setCount ( Tree  t,
int  c 
) [private]

Set the number of occurrences of t.

Definition at line 57 of file occurrences.cpp.

References fKey, setProperty(), and tree().

Referenced by countOccurrences(), and Occurrences().

00058 {
00059     setProperty(t, fKey, tree(c));
00060 }   

Here is the call graph for this function:

Here is the caller graph for this function:

Tree Occurrences::specificKey ( Tree  root  )  [private]

Creates a specific property key for occurrences count in root.

Definition at line 67 of file occurrences.cpp.

References tree(), and unique().

Referenced by Occurrences().

00068 {
00069     char    keyname[256];
00070     snprintf(keyname, 256, "OCCURRENCES COUNT IN %p : ", (CTree*)root);
00071 
00072     return tree(unique(keyname));   
00073 }   

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 34 of file occurrences.hh.

Referenced by getCount(), Occurrences(), and setCount().


The documentation for this class was generated from the following files:
Generated on Thu Jul 15 16:15:59 2010 for FAUST compiler by  doxygen 1.6.3