FAUST compiler  0.9.9.6b8
Public Member Functions | Private Member Functions | Private Attributes
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:
Collaboration graph
[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

Count the number of occurrences of each subtree of root.

Definition at line 38 of file occurrences.cpp.

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

{
    fKey = specificKey(root);
    countOccurrences(root);
    setCount(root,0);   // root as no occurences in itself
}   

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().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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().

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

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().

{
    setProperty(t, fKey, tree(c));
}   

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().

{
    char    keyname[256];
    snprintf(keyname, 256, "OCCURRENCES COUNT IN %p : ", (CTree*)root);

    return tree(unique(keyname));   
}   

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: