#include <LEDA/_d_array.h> #include <LEDA/impl/skiplist.h> main() { _d_array<string, int, skiplist> N(0); string s; while (cin >> s) N[s]++; forall_defined(s,N) cout << s << " " << N[s] << endl; }
Any type _XYZ<T1, ... ,Tk,xyz_impl>is derived from the corresponding ``normal" parameterized type XYZ<T1, ...,Tk>, i.e., an instance of type _XYZ<T1, ...,Tk,xyz_impl>can be passed as argument to functions with a formal parameter of type XYZ<T1, ...,Tk>&. This provides a mechanism for choosing implementations of data types in pre-compiled algorithms. See ``prog/graph/dijkstra.c" for an example.
LEDA offers several implementations for each of the data types. For instance, skip lists, randomized search trees, and red-black trees for dictionary arrays. Users can also provide their own implementation. A data structure xyz_impl can be used as actual implementation parameter for a data type _XYZ if it provides a certain set of operations and uses certain virtual functions for type dependent operations (e.g. compare, initialize, copy, ...). Chapter Implementations lists all data structures contained in the current version and gives the exact requirements for implementations of dictionaries, priority_queues, sorted sequences and dictionary arrays. A detailed description of the mechanism for parameterized data types and implementation parameters used in LEDA will be published soon.