home *** CD-ROM | disk | FTP | other *** search
- #include <LEDA/list.h>
-
-
- declare(list,string)
-
-
- int cmp_length(string& x, string& y)
- { return x.length() - y.length(); }
-
-
- int F(string& x)
- { return (x.length() > 0) ? int(x[0]) : 0; }
-
-
- main()
- { list(string) L;
- string s;
-
- L.read("List of strings : ");
- newline;
-
- // random permutation
- L.permute();
- L.print("permuted: ");
- newline;
- newline;
-
-
- // sort lexicographically
-
- L.sort(compare); // predefined compare(string&,string&)
- L.print("sorted lexicographically:\n");
- newline;
- newline;
-
-
- // sort by length
-
- L.sort(cmp_length);
- L.print("sorted by length:\n");
- newline;
- newline;
-
-
-
- // bucket_sort by first character
-
- L.bucket_sort(0,255,F);
- L.print("sorted by s[0]:\n");
- newline;
- newline;
-
- }
-