00001 //============================================================================ 00005 //============================================================================ 00006 00007 #ifndef NXYTER_DISTFUNC_H 00008 #define NXYTER_DISTFUNC_H 00009 00010 #include <vector> 00011 00012 namespace nxyter { 00013 00014 class DistFunc { 00015 protected: 00016 std::vector<float> fData; 00017 int fMaxEntries; 00018 bool fFull; 00019 bool fSorted; 00020 00021 public: 00022 explicit DistFunc(int cap=0); 00023 virtual ~DistFunc(); 00024 00025 void setMaxEntries(int max); 00026 00028 00038 void setCapacity(int cap) 00039 { fData.reserve(cap); } 00040 00042 void clear() 00043 { fData.clear(); fSorted = false; fFull = false; } 00044 00045 void addEntry(float val); 00046 00048 int numEntries() 00049 { return fData.size(); } 00050 00052 00058 bool full() 00059 { return fFull; } 00060 00061 float operator()(float prob); 00062 float operator[](int ind); 00063 00064 float getMedian(); 00065 float getWidth(float cut); 00066 float getMin(); 00067 float getMax(); 00068 00069 protected: 00070 void sort(); 00071 00072 }; 00073 00074 } 00075 00076 #endif