home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / SAMPLES / ICLCC / TRMAPOPS.H < prev    next >
C/C++ Source or Header  |  1993-05-07  |  3KB  |  65 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. /*-------------------------------------------------------------*\
  19. |  trmapops.h  -  Translation Map Operations                    |
  20. |                 This is the base class for the element        |
  21. |                 operations for our Translation Map example.   |
  22. \*-------------------------------------------------------------*/
  23.  
  24.        /* Get the standard operation classes.                  */
  25. #include <istdops.h>
  26.  
  27. template <class Element, class Key>
  28. class KeyOpsTransMap : public IStdMemOps,
  29.                        public IStdAsOps< Element >,
  30.                        public IStdEqOps< Element >
  31. {
  32.   public:
  33.      class KeyOps
  34.      {
  35.        public:
  36.                             /* Equality of keys                */
  37.         Boolean equal (Key const& k1, Key const& k2)
  38.            { return k1 == k2; };
  39.  
  40.                             /* Hash function for key           */
  41.         unsigned long hash (Key const& k1, unsigned long n)
  42.            { return k1 % n; };
  43.  
  44.      }  keyOps;
  45. };
  46.  
  47.        /* Operations Class for the EBCDIC-ASCII mapping:       */
  48. template <class Element, class Key>
  49. class KeyOpsTransE2A : public KeyOpsTransMap <Element, Key>
  50. {
  51.   public:                   /* Key Access                      */
  52.      Key const& key (Element const& te)
  53.         { return te.ebc_code; }
  54. };
  55.  
  56.  
  57.        /* Operations Class for the ASCII-EBCDIC mapping:       */
  58. template <class Element, class Key>
  59. class KeyOpsTransA2E : public KeyOpsTransMap <Element, Key>
  60. {
  61.   public:                   /* Key Access                      */
  62.      Key const& key (Element const& te)
  63.         { return te.asc_code; }
  64. };
  65.