1 //////////////////////////////////////////////////////////////////////////////
4 // ADLib, Prop and their related set of tools and documentation are in the
5 // public domain. The author(s) of this software reserve no copyrights on
6 // the source code and any code generated using the tools. You are encouraged
7 // to use ADLib and Prop to develop software, in both academic and commercial
8 // settings, and are free to incorporate any part of ADLib and Prop into
11 // Although you are under no obligation to do so, we strongly recommend that
12 // you give away all software developed using our tools.
14 // We also ask that credit be given to us when ADLib and/or Prop are used in
15 // your programs, and that this notice be preserved intact in all the source
18 // This software is still under development and we welcome any suggestions
19 // and help from the users.
23 //////////////////////////////////////////////////////////////////////////////
25 #ifndef queue_collection_h
26 #define queue_collection_h
28 //////////////////////////////////////////////////////////////////////////////
29 // Queue Collection derives a collection class using an existing
30 // queue concrete type.
31 // Suitable concrete types include:
32 // Queue<T> --- array based queue with capacity fixed at creation
33 // FixQueue<T> --- array based queue with capacity fixed at compile time
34 // VarQueue<T> --- array based expandable queue
35 // ListQueue<T> --- linked list based queue
36 // IndexableQueue<T> --- queue based on an indexable structure
37 //////////////////////////////////////////////////////////////////////////////
39 #include <AD/contain/seqcol.h>
41 template <class T
, class Q
>
42 class QueueCollection
: public SequenceableCollection
<T
> {
44 Q queue
; // implementation
47 //////////////////////////////////////////////////////////////
49 //////////////////////////////////////////////////////////////
50 typedef SequenceableCollection
<T
> Super
;
51 typedef Super::Element Element
;
53 //////////////////////////////////////////////////////////////
55 //////////////////////////////////////////////////////////////
56 inline int size() const { return stack
.size(); }
57 inline int capacity() const { return stack
.capacity(); }
58 inline Bool
is_empty() const { return stack
.is_empty(); }
59 inline Bool
is_full() const { return stack
.is_full(); }
60 // virtual Bool contains(const T&) const; // inherited
61 // virtual Ix lookup() const; // inherited
62 // virtual int length() const; // inherited
63 // virtual T& operator [] (int i) const; // inherited
65 //////////////////////////////////////////////////////////////
67 ///////////////////////////////////////////////////////////////
68 inline void clear() { stack
.clear(); }
69 // virtual Ix insert(const T&); // inherited
70 // virtual Bool remove(const T&); // inherited
72 ///////////////////////////////////////////////////////////////
74 ///////////////////////////////////////////////////////////////
75 inline Ix
first() const { return stack
.first(); }
76 inline Ix
next(Ix i
) const { return stack
.next(i
); }
77 inline const T
& operator [] (Ix
) const { return stack(i
); }
78 inline T
& operator [] (Ix
) { return stack(i
); }