heap.h
Go to the documentation of this file.
1 /*
2  * This file is part of the alglib project.
3  *
4  * (c) Divyanshu Kakwani <divkakwani@gmail.com>
5  *
6  * For the full copyright and license information, please view the LICENSE file
7  * that was distributed with this source code.
8  */
9 
10 #ifndef _HEAP_H
11 #define _HEAP_H
12 
13 #include <boost/concept_check.hpp>
14 #include <functional>
15 
16 namespace alglib {
17 namespace heap {
18 
64 template<typename elt_t, typename key_t>
65 class min_heap {
66  BOOST_CONCEPT_ASSERT((boost::LessThanComparable<elt_t>));
67  BOOST_CONCEPT_ASSERT((boost::LessThanComparable<key_t>));
68 
69  public:
70  virtual void insert(const elt_t& elt, const key_t& key) = 0;
71 
72  /* get the root */
73  virtual const elt_t& get_min_elt() const = 0;
74  virtual const key_t& get_min_key() const = 0;
75 
76  /* remove the root */
77  virtual void delete_min() = 0;
78  virtual void replace(const elt_t& elt, const key_t& key) = 0;
79 
80  /* Inspection */
81  virtual int size() const = 0;
82  virtual bool empty() const = 0;
83 
84  /* Internal modification */
85  virtual void update_key(const elt_t& elt, const key_t& key) = 0;
86 
87 
88  /* return a new heap that is the merger of the heap h and *this. */
89  // min_heap<elt_t, Compare> merge_heaps(const min_heap<elt_t, Compare>& h);
90 };
91 
92 } // end heap namespace
93 } // end alglib namespace
94 
95 
96 #endif // _HEAP_H
Definition: bimap.h:17
virtual void delete_min()=0
virtual void update_key(const elt_t &elt, const key_t &key)=0
virtual bool empty() const =0
Definition: heap.h:65
virtual const key_t & get_min_key() const =0
virtual int size() const =0
virtual void replace(const elt_t &elt, const key_t &key)=0
virtual void insert(const elt_t &elt, const key_t &key)=0
virtual const elt_t & get_min_elt() const =0