libassa
3.5.1
assa
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 >
53
class
PriorityQueue_Impl
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
68
PriorityQueue_Impl<T, Compare>::
69
~PriorityQueue_Impl
()
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 */
ASSA::PriorityQueue_Impl::top
virtual const T & top() const =0
ASSA::Less
Definition:
PriorityQueue_Impl.h:41
ASSA::PriorityQueue_Impl::insert
virtual void insert(const T &)=0
ASSA::PriorityQueue_Impl::~PriorityQueue_Impl
virtual ~PriorityQueue_Impl()
Definition:
PriorityQueue_Impl.h:69
ASSA::Bfunc::second_argument_type
Arg2 second_argument_type
Definition:
PriorityQueue_Impl.h:32
ASSA::PriorityQueue_Impl::size
virtual size_t size()=0
ASSA::PriorityQueue_Impl::remove
virtual bool remove(T)=0
ASSA::PriorityQueue_Impl::pop
virtual T pop()=0
ASSA::Bfunc
Definition:
PriorityQueue_Impl.h:30
ASSA::PriorityQueue_Impl::operator[]
virtual T & operator[](int)=0
ASSA::Less::operator()
bool operator()(const T &x, const T &y) const
Definition:
PriorityQueue_Impl.h:42
ASSA::Bfunc::first_argument_type
Arg1 first_argument_type
Definition:
PriorityQueue_Impl.h:31
ASSA
Definition:
Acceptor.h:40
ASSA::Bfunc::result_type
Result result_type
Definition:
PriorityQueue_Impl.h:33
Generated by
1.8.17