BALL  1.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
peakList.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 // $Id: peakList.h,v 1.17 2003/08/26 08:04:45 oliver Exp $
5 //
6 
7 #ifndef BALL_NMR_PEAKLIST_H
8 #define BALL_NMR_PEAKLIST_H
9 
10 #ifndef BALL_NMR_PEAK_H
11 # include<BALL/NMR/peak.h>
12 #endif
13 
14 #ifndef BALL_COMMON_LIMITS_H
15 # include<BALL/COMMON/limits.h>
16 #endif
17 
18 namespace BALL
19 {
20 
25  template <typename PT>
26  class PeakList
27  : public std::list<PT>
28  {
29  public:
30 
32 
33 
36 
37 
38  typedef typename PT::Position Position;
39 
41  typedef PT PeakType;
42 
44  typedef typename std::list<PT>::iterator Iterator;
45 
47  typedef typename std::list<PT>::const_iterator ConstIterator;
49 
53 
57  {
58  }
59 
62  PeakList(const PeakList& peak_list)
63  : std::list<PT>(peak_list)
64  {
65  }
66 
69  virtual ~PeakList()
70  {
71  }
72 
74 
78 
81  void scale(float x)
82  {
83  Iterator it = std::list<PT>::begin();
84  for (; it != std::list<PT>::end(); ++it)
85  {
86  it->setIntensity(it->getIntensity() * x);
87  }
88  }
89 
93  float getMaxIntensity() const
94  {
95  ConstIterator it = std::list<PT>::begin();
96  float max = -Limits<float>::max();
97  for (; it != std::list<PT>::end(); ++it)
98  {
99  max = std::max(max, it->getIntensity());
100  }
101 
102  return max;
103  }
104 
108  float getMinIntensity() const
109  {
110  ConstIterator it = std::list<PT>::begin();
111  float min = Limits<float>::max();
112  for (; it != std::list<PT>::end(); ++it)
113  {
114  min = std::min(min, it->getIntensity());
115  }
116 
117  return min;
118  }
119 
121  };
122 
127 
130 
133 
136 
138 
139 } // namespace BALL
140 
141 #endif // BALL_NMR_PEAKLIST_H