\manpage {\_d\_array} {I,E,impl} {Dictionary Arrays with Implementation Parameter} 
 
\definition
An instance of type \name\ is a dictionary array implemented by data type 
$impl$. $impl$ must be one of the dictionary implementations listed in
section \ref{Implementations Dictionaries} or a user defined data structure
fulfilling the specification given in section \ref{User Implementations
Dictionaries}. Note that depending on the actual implementation $impl$
the index type $I$ must either be linearly ordered or hashed.

 

{\bf Example}\\
Using a dictionary array implemented by hashing with chaining  ($ch\_hash$)
to count the number of occurences of the elements in a sequence of strings.
\begingroup
\ttbig
{\obeyspaces\gdef {\ }}
\ttverbatim

#include <LEDA/_d_array.h>
#include <LEDA/impl/ch_hash.h>

//we first have to define a hash function for strings

int Hash(const string& x) { return (x.length() > 0) ? x[0] : 0; }

main()
{ 
  _d_array<string,int,ch_hash> N(0);
  string s;

  while (cin >> s) N[s]++;

  forall_defined(s,N) cout << s << "  " << N[s] << endl;

}
\endgroup


 
