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 #ifndef BALL_DATATYPE_LIST_H
00019 # include<BALL/DATATYPE/list.h>
00020 #endif
00021 
00022 namespace BALL 
00023 {
00024 
00029   template <typename PT>
00030   class PeakList
00031     : public List<PT>
00032   {
00033     public:
00034     
00035     BALL_CREATE(PeakList<PT>)
00036 
00037     
00040       
00041     
00042     typedef typename PT::Position Position;
00043 
00045     typedef PT PeakType;
00046   
00048     typedef typename List<PT>::iterator Iterator;
00049 
00051     typedef typename List<PT>::ConstIterator ConstIterator;
00053 
00057 
00060     PeakList() 
00061     {
00062     }
00063     
00066     PeakList(const PeakList& peak_list)
00067       : List<PT>(peak_list)
00068     {
00069     }   
00070 
00073     virtual ~PeakList()
00074     {
00075     }
00076     
00078 
00082       
00085     void scale(float x)
00086     {
00087       Iterator it = List<PT>::begin();
00088       for (; it != List<PT>::end(); ++it)
00089       {
00090         it->setIntensity(it->getIntensity() * x);
00091       }
00092     }
00093 
00097     float getMaxIntensity() const
00098     {
00099       ConstIterator it = List<PT>::begin();
00100       float max = -Limits<float>::max();
00101       for (; it != List<PT>::end(); ++it)
00102       {
00103         max = std::max(max, it->getIntensity());
00104       }
00105     
00106       return max;
00107     }
00108 
00112     float getMinIntensity() const
00113     {
00114       ConstIterator it = List<PT>::begin();
00115       float min = Limits<float>::max();
00116       for (; it != List<PT>::end(); ++it)
00117       {
00118         min = std::min(min, it->getIntensity());
00119       }
00120     
00121       return min;
00122     }
00123 
00125   };
00126 
00131     
00133   typedef PeakList<Peak<float> > PeakList1D;
00134 
00136   typedef PeakList<Peak<Vector2> > PeakList2D;
00137 
00139   typedef PeakList<Peak<Vector3> > PeakList3D;
00140   
00142   
00143 } // namespace BALL
00144 
00145 #endif // BALL_NMR_PEAKLIST_H