home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
OPtrSet.hxx
< prev
next >
Wrap
Text File
|
1996-05-31
|
4KB
|
120 lines
/*---------------------------------------------------------------------------
*
* (c) Westmount Technology 1994
*
* File: @(#)OPtrSet.hxx 1.3
* Author: peku
* Description: Ordered set of pointers
*---------------------------------------------------------------------------
SccsId = @(#)OPtrSet.hxx 1.3 11 Oct 1995 Copyright 1994 Westmount Technology */
#ifndef OPTRSET_HXX
#define OPTRSET_HXX
#ifndef CLIST_HXX
#include "CList.hxx"
#endif
#if HAS_TEMPLATES
template<class T>
class OPtrSet : private GenCList {
public:
OPtrSet(unsigned s = DEFAULT_ARRAY_SIZE, int gf = +1): GenCList(s,gf) {}
OPtrSet(const OPtrSet& cpy): GenCList(cpy) {}
OPtrSet& operator= (const OPtrSet& cpy)
{this->GenCList::operator=(cpy); return *this;}
void reset() { GenCList::reset();}
void reset(unsigned s) { GenCList::reset(s);}
#ifndef GNU
void cleanup();
#endif
OPtrSet<T>& append(T *e)
{return (OPtrSet<T>&)GenCList::append(e);}
OPtrSet<T>& append(const OPtrSet<T>& l)
{return (OPtrSet<T>&)GenCList::append(l);}
OPtrSet<T>& insert_at(int i, T *e)
{return (OPtrSet<T>&)GenCList::insert_at(i,e);}
OPtrSet<T>& insert_at(int i, const OPtrSet<T>& l)
{return (OPtrSet<T>&)GenCList::insert_at(i,l);}
OPtrSet<T>& remove_last()
{return (OPtrSet<T>&)GenCList::remove_last();}
OPtrSet<T>& remove_at(int i)
{return (OPtrSet<T>&)GenCList::remove_at(i);}
OPtrSet<T>& remove(int i, int j)
{return (OPtrSet<T>&)GenCList::remove(i,j);}
OPtrSet<T>& remove(T *elem)
{return (OPtrSet<T>&)GenCList::remove(elem);}
unsigned capacity() const {return GenCList::capacity();}
unsigned size() const {return GenCList::size();}
T*& at(int i) const {return (T*&)GenCList::at(i);}
T*& operator[](int i) const {return (T*&)GenCList::operator[](i);}
void operator&= (T *elem) {append(elem);}
void operator&= (const OPtrSet<T>& lst) {append(lst);}
};
#ifndef GNU
template<class T> void
OPtrSet<T>::cleanup()
{
T** last=&at(size());
for (register T** e=&at(0); e<last; e++) delete *e;
reset();
}
#endif
#else
#define OPtrSet(t) name2(t,_OPtrSet)
#define OPtrSetdeclare(t) \
class OPtrSet(t) : private GenCList { \
public: \
OPtrSet(t) (unsigned s = DEFAULT_ARRAY_SIZE, int gf = +1): \
GenCList(s,gf) {} \
OPtrSet(t) (const OPtrSet(t)& cpy): GenCList(cpy) {} \
OPtrSet(t)& operator= (const OPtrSet(t)& cpy) \
{this->GenCList::operator=(cpy); return *this;} \
void reset() { GenCList::reset();} \
void reset(unsigned s) { GenCList::reset(s);} \
#ifndef GNU
void cleanup(); \
#endif
OPtrSet(t)& append(t *e) \
{return (OPtrSet(t)&)GenCList::append(e);} \
OPtrSet(t)& append(const OPtrSet(t)& l) \
{return (OPtrSet(t)&)GenCList::append(l);} \
OPtrSet(t)& insert_at(int i, t *e) \
{return (OPtrSet(t)&)GenCList::insert_at(i,e);} \
OPtrSet(t)& insert_at(int i, const OPtrSet(t)& l) \
{return (OPtrSet(t)&)GenCList::insert_at(i,l);} \
OPtrSet(t)& remove_last() \
{return (OPtrSet(t)&)GenCList::remove_last();} \
OPtrSet(t)& remove_at(int i) \
{return (OPtrSet(t)&)GenCList::remove_at(i);} \
OPtrSet(t)& remove(int i, int j) \
{return (OPtrSet(t)&)GenCList::remove(i,j);} \
OPtrSet(t)& remove(t *elem) \
{return (OPtrSet(t)&)GenCList::remove(elem);} \
unsigned capacity() const {return GenCList::capacity();} \
unsigned size() const {return GenCList::size();} \
t*& at(int i) const {return (t*&)GenCList::at(i);} \
t*& operator[](int i) const {return (t*&)GenCList::operator[](i);} \
void operator&= (t *elem) {append(elem);} \
void operator&= (const OPtrSet(t)& lst) {append(lst);} \
}
#ifndef GNU
#define OPtrSetimplement(t) \
void OPtrSet(t)::cleanup() \
{ \
t** last=&at(size()); \
for (register t** e=&at(0); e<last; e++) delete *e; \
reset(); \
}
#endif
#endif /* HAS_TEMPLATES */
#endif /* OPTRSET_HXX */