Fork me on GitHub

source: git/external/fastjet/plugins/SISCone/circulator.h@ d69dfe4

ImprovedOutputFile Timing dual_readout llp
Last change on this file since d69dfe4 was d7d2da3, checked in by pavel <pavel@…>, 11 years ago

move branches/ModularDelphes to trunk

  • Property mode set to 100644
File size: 4.0 KB
Line 
1// -*- C++ -*-
2///////////////////////////////////////////////////////////////////////////////
3// File: circulator.h //
4// Description: header file for circulator (circulator class) //
5// This file is part of the SISCone project. //
6// For more details, see http://projects.hepforge.org/siscone //
7// //
8// Copyright (c) 2006 Gavin Salam and Gregory Soyez //
9// //
10// This program is free software; you can redistribute it and/or modify //
11// it under the terms of the GNU General Public License as published by //
12// the Free Software Foundation; either version 2 of the License, or //
13// (at your option) any later version. //
14// //
15// This program is distributed in the hope that it will be useful, //
16// but WITHOUT ANY WARRANTY; without even the implied warranty of //
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
18// GNU General Public License for more details. //
19// //
20// You should have received a copy of the GNU General Public License //
21// along with this program; if not, write to the Free Software //
22// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
23// //
24// $Revision:: $//
25// $Date:: $//
26///////////////////////////////////////////////////////////////////////////////
27
28#ifndef __CIRCULATOR_H__
29#define __CIRCULATOR_H__
30
31namespace siscone{
32
33/// \class circulator
34/// a circulator that is foreseen to take as template member either a
35/// pointer or an iterator;
36template<class T> class circulator {
37
38public:
39 /// ctor with iniitalisation from iterators
40 /// \param here the current position
41 /// \param begin the first position
42 /// \param end the last position
43 inline circulator(T here, T begin, T end) : m_here(here), m_begin(begin), m_end(end) {}
44
45 /// copy ctor
46 /// \param other the circulator to copy
47 inline circulator(const circulator<T> & other) : m_here(other.m_here), m_begin(other.m_begin), m_end(other.m_end) {}
48
49 /// set just the position without resetting the begin and end elements
50 /// \param other the circulator to grab position from
51 void set_position(const circulator<T> & other) {m_here = other.m_here;}
52
53 /// set just the position without resetting the begin and end elements
54 /// \param pointer the iterator to use as the new position
55 void set_position(T pointer) {m_here = pointer;}
56
57 /// get the current object
58 T operator()() {return m_here;}
59
60 /// position incrementation
61 inline circulator<T> & operator++() {
62 ++m_here;
63 if (m_here == m_end) m_here = m_begin;
64 return *this;
65 }
66
67 /// position decrementation
68 inline circulator<T> & operator--() {
69 if (m_here == m_begin) m_here = m_end;
70 --m_here;
71 return *this;
72 }
73
74 /// check if the current elements are the same
75 /// NB: for efficiency, this checks only the here element
76 /// \param other the circulator to compare to the current one
77 bool operator==(const circulator & other) const {return m_here == other.m_here;}
78
79 /// check if the current elements are different
80 /// NB: for efficiency, this checks only the here element
81 /// \param other the circulator to compare to the current one
82 bool operator!=(const circulator & other) const {return m_here != other.m_here;}
83
84private:
85 T m_here, m_begin, m_end; ///< the current, beginning and ending iterators/pointers
86};
87
88}
89
90#endif // __CIRCULATOR_H__
Note: See TracBrowser for help on using the repository browser.