next up previous contents index
Next: The LEDA Manual Page Up: Basics Previous: Basics

Getting Started

 Please use your favourite text editor to create a file prog.c with the following program:

#include <LEDA/d_array.h>

using namespace leda;
using namespace std;

int main()
{
  d_array<string,int> N(0);
  string s;
  while (cin >> s) N[s]++;
  forall_defined (s,N) 
    cout << s << " " << N[s] << endl;

  return 0;
}

If you followed the installation guidelines (see Chapter UnixObjectCodePackage and Chapter WinObjectCodePackage ff.), you can compile and link it with LEDA's basic library libL(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.



© Copyright 1995-2002, Algorithmic Solutions Software GmbH. All rights reserved.
2002-10-16