mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
PriorityQueue: initialization cleanup
This commit is contained in:
parent
a312851d6e
commit
8424b68d77
2 changed files with 13 additions and 15 deletions
|
@ -9,11 +9,9 @@
|
||||||
#include "Reporter.h"
|
#include "Reporter.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
PriorityQueue::PriorityQueue(int initial_size)
|
PriorityQueue::PriorityQueue(int initial_size) : max_heap_size(initial_size)
|
||||||
{
|
{
|
||||||
max_heap_size = initial_size;
|
|
||||||
heap = new PQ_Element*[max_heap_size];
|
heap = new PQ_Element*[max_heap_size];
|
||||||
peak_heap_size = heap_size = cumulative_num = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PriorityQueue::~PriorityQueue()
|
PriorityQueue::~PriorityQueue()
|
||||||
|
|
|
@ -9,8 +9,8 @@ class PriorityQueue;
|
||||||
|
|
||||||
class PQ_Element {
|
class PQ_Element {
|
||||||
public:
|
public:
|
||||||
explicit PQ_Element(double t) { time = t; offset = -1; }
|
explicit PQ_Element(double t) : time(t) {}
|
||||||
virtual ~PQ_Element() { }
|
virtual ~PQ_Element() = default;
|
||||||
|
|
||||||
double Time() const { return time; }
|
double Time() const { return time; }
|
||||||
|
|
||||||
|
@ -20,9 +20,9 @@ public:
|
||||||
void MinimizeTime() { time = -HUGE_VAL; }
|
void MinimizeTime() { time = -HUGE_VAL; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PQ_Element() { time = 0; offset = -1; }
|
PQ_Element() = default;
|
||||||
double time;
|
double time = 0.0;
|
||||||
int offset;
|
int offset = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PriorityQueue {
|
class PriorityQueue {
|
||||||
|
@ -35,8 +35,8 @@ public:
|
||||||
{
|
{
|
||||||
if ( heap_size == 0 )
|
if ( heap_size == 0 )
|
||||||
return 0;
|
return 0;
|
||||||
else
|
|
||||||
return heap[0];
|
return heap[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Removes (and returns) top of queue. Returns nil if the queue
|
// Removes (and returns) top of queue. Returns nil if the queue
|
||||||
|
@ -89,9 +89,9 @@ protected:
|
||||||
SetElement(bin2, t);
|
SetElement(bin2, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
PQ_Element** heap;
|
PQ_Element** heap = nullptr;
|
||||||
int heap_size;
|
int heap_size = 0;
|
||||||
int peak_heap_size;
|
int peak_heap_size = 0;
|
||||||
int max_heap_size;
|
int max_heap_size = 0;
|
||||||
uint64_t cumulative_num;
|
uint64_t cumulative_num = 0;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue