HOG2
Heap.h
Go to the documentation of this file.
1 /*
2  * $Id: Heap.h
3  * hog2
4  *
5  * Created by Nathan Sturtevant on 11/29/06.
6  * Modified by Nathan Sturtevant on 02/29/20.
7  *
8  * This file is part of HOG2. See https://github.com/nathansttt/hog2 for licensing information.
9  *
10  */
11 
12 // HOG File
13 
14 #ifndef HEAP_H
15 #define HEAP_H
16 
17 #include <vector>
18 #include <list>
19 
20 #define DEFAULT_SIZE 10
21 #include "Graph.h"
22 
27 class Heap {
28 public:
29  Heap(int s = DEFAULT_SIZE);
30  ~Heap();
31  unsigned int size();
32  void Add(graph_object *val);
33  void DecreaseKey(graph_object *val);
34  bool IsIn(graph_object *val);
36  bool Empty();
37 private:
38  void HeapifyUp(int index);
39  void HeapifyDown(int index);
40  std::vector<graph_object *> _elts;
41  int count;
42 };
43 
44 #endif
Graph.h
Heap::size
unsigned int size()
Definition: Heap.cpp:28
Heap::~Heap
~Heap()
Definition: Heap.cpp:24
Heap::HeapifyUp
void HeapifyUp(int index)
Definition: Heap.cpp:88
Heap::_elts
std::vector< graph_object * > _elts
Definition: Heap.h:40
Heap::DecreaseKey
void DecreaseKey(graph_object *val)
Indicate that the key for a particular object has decreased.
Definition: Heap.cpp:47
graph_object
Parent class for nodes and edges allowing them to be stored in a Heap or manipulated with other data ...
Definition: Graph.h:47
Heap::Empty
bool Empty()
Returns true if no items are in the Heap.
Definition: Heap.cpp:83
DEFAULT_SIZE
#define DEFAULT_SIZE
Definition: Heap.h:20
Heap::Remove
graph_object * Remove()
Remove the item with the lowest key from the Heap & re-heapify.
Definition: Heap.cpp:66
Heap::HeapifyDown
void HeapifyDown(int index)
Definition: Heap.cpp:104
Heap::Heap
Heap(int s=DEFAULT_SIZE)
Definition: Heap.cpp:18
Heap::Add
void Add(graph_object *val)
Add object into Heap.
Definition: Heap.cpp:36
Heap::count
int count
Definition: Heap.h:41
Heap
A simple & efficient Heap class which uses Graph objects.
Definition: Heap.h:27
Heap::IsIn
bool IsIn(graph_object *val)
Returns true if the object is in the Heap.
Definition: Heap.cpp:55