home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
VSCPPv8.zip
/
VACPP
/
IBMCPP
/
samples
/
IOC
/
WORDBAG
/
TOYWORD.H
< prev
next >
Wrap
Text File
|
1995-03-15
|
2KB
|
61 lines
/*************************************************************************
IBM C/C++ Tools Version 3.00 - Collection Class Library
(C) Copyright IBM Corporation 1992 ,1995, Licensed Program-Property of
IBM. All Rights Reserved. US Government Users Restricted Rights - Use,
duplication or disclosure restricted by GSA ADP Schedule Contract with
IBM Corp.
*************************************************************************/
/*-------------------------------------------------------------*\
| toyword.h - Class Word for use with coding examples. |
\*-------------------------------------------------------------*/
#if defined (_SUN)
#include <istring.h>
#else
#include <istring.hpp>
#endif
class Word {
IString ivWord;
unsigned ivKey;
public:
//Constructor to be used for sample: wordbag.c
Word (IString word, unsigned theLength) : ivWord(word),
ivKey(theLength)
{}
//Constructor to be used for sample: wordseq.c
Word (IString word) : ivWord(word)
{}
IBoolean operator> (Word const& w1)
{
return this->ivWord > w1.ivWord;
}
unsigned setKey()
{
this->ivKey = this->ivWord.length();
return this->ivKey;
}
IString const& getWord() const
{
return this->ivWord;
}
unsigned const& getKey() const
{
return this->ivKey;
}
};
// Key access. The length of the word is the key.
inline unsigned const& key (Word const &aWord)
{ return aWord.getKey();
}