home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
SAMPLES
/
ICLCC
/
INTKYSET.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-05-07
|
3KB
|
69 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. */
/* */
/******************************************************************************/
/*-------------------------------------------------------------*\
| intkyset.C - Integer Key Set for demonstration of using |
| a KeySet. |
\*-------------------------------------------------------------*/
#include <iostream.h>
#include <iglobals.h>
#include <icursor.h>
#include <ikeyset.h>
// Class DemoElement:
#include "demoelem.h"
typedef IKeySet < DemoElement,int > TestKeySet;
ostream & operator << ( ostream & sout, TestKeySet const & t){
sout << t.numberOfElements() << " elements are in the set:\n";
TestKeySet::Cursor cursor (t);
// forCursor(c)
// expands to
// for ((c).setToFirst (); (c).isValid (); (c).setToNext ())
forCursor (cursor)
sout << " " << cursor.element() << "\n";
return sout << "\n";
}
main(){
TestKeySet t;
try {
t.add(DemoElement(1,1));
t.add(DemoElement(2,4711));
t.add(DemoElement(3,1));
t.add(DemoElement(4,443));
cout << t;
t.removeElementWithKey (3);
cout << t;
}
catch (IException & exception) {
cout << exception.name() << " : " << exception.text();
}
return 0;
}