Fork me on GitHub

source: git/external/fastjet/internal/MinHeap.hh@ 1e8afcc

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 1e8afcc was 35cdc46, checked in by Pavel Demin <demin@…>, 10 years ago

upgrade FastJet to version 3.1.0-beta.1, upgrade Nsubjettiness to version 2.1.0, add SoftKiller version 1.0.0

  • Property mode set to 100644
File size: 3.4 KB
RevLine 
[35cdc46]1//FJSTARTHEADER
2// $Id: MinHeap.hh 3433 2014-07-23 08:17:03Z salam $
[d7d2da3]3//
[35cdc46]4// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
[d7d2da3]5//
6//----------------------------------------------------------------------
7// This file is part of FastJet.
8//
9// FastJet is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; either version 2 of the License, or
12// (at your option) any later version.
13//
14// The algorithms that underlie FastJet have required considerable
[35cdc46]15// development. They are described in the original FastJet paper,
16// hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
[d7d2da3]17// FastJet as part of work towards a scientific publication, please
[35cdc46]18// quote the version you use and include a citation to the manual and
19// optionally also to hep-ph/0512210.
[d7d2da3]20//
21// FastJet is distributed in the hope that it will be useful,
22// but WITHOUT ANY WARRANTY; without even the implied warranty of
23// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24// GNU General Public License for more details.
25//
26// You should have received a copy of the GNU General Public License
27// along with FastJet. If not, see <http://www.gnu.org/licenses/>.
28//----------------------------------------------------------------------
[35cdc46]29//FJENDHEADER
[d7d2da3]30
31#ifndef __FASTJET_MINHEAP__HH__
32#define __FASTJET_MINHEAP__HH__
33
34#include<vector>
35#include<cassert>
36#include<memory>
37#include<limits>
38#include "fastjet/internal/base.hh"
39
40FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
41
42//======================================================================
43/// \if internal_doc
44/// @ingroup internal
45/// \class MinHeap
46/// A class which provides a "heap"-like structure that allows
47/// access to a the minimal value of a dynamically changing set of numbers
48/// \endif
49class MinHeap {
50public:
51 /// construct a MinHeap from the vector of values, allowing future
52 /// expansion to a maximum size max_size;
53 MinHeap (const std::vector<double> & values, unsigned int max_size) :
[35cdc46]54 _heap(max_size) {initialise(values);}
55
56 /// do the minimal setup for a MinHeap that can reach max_size;
57 /// initialisation must be performed later with the actual values.
58 MinHeap (unsigned int max_size) : _heap(max_size) {}
[d7d2da3]59
60 /// constructor in which the the maximum size is the size of the values array
61 MinHeap (const std::vector<double> & values) :
[35cdc46]62 _heap(values.size()) {initialise(values);}
63
64 /// initialise the heap with the supplied values. Should only be called if
65 /// the constructor did not supply values.
66 void initialise(const std::vector<double> & values);
67
[d7d2da3]68 /// return the location of the minimal value on the heap
69 inline unsigned int minloc() const {
[35cdc46]70 return (_heap[0].minloc) - &(_heap[0]);}
[d7d2da3]71
72 /// return the minimal value on the heap
[35cdc46]73 inline double minval() const {return _heap[0].minloc->value;}
[d7d2da3]74
[35cdc46]75 inline double operator[](int i) const {return _heap[i].value;}
[d7d2da3]76
77 /// remove the value at the specified location (i.e. replace it with
78 /// the largest possible value).
79 void remove(unsigned int loc) {
80 update(loc,std::numeric_limits<double>::max());};
81
82 /// update the value at the specified location
83 void update(unsigned int, double);
84
85private:
86
87 struct ValueLoc{
88 double value;
89 ValueLoc * minloc;
90 };
91
92 std::vector<ValueLoc> _heap;
93
94
95
96};
97
98
99FASTJET_END_NAMESPACE
100
101#endif // __FASTJET_MINHEAP__HH__
Note: See TracBrowser for help on using the repository browser.