home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / TUTORIAL / ICLCC / TUTOR6 / EXAMPLE6.C next >
C/C++ Source or Header  |  1993-05-07  |  3KB  |  85 lines

  1. /******************************************************************************/
  2. /*                                                                            */
  3. /* COPYRIGHT:                                                                 */
  4. /* ----------                                                                 */
  5. /* Copyright (C) International Business Machines Corp., 1991,1992.            */
  6. /*                                                                            */
  7. /* DISCLAIMER OF WARRANTIES:                                                  */
  8. /* -------------------------                                                  */
  9. /* The following [enclosed] code is sample code created by IBM                */
  10. /* Corporation.  This sample code is not part of any standard IBM product     */
  11. /* and is provided to you solely for the purpose of assisting you in the      */
  12. /* development of your applications.  The code is provided "AS IS",           */
  13. /* without warranty of any kind.  IBM shall not be liable for any damages     */
  14. /* arising out of your use of the sample code, even if they have been         */
  15. /* advised of the possibility of such damages.                                */
  16. /*                                                                            */
  17. /******************************************************************************/
  18. #include <tstring.h>
  19. #include <iglobals.h>
  20. #include <person.h>
  21.  
  22. #include <iset.h>
  23. #include <irset.h>
  24. typedef ISet <Person>  PeopleSet;
  25. typedef IRSet <Person, PeopleSet>  PolyPeopleSet;
  26.  
  27. #include <ieqseq.h>
  28. #include <irseq.h>
  29. typedef IEqualitySequence <Person>  People;
  30. typedef IRSequence <Person, People> PolyPeopleSeq;
  31.  
  32. #include <itbseq.h>
  33. typedef ITabularSequence <Person>  PeopleTab;
  34. typedef IRSequence <Person, PeopleTab> PolyPeopleTab;
  35.  
  36.  
  37. class MyPrint: public IConstantIterator <Person> {
  38.     applyTo(Person const & person){
  39.       cout << "Name " << person.getName() << "\n" ;
  40.       return  True;
  41.   }
  42. };
  43.  
  44. void printCollection( ............ <......> const & collection){
  45.    ....... myPrint;
  46.    collection..............(myPrint);
  47. }
  48.  
  49. int main () {
  50.         People people;
  51.  
  52.         people.add("J. Uhl");
  53.         people.add("K. Liegert");
  54.         people.add("M. Blum");
  55.         people.add("T. Wappler");
  56.         people.add("F. Seliger");
  57.         people.add("H. Wingert");
  58.         people.add("C. Ludwig");
  59.  
  60.  
  61.         people.add("Your Name");
  62.         people.remove("K. Liegert");
  63.  
  64.      PeopleSet peopleSet;
  65.  
  66.         peopleSet.add("Joe Cool");
  67.         peopleSet.add("Mr. Nobody");
  68.         peopleSet.remove("T. Wappler");
  69.         peopleSet.add("Mrs. Somebody");
  70.  
  71.  
  72.         printCollection(PolyPeopleSet(peopleSet));
  73.         printCollection(PolyPeopleSeq(people));
  74.  
  75.  
  76.         ......... peopleTab;
  77.         PolyPeopleTab polyPeopleTab(peopleTab);
  78.         polyPeopleTab...........(.............(......));
  79.         polyPeopleTab.add("Your Name again");
  80.         printCollection(polyPeopleTab);
  81.         peopleTab.add(" yet another Joe Cool");
  82.  
  83.         return 0;
  84. }
  85.