-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeap.h
More file actions
44 lines (35 loc) · 878 Bytes
/
Copy pathHeap.h
File metadata and controls
44 lines (35 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef HEAP_H
#define HEAP_H
#include <cstddef>
#include <string>
// This is the heap class you need to implement.
// It's a binary min-heap that stores its entries in an array.
// Do not edit this file.
class Heap {
public:
struct Entry {
std::string value;
float score;
};
private:
Entry* mData;
size_t mCapacity;
size_t mCount;
public:
Heap(size_t capacity);
Heap(const Heap& other);
Heap(Heap&& other);
~Heap();
size_t capacity() const;
size_t count() const;
const Entry& lookup(size_t index) const;
Entry pop();
Entry pushpop(const std::string& value, float score);
void push(const std::string& value, float score);
const Entry& top() const;
// Used by the autograder:
const Entry* data() const {
return mData;
}
};
#endif