home *** CD-ROM | disk | FTP | other *** search
- #include <LEDA/hash.h>
-
- declare2(hash,string,int)
-
- int hash_fun(string& x) { return int(x[0]); }
-
- main()
-
- {
- hash(string,int) D(hash_fun);
-
- hash_item it;
- string r;
-
- while (cin >> r)
- { it = D.lookup(r);
- if (it==nil) D.insert(r,1);
- else D.change_inf(it,D.info(it)+1);
- }
-
- forall_hash_items(it,D) cout << D.info(it) << " " << D.key(it) << "\n";
-
- }
-
-