xref: /386bsd/usr/src/lib/libg++/g++-include/gen/XPPQ.hP (revision a2142627)
1// This may look like C code, but it is really -*- C++ -*-
2/*
3Copyright (C) 1988 Free Software Foundation
4    written by Doug Lea (dl@rocky.oswego.edu)
5
6This file is part of GNU CC.
7
8GNU CC is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY.  No author or distributor
10accepts responsibility to anyone for the consequences of using it
11or for whether it serves any particular purpose or works at all,
12unless he says so in writing.  Refer to the GNU CC General Public
13License for full details.
14
15Everyone is granted permission to copy, modify and redistribute
16GNU CC, but only under the conditions described in the
17GNU CC General Public License.   A copy of this license is
18supposed to have been given to you along with GNU CC so you
19can know your rights and responsibilities.  It should be in a
20file named COPYING.  Among other things, the copyright notice
21and this notice must be preserved on all copies.
22*/
23
24
25#ifndef _<T>XPPQ_h
26#ifdef __GNUG__
27#pragma once
28#pragma interface
29#endif
30#define _<T>XPPQ_h 1
31
32#include "<T>.PQ.h"
33#include "<T>.XPlex.h"
34
35class <T>XPPQ : public <T>PQ
36{
37protected:
38  <T>XPlex              p;
39
40public:
41                <T>XPPQ(int chunksize = DEFAULT_INITIAL_CAPACITY);
42                <T>XPPQ(const <T>XPPQ&);
43
44  Pix           enq(<T&> item);
45  <T>           deq();
46
47  <T>&          front();
48  void          del_front();
49
50  int           contains(<T&> item);
51
52  void          clear();
53
54  Pix           first();
55  void          next(Pix& i);
56  <T>&          operator () (Pix i);
57  void          del(Pix i);
58  int           owns(Pix i);
59  Pix           seek(<T&> item);
60
61  int           OK();                    // rep invariant
62};
63
64#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
65
66inline <T>XPPQ::<T>XPPQ(int chunksize)
67     : p(1, chunksize) { count = 0; }
68
69inline <T>XPPQ::<T>XPPQ(const <T>XPPQ& s) : p(s.p) { count = s.count; }
70
71inline Pix <T>XPPQ::first()
72{
73  return p.first();
74}
75
76inline void <T>XPPQ::next(Pix  & idx)
77{
78  p.next(idx);
79}
80
81inline <T>& <T>XPPQ::operator ()(Pix   idx)
82{
83  return p(idx);
84}
85
86inline <T>& <T>XPPQ::front ()
87{
88  return p.low_element();
89}
90
91inline <T> <T>XPPQ::deq ()
92{
93  <T> x = p.low_element();
94  del_front();
95  return x;
96}
97
98inline void <T>XPPQ::clear()
99{
100  count = 0;  p.clear();
101}
102
103inline int <T>XPPQ::contains (<T&> item)
104{
105  return seek(item) != 0;
106}
107
108inline int <T>XPPQ::owns (Pix   idx)
109{
110  return p.owns(idx);
111}
112
113
114#endif
115#endif
116