home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
VSCPPv8.zip
/
VACPP
/
IBMCPP
/
samples
/
IOC
/
INTKYSET
/
INTKYSET.CPP
< prev
next >
Wrap
Text File
|
1995-03-15
|
2KB
|
57 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.
*************************************************************************/
/*-------------------------------------------------------------*\
| intkyset.CPP - 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:" << endl;
TestKeySet::Cursor cursor (t);
// forCursor(c)
// expands to
// for ((c).setToFirst (); (c).isValid (); (c).setToNext ())
forCursor (cursor)
sout << " " << cursor.element () << endl;
return sout << endl;
}
main()
{
TestKeySet t;
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;
return 0;
}