home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1998 May
/
Pcwk5b98.iso
/
Borland
/
Cplus45
/
BC45
/
CLOBSH.PAK
/
PRIORTYQ.H
< prev
next >
Wrap
C/C++ Source or Header
|
1995-08-29
|
3KB
|
122 lines
/*------------------------------------------------------------------------*/
/* */
/* PRIORTYQ.H */
/* */
/* Copyright Borland International 1991, 1993 */
/* All Rights Reserved */
/* */
/*------------------------------------------------------------------------*/
#if !defined( __PRIORTYQ_H )
#define __PRIORTYQ_H
#define BI_OLDNAMES
#if !defined( __BTREE_H )
#include "classlib\obsolete\Btree.h"
#endif
#if !defined( __SHDDEL_H )
#include "classlib\ShdDel.h"
#endif // __SHDDEL_H
#pragma option -Vo-
#if defined( __BCOPT__ ) && !defined( __FLAT__ ) && !defined( _ALLOW_po )
#pragma option -po-
#endif
_CLASSDEF(PriorityQueue)
class _CLASSTYPE PriorityQueue :
public Container,
public virtual Object::TShouldDelete
{
public:
int isEmpty() const
{
return tree.isEmpty();
}
countType getItemsInContainer() const
{
return tree.getItemsInContainer();
}
void put(Object& o)
{
tree.add(o);
}
Object& get()
{
if( isEmpty() )
return NOOBJECT;
else
{
Object& obj = tree[0];
tree.detach( obj ); // does not delete
return obj;
}
}
Object& peekLeft()
{
return (isEmpty()?NOOBJECT:tree[0]);
}
void detachLeft( DeleteType dt = NoDelete )
{
if( !isEmpty() )
tree.detach( tree[0], dt );
}
void flush( DeleteType dt = DefDelete )
{
tree.flush( dt );
}
int hasMember( Object& obj ) const
{
return tree.hasMember( obj );
}
int ownsElements()
{
return tree.ownsElements();
}
void ownsElements( int del )
{
tree.ownsElements( del );
}
virtual classType isA() const
{
return priorityQueueClass;
}
virtual char _FAR *nameOf() const
{
return "PriorityQueue";
}
virtual ContainerIterator _FAR & initIterator() const
{
return tree.initIterator();
}
private:
Btree tree;
};
#if defined( __BCOPT__ ) && !defined( __FLAT__ ) && !defined( _ALLOW_po )
#pragma option -po.
#endif
#pragma option -Vo.
#endif