include/HistogramMaker.hpp

Go to the documentation of this file.
00001 // HistogramMaker.hpp: this file is part of the REGAL project.
00002 //
00003 // REGAL : Random and Exhaustive Generators for Automata - Library
00004 //
00005 // Copyright (C) 2007 Julien DAVID.
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // The complete GNU General Public Licence Notice can be found as the
00013 // `COPYING' file in the root directory.
00014 //
00015 //
00016 #ifndef HISTOGRAMMAKER
00017 #define HISTOGRAMMAKER
00018 
00019 #include "StatisticMaker.hpp"
00020 
00021 namespace regal{
00022   
00023     
00024   class HistogramMaker:public StatisticMaker{
00025   protected:
00026     int * tab;
00027     int max;
00028     
00029   public:
00030     
00037     HistogramMaker(char * path,char * option,const int & maxValue):StatisticMaker::StatisticMaker(path,option){
00038       tab=NULL;
00039       max=0;
00040       resetHistogram(maxValue);
00041     }
00042     
00047     void resetHistogram(const int & maxValue){
00048       if(max==maxValue)
00049         memset(tab,0,max*sizeof(int));
00050       else{
00051         if(max!=0)
00052           delete [] tab;
00053         tab=new int[maxValue];
00054         memset(tab,0,sizeof(int)*maxValue);
00055         max=maxValue;
00056       }
00057     }
00058 
00063     void addValue(const int & ind){
00064       if(ind<max&&ind>=0)
00065         tab[ind]++;
00066     }
00067 
00071     void writeHistogram(){
00072       for(int i=0;i<max;i++)
00073         fprintf(this->output,"%d %d\n",i,tab[i]);
00074     }
00075 
00080     int * getHistogram(){
00081       return tab;
00082     }
00083     
00087     virtual ~HistogramMaker(){
00088       if(max!=0)
00089         delete [] tab;
00090     }
00091     
00092   };
00093 
00094 }
00095 
00096 
00097 #endif 

Generated on Mon Sep 29 16:33:58 2008 for REGAL by  doxygen 1.5.1