libassa  3.5.1
PriorityQueue_Impl.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //------------------------------------------------------------------------------
3 // PriorityQueue_Impl.h
4 //------------------------------------------------------------------------------
5 // Copyright (C) 1997-2002 Vladislav Grinchenko
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Library General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
11 //------------------------------------------------------------------------------
12 // Created: 09/17/1999
13 //------------------------------------------------------------------------------
14 
15 #ifndef PRIORITY_QUEUE_IMPL_H
16 #define PRIORITY_QUEUE_IMPL_H
17 
18 namespace ASSA {
19 
24 // less<> is borrowed from STL implementation.
25 
29 template <class Arg1, class Arg2, class Result>
30 struct Bfunc {
31  typedef Arg1 first_argument_type;
32  typedef Arg2 second_argument_type;
33  typedef Result result_type;
34 };
35 
36 
40 template <class T>
41 struct Less : public Bfunc<T, T, bool> {
42  bool operator()(const T& x, const T& y) const { return x < y; }
43 };
44 
45 
52 template< class T, class Compare >
54 {
55 public:
56  virtual ~PriorityQueue_Impl ();
57 
58  virtual void insert (const T&) =0;
59  virtual T pop () =0;
60  virtual const T& top () const =0;
61  virtual bool remove (T) =0;
62  virtual size_t size () =0;
63  virtual T& operator[] (int) =0;
64 };
65 
66 template<class T, class Compare>
67 inline
70 {
71  // Here is the twist: we must provide a definition for the virtual
72  // destructor. We need the definition here because the way virtual
73  // destructors work. Most derived class's destructor is called first,
74  // then the destructor of each base class is called. That means that
75  // the compiler will generate a call to ~PriorityQueue_Impl, even
76  // though the class is abstract - that's why we need body here.
77 
78  /* no-op */
79 }
80 
81 } // end namespace ASSA
82 
83 #endif /* PRIORITY_QUEUE_IMPL_H */
Class PriorityQueue_Impl.
virtual bool remove(T)=0
virtual void insert(const T &)=0
virtual size_t size()=0
virtual const T & top() const =0
virtual T & operator[](int)=0
Definition: Acceptor.h:40
Bfunc is used by PriorityQueue_impl.
Less is borrowed from STL implementation.
bool operator()(const T &x, const T &y) const