libassa 3.5.1
Loading...
Searching...
No Matches
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
18namespace ASSA {
19
24// less<> is borrowed from STL implementation.
25
29template <class Arg1, class Arg2, class Result>
35
36
40template <class T>
41struct Less : public Bfunc<T, T, bool> {
42 bool operator()(const T& x, const T& y) const { return x < y; }
43};
44
45
52template< class T, class Compare >
54{
55public:
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
66template<class T, class Compare>
67inline
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 */
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
Class PriorityQueue_Impl.
virtual bool remove(T)=0
virtual void insert(const T &)=0
virtual const T & top() const =0
virtual size_t size()=0
virtual T & operator[](int)=0
Bfunc is used by PriorityQueue_impl.
Less is borrowed from STL implementation.
bool operator()(const T &x, const T &y) const