Discussion:
use of int &running
(too old to reply)
Zikun Xu
2011-06-14 07:41:36 UTC
Permalink
void apply( TrieNode &node, int &running, void (*action)( TrieNode
&node, int &running ) );
The reference parameter running provides an integer variable for
passing information between calls to action.
I do not understand what kind of information it passes.
kun qian
2011-06-14 17:52:18 UTC
Permalink
Post by Zikun Xu
void apply( TrieNode &node, int &running, void (*action)( TrieNode
&node, int &running ) );
The reference parameter running provides an integer variable for
passing information between calls to action.
I do not understand what kind of information it passes.
You are changing a variable. For example:

void swap (int &x, int &y) {
int temp = x;
int x = y;
int y = temp;
}

int main() {
int x = 0;
int y = 1;
swap(x, y); // x = 1, y = 0
}

So when you call "apply" and pass a variable to the parameter
"running" it could be changed and used depending on how you manipulate
running with the action function.
Sammie Zhang
2011-06-14 18:52:10 UTC
Permalink
Post by kun qian
Post by Zikun Xu
void apply( TrieNode &node, int &running, void (*action)( TrieNode
&node, int &running ) );
The reference parameter running provides an integer variable for
passing information between calls to action.
I do not understand what kind of information it passes.
void swap (int &x, int &y) {
   int temp = x;
   int x = y;
   int y = temp;
}
int main() {
 int x = 0;
 int y = 1;
  swap(x, y); // x = 1, y = 0
}
So when you call "apply" and pass a variable to the parameter
"running" it could be changed and used depending on how you manipulate
running with the action function.
I am not sure that I understand what is the" void (*action)( TrieNode
&node, int &running )" functionality here?
and how to understand this command line?
kun qian
2011-06-14 19:46:59 UTC
Permalink
Post by Sammie Zhang
Post by kun qian
Post by Zikun Xu
void apply( TrieNode &node, int &running, void (*action)( TrieNode
&node, int &running ) );
The reference parameter running provides an integer variable for
passing information between calls to action.
I do not understand what kind of information it passes.
void swap (int &x, int &y) {
   int temp = x;
   int x = y;
   int y = temp;
}
int main() {
 int x = 0;
 int y = 1;
  swap(x, y); // x = 1, y = 0
}
So when you call "apply" and pass a variable to the parameter
"running" it could be changed and used depending on how you manipulate
running with the action function.
I am not sure that I understand what is the" void (*action)( TrieNode
&node, int &running )" functionality here?
and how to understand this command line?
The action function is a function you use to collected information. If
you want to know how C++ handles function pointer as parameter just
google it.

Loading...