|
FAUST compiler
0.9.9.6b8
|
Count subtree occurences Count the number of occurences of each subtree of a root tree. More...
#include <occurrences.hh>

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 |
Count subtree occurences Count the number of occurences of each subtree of a root tree.
Definition at line 32 of file occurrences.hh.
| 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().
{
fKey = specificKey(root);
countOccurrences(root);
setCount(root,0); // root as no occurences in itself
}

| 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));
}
}


| 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().
{
Tree c;
return (getProperty(t, fKey, c)) ? c->node().getInt() : 0;
}


| 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));
}


| 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));
}


Tree Occurrences::fKey [private] |
Definition at line 34 of file occurrences.hh.
Referenced by getCount(), Occurrences(), and setCount().
1.8.0