Please use your favourite text editor to create a file prog.c with the following program:
#include <LEDA/d_array.h> main() { d_array<string,int> N(0); string s; while (cin >> s) N[s]++; forall_defined (s,N) cout << s << " " << N[s] << endl; }
If you followed the installation guidelines (see chapter Installation), you can compile and link it with LEDA's basic library libL.a (cf. section Libraries). For example on a Unix machine where g ++ is installed you can type
g++ -o prog prog.c -lL -lm
When executed it reads a sequence of strings from the standard input and then prints the number of occurrences of each string on the standard output. More examples of LEDA programs can be found throughout this manual.
The program above uses the parameterized data type dictionary array ( d_array<I,E>) from the library. This is expressed by the include statement (cf. section Header Files for more details). The specification of the data type d_array can be found in section Dictionary Arrays. We use it also as a running example to discuss the principles underlying LEDA in the following sections.