Roulette.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00030
00031 #ifndef __ROULETTE_H_
00032 #define __ROULETTE_H_
00033
00034 #ifdef MIP_HOST_APPLE
00035 #include <applePatch.h>
00036 #endif
00037
00038 #include <vector>
00039 #include <map>
00040 #include <sstream>
00041
00042 #include <Types.h>
00043
00044
00048
00050
00051
00052 using namespace std;
00053
00054 namespace MipBaselib {
00055
00059 struct Pocket{
00060
00062 int value;
00063
00065 Decimal weight;
00066
00069 Pocket();
00070
00074 Pocket(int v);
00075
00080 Pocket(int v, Decimal w);
00081
00084 Pocket(const Pocket& v);
00085
00088 const Pocket& operator=(const Pocket& v);
00089
00092 string print();
00093 };
00094
00095
00100 class Roulette : private vector<Pocket>{
00101
00102 Decimal _sumW;
00103 int _numP;
00104 vector<Decimal> _pSumW;
00105 map<int,bool> _alreadyGone;
00106 int _alreadyGoneNumber;
00107 Decimal _sumGone;
00108
00109 public:
00111 Roulette();
00112
00114 Roulette(const Roulette &r);
00115
00117 const Roulette& operator=(const Roulette &r);
00118
00120 void setCapacity(int s);
00121
00126 void addPocket(Pocket p);
00127
00130 int getNumPockets() const;
00131
00134 int getSumPockets() const;
00135
00140 bool weigthedExtraction(int &extracted, bool rep = true);
00141
00147 bool unweigthedExtraction(int &extracted, bool rep = true);
00148
00150 void resetRepetitions();
00151
00153 void clearAll();
00154
00157 string print();
00158
00159 private:
00160 bool weigthedExtractionWithRepetitions(int &extracted);
00161
00162 bool unweigthedExtractionWithRepetitions(int &extracted);
00163
00164 bool weigthedExtractionNoRepetitions(int &extracted);
00165
00166 bool unweigthedExtractionNoRepetitions(int &extracted);
00167 };
00168
00169 };
00170
00171 #endif
00172
00173
00174
00175
00176