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 >
Wrap
C/C++ Source or Header
|
1993-05-07
|
3KB
|
65 lines
/******************************************************************************/
/* */
/* COPYRIGHT: */
/* ---------- */
/* Copyright (C) International Business Machines Corp., 1991,1992. */
/* */
/* DISCLAIMER OF WARRANTIES: */
/* ------------------------- */
/* The following [enclosed] code is sample code created by IBM */
/* Corporation. This sample code is not part of any standard IBM product */
/* and is provided to you solely for the purpose of assisting you in the */
/* development of your applications. The code is provided "AS IS", */
/* without warranty of any kind. IBM shall not be liable for any damages */
/* arising out of your use of the sample code, even if they have been */
/* advised of the possibility of such damages. */
/* */
/******************************************************************************/
/*-------------------------------------------------------------*\
| trmapops.h - Translation Map Operations |
| This is the base class for the element |
| operations for our Translation Map example. |
\*-------------------------------------------------------------*/
/* Get the standard operation classes. */
#include <istdops.h>
template <class Element, class Key>
class KeyOpsTransMap : public IStdMemOps,
public IStdAsOps< Element >,
public IStdEqOps< Element >
{
public:
class KeyOps
{
public:
/* Equality of keys */
Boolean equal (Key const& k1, Key const& k2)
{ return k1 == k2; };
/* Hash function for key */
unsigned long hash (Key const& k1, unsigned long n)
{ return k1 % n; };
} keyOps;
};
/* Operations Class for the EBCDIC-ASCII mapping: */
template <class Element, class Key>
class KeyOpsTransE2A : public KeyOpsTransMap <Element, Key>
{
public: /* Key Access */
Key const& key (Element const& te)
{ return te.ebc_code; }
};
/* Operations Class for the ASCII-EBCDIC mapping: */
template <class Element, class Key>
class KeyOpsTransA2E : public KeyOpsTransMap <Element, Key>
{
public: /* Key Access */
Key const& key (Element const& te)
{ return te.asc_code; }
};