A class which provides a "heap"-like structure that allows access to a the minimal value of a dynamically changing set of numbers. More...
#include <MinHeap.hh>
Classes | |
struct | ValueLoc |
Public Member Functions | |
MinHeap (const std::vector< double > &values, unsigned int max_size) | |
construct a MinHeap from the vector of values, allowing future expansion to a maximum size max_size; | |
MinHeap (const std::vector< double > &values) | |
constructor in which the the maximum size is the size of the values array | |
unsigned int | minloc () const |
return the location of the minimal value on the heap | |
double | minval () const |
return the minimal value on the heap | |
double | operator[] (int i) const |
void | remove (unsigned int loc) |
remove the value at the specified location (i.e. | |
void | update (unsigned int, double) |
update the value at the specified location | |
Private Member Functions | |
void | _initialise (const std::vector< double > &values) |
Private Attributes | |
std::vector< ValueLoc > | _heap |
A class which provides a "heap"-like structure that allows access to a the minimal value of a dynamically changing set of numbers.
Definition at line 45 of file MinHeap.hh.
fastjet::MinHeap::MinHeap | ( | const std::vector< double > & | values, | |
unsigned int | max_size | |||
) | [inline] |
construct a MinHeap from the vector of values, allowing future expansion to a maximum size max_size;
Definition at line 49 of file MinHeap.hh.
00049 : 00050 _heap(max_size) {_initialise(values);};
fastjet::MinHeap::MinHeap | ( | const std::vector< double > & | values | ) | [inline] |
constructor in which the the maximum size is the size of the values array
Definition at line 53 of file MinHeap.hh.
00053 : 00054 _heap(values.size()) {_initialise(values);};
void fastjet::MinHeap::_initialise | ( | const std::vector< double > & | values | ) | [private] |
unsigned int fastjet::MinHeap::minloc | ( | ) | const [inline] |
return the location of the minimal value on the heap
Definition at line 57 of file MinHeap.hh.
double fastjet::MinHeap::minval | ( | ) | const [inline] |
return the minimal value on the heap
Definition at line 61 of file MinHeap.hh.
00061 {return _heap[0].minloc->value;};
double fastjet::MinHeap::operator[] | ( | int | i | ) | const [inline] |
Definition at line 63 of file MinHeap.hh.
00063 {return _heap[i].value;};
void fastjet::MinHeap::remove | ( | unsigned int | loc | ) | [inline] |
remove the value at the specified location (i.e.
replace it with the largest possible value).
Definition at line 67 of file MinHeap.hh.
00067 { 00068 update(loc,std::numeric_limits<double>::max());};
void fastjet::MinHeap::update | ( | unsigned | int, | |
double | ||||
) |
update the value at the specified location
std::vector<ValueLoc> fastjet::MinHeap::_heap [private] |
Definition at line 80 of file MinHeap.hh.