BALL  1.4.1
peakList.h
Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: peakList.h,v 1.17 2003/08/26 08:04:45 oliver Exp $
00005 //
00006 
00007 #ifndef BALL_NMR_PEAKLIST_H
00008 #define BALL_NMR_PEAKLIST_H
00009 
00010 #ifndef BALL_NMR_PEAK_H
00011 # include<BALL/NMR/peak.h>
00012 #endif
00013 
00014 #ifndef BALL_COMMON_LIMITS_H
00015 # include<BALL/COMMON/limits.h>
00016 #endif
00017 
00018 namespace BALL 
00019 {
00020 
00025   template <typename PT>
00026   class PeakList
00027     : public std::list<PT>
00028   {
00029     public:
00030     
00031     BALL_CREATE(PeakList<PT>)
00032 
00033     
00036       
00037     
00038     typedef typename PT::Position Position;
00039 
00041     typedef PT PeakType;
00042   
00044     typedef typename std::list<PT>::iterator Iterator;
00045 
00047     typedef typename std::list<PT>::const_iterator ConstIterator;
00049 
00053 
00056     PeakList() 
00057     {
00058     }
00059     
00062     PeakList(const PeakList& peak_list)
00063       : std::list<PT>(peak_list)
00064     {
00065     }   
00066 
00069     virtual ~PeakList()
00070     {
00071     }
00072     
00074 
00078       
00081     void scale(float x)
00082     {
00083       Iterator it = std::list<PT>::begin();
00084       for (; it != std::list<PT>::end(); ++it)
00085       {
00086         it->setIntensity(it->getIntensity() * x);
00087       }
00088     }
00089 
00093     float getMaxIntensity() const
00094     {
00095       ConstIterator it = std::list<PT>::begin();
00096       float max = -Limits<float>::max();
00097       for (; it != std::list<PT>::end(); ++it)
00098       {
00099         max = std::max(max, it->getIntensity());
00100       }
00101     
00102       return max;
00103     }
00104 
00108     float getMinIntensity() const
00109     {
00110       ConstIterator it = std::list<PT>::begin();
00111       float min = Limits<float>::max();
00112       for (; it != std::list<PT>::end(); ++it)
00113       {
00114         min = std::min(min, it->getIntensity());
00115       }
00116     
00117       return min;
00118     }
00119 
00121   };
00122 
00127     
00129   typedef PeakList<Peak<float> > PeakList1D;
00130 
00132   typedef PeakList<Peak<Vector2> > PeakList2D;
00133 
00135   typedef PeakList<Peak<Vector3> > PeakList3D;
00136   
00138   
00139 } // namespace BALL
00140 
00141 #endif // BALL_NMR_PEAKLIST_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines