Loading...
Searching...
No Matches
PriorityQueue_Impl.h
Go to the documentation of this file.
// -*- c++ -*-
//------------------------------------------------------------------------------
// PriorityQueue_Impl.h
//------------------------------------------------------------------------------
// Copyright (C) 1997-2002 Vladislav Grinchenko
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//------------------------------------------------------------------------------
// Created: 09/17/1999
//------------------------------------------------------------------------------
#ifndef PRIORITY_QUEUE_IMPL_H
#define PRIORITY_QUEUE_IMPL_H
namespace ASSA {
// less<> is borrowed from STL implementation.
template <class Arg1, class Arg2, class Result>
struct Bfunc {
typedef Arg1 first_argument_type;
typedef Arg2 second_argument_type;
typedef Result result_type;
};
template <class T>
struct Less : public Bfunc<T, T, bool> {
bool operator()(const T& x, const T& y) const { return x < y; }
};
template< class T, class Compare >
class PriorityQueue_Impl
{
public:
virtual ~PriorityQueue_Impl ();
virtual void insert (const T&) =0;
virtual T pop () =0;
virtual const T& top () const =0;
virtual bool remove (T) =0;
virtual size_t size () =0;
virtual T& operator[] (int) =0;
};
template<class T, class Compare>
inline
PriorityQueue_Impl<T, Compare>::
~PriorityQueue_Impl ()
{
// Here is the twist: we must provide a definition for the virtual
// destructor. We need the definition here because the way virtual
// destructors work. Most derived class's destructor is called first,
// then the destructor of each base class is called. That means that
// the compiler will generate a call to ~PriorityQueue_Impl, even
// though the class is abstract - that's why we need body here.
/* no-op */
}
} // end namespace ASSA
#endif /* PRIORITY_QUEUE_IMPL_H */
ASSA::PriorityQueue_Impl
Class PriorityQueue_Impl.
Definition PriorityQueue_Impl.h:54
ASSA::PriorityQueue_Impl::remove
virtual bool remove(T)=0
ASSA::PriorityQueue_Impl::insert
virtual void insert(const T &)=0
ASSA::PriorityQueue_Impl::~PriorityQueue_Impl
virtual ~PriorityQueue_Impl()
Definition PriorityQueue_Impl.h:69
ASSA::PriorityQueue_Impl::top
virtual const T & top() const =0
ASSA::PriorityQueue_Impl::size
virtual size_t size()=0
ASSA::PriorityQueue_Impl::operator[]
virtual T & operator[](int)=0
ASSA::PriorityQueue_Impl::pop
virtual T pop()=0
ASSA
Definition Acceptor.h:40
ASSA::Bfunc
Bfunc is used by PriorityQueue_impl.
Definition PriorityQueue_Impl.h:30
ASSA::Bfunc::first_argument_type
Arg1 first_argument_type
Definition PriorityQueue_Impl.h:31
ASSA::Bfunc::result_type
Result result_type
Definition PriorityQueue_Impl.h:33
ASSA::Bfunc::second_argument_type
Arg2 second_argument_type
Definition PriorityQueue_Impl.h:32
ASSA::Less
Less is borrowed from STL implementation.
Definition PriorityQueue_Impl.h:41
ASSA::Less::operator()
bool operator()(const T &x, const T &y) const
Definition PriorityQueue_Impl.h:42