NAME

OTC_BoundedQueue - Implements a FIFO or queue with fixed capacity.

SYNOPSIS


#include <OTC/collctn/bndqueue.hh>

template<class T>
class OTC_BoundedQueue
{
  public:
    static os_typespec* get_os_typespec();
    ~OTC_BoundedQueue();
    OTC_BoundedQueue(u_int theCapacity, T* theMem=0);
    OTC_BoundedQueue(OTC_BoundedQueue<T> const& theQueue);
    OTC_BoundedQueue<T>& operator=(
      OTC_BoundedQueue<T> const& theQueue
    );
    inline OTC_Boolean isEmpty() const;
    inline OTC_Boolean isFull() const;
    inline u_int count() const;
    inline u_int capacity() const;
    inline T& head();
    inline T const& head() const;
    inline T& peek(u_int theIndex);
    inline T const& peek(u_int theIndex) const;
    void add(T const& theItem);
    T remove();
    inline void clear();
    void discard(u_int theCount);
};

CLASS TYPE

Concrete

DESCRIPTION

OTC_BoundedQueue implements a FIFO or queue with fixed capacity. Note, that it is the user's responsibility to deal with deletion of objects held in the queue when it is parameterised over a pointer type; ie., this class works independently of the OTC_BaseActions class.

INITIALISATION

OTC_BoundedQueue(u_int theCapacity, T* theMem=0);
OTC_BoundedQueue(OTC_BoundedQueue<T> const& theQueue);

ASSIGNMENT

OTC_BoundedQueue<T>& operator=(OTC_BoundedQueue<T> const& theQueue);

QUERY

inline OTC_Boolean isEmpty() const;
inline OTC_Boolean isFull() const;
inline u_int count() const;
inline u_int capacity() const;
inline T& head();
inline T const& head() const;
inline T& peek(u_int theIndex);
inline T const& peek(u_int theIndex) const;

MODIFICATION

void add(T const& theItem);
T remove();
inline void clear();
void discard(u_int theCount);

NOTES

Being a bounded queue, for efficiency, an array is used in the internal implementation instead of a linked list. The consequences are, that when parameterised over a class type, the class must have a constructor which accepts no arguments and also be capable of having assignment performed upon it.

LIBRARY

OTC

AUTHOR(S)

Graham Dumpleton

COPYRIGHT

Copyright 1992 1993 OTC LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED