home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / basedemo / sequence / gseqtest.cxx next >
C/C++ Source or Header  |  1994-10-14  |  673b  |  32 lines

  1.  
  2.  
  3. // A simple program to demonstrate the GenericSequence class.
  4.  
  5. #include "base/genseq.h"
  6. #include <string.h>
  7. #include <iostream.h>
  8.  
  9. class MyComparator: public CL_AbstractComparator {
  10.  
  11. public:
  12.     short operator() (CL_VoidPtr p1, CL_VoidPtr p2) const
  13.         { return strcmp ((const char*) p1, (const char*) p2);};
  14. };
  15.  
  16.  
  17. main ()
  18. {
  19.     MyComparator my_comp;
  20.     CL_GenericSequence my_seq (0, &my_comp);
  21.     my_seq.Add ("Line 1");
  22.     my_seq.Add ("Some string");
  23.     my_seq.Add ("44");
  24.     my_seq.Add ("Have a nice day");
  25.  
  26.     my_seq.Sort ();
  27.     register long i, n = my_seq.Size();
  28.     for (i = 0; i < n; i++)
  29.         cout << (const char*) my_seq[i] << endl;
  30.     return 0;
  31. }
  32.