1 #ifndef __TRADEMGEN_BAS_CATEGORICALATTRIBUTELITE_HPP
2 #define __TRADEMGEN_BAS_CATEGORICALATTRIBUTELITE_HPP
14 #include <stdair/stdair_basic_types.hpp>
15 #include <stdair/service/Logger.hpp>
41 const T&
getValue (
const stdair::Probability_T& iCumulativeProbability)
const {
45 for (
unsigned int idx = 0; idx < _size; ++idx) {
46 if (_cumulativeDistribution.at(idx) >= lKey) {
47 const T& oValue = _valueArray.at(idx);
52 std::ostringstream oStr;
53 oStr <<
"The following cumulative probability is out of range: "
62 for (
unsigned int idx = 0; idx < _size; ++idx) {
63 if (_valueArray.at(idx) == iValue) {
77 std::ostringstream oStr;
79 for (
unsigned int idx = 0; idx < _size; ++idx) {
83 oStr << _valueArray.at(idx) <<
":"
96 : _size (iValueMap.size()) {
110 : _size (iCAL._size),
111 _cumulativeDistribution (iCAL._cumulativeDistribution),
112 _valueArray (iCAL._valueArray) {
120 _cumulativeDistribution = iCAL._cumulativeDistribution;
121 _valueArray = iCAL._valueArray;
138 const unsigned int lSize = iValueMap.size();
139 _cumulativeDistribution.reserve (lSize);
140 _valueArray.reserve (lSize);
142 stdair::Probability_T cumulative_probability_so_far = 0.0;
146 for (
typename ProbabilityMassFunction_T::const_iterator
147 itProbabilityMassFunction = iValueMap.begin();
148 itProbabilityMassFunction != iValueMap.end();
149 ++itProbabilityMassFunction) {
151 stdair::Probability_T attribute_probability_mass =
152 itProbabilityMassFunction->second;
154 if (attribute_probability_mass > 0) {
155 const T& attribute_value = itProbabilityMassFunction->first;
156 cumulative_probability_so_far += attribute_probability_mass;
162 _cumulativeDistribution.push_back (lKey);
163 _valueArray.push_back (attribute_value);
167 _size = _valueArray.size();
180 std::vector<DictionaryKey_T> _cumulativeDistribution;
185 std::vector<T> _valueArray;
188 #endif // __TRADEMGEN_BAS_CATEGORICALATTRIBUTELITE_HPP