home *** CD-ROM | disk | FTP | other *** search
- #include <LEDA/sortseq.h>
-
- declare2(sortseq,string,int);
-
- void print(sortseq(string,int) S)
- { seq_item it;
- forall_seq_items(it,S) cout << S.key(it) << "\n";
- newline;
- S.clear();
- }
-
-
- main()
- {
- sortseq(string,int) S,S1,S2;
-
- string f_name = read_string("file name: ");
-
- file_istream input(f_name);
-
- string s;
-
- while (input >> s) S.insert(s,0);
-
- cout << S.size() << " strings.\n\n";
-
-
- print(S);
-
- string s1,s2;
-
- do { s1 = read_string("s1 = ");
-
- /*
- s2 = read_string("s2 = ");
-
- if (s1 > s2)
- { cerr << "illegal input: s1 > s2.\n";
- continue;
- }
- */
-
- seq_item it1 = S.locate(s1);
-
- cout << "SPLIT at " << S.key(it1) << "\n";
- newline;
-
- /*
- seq_item it2 = S.locate(s2);
-
- while (it1!=it2)
- { cout << S.key(it1) << "\n";
- it1 = S.succ(it1);
- }
- */
-
- S.split(it1,S1,S2); //now S is mepty
-
- print(S1);
-
- print(S2);
-
- S1.conc(S2); //now S2 is empty
-
- S.conc(S1); //now S1 is empty
-
-
- } while (s1 != "");
-
- }
-