]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/speedquantizer.cpp
Improve the interface and algorithms of BlockAllocator
[r2c2.git] / source / libr2c2 / speedquantizer.cpp
index 1098d437c38e76caf7ecb6f1afdd335ae5aaf2e5..fa7a4be8b31311d348118cb47c4237e0e59ae8c7 100644 (file)
@@ -10,13 +10,13 @@ SpeedQuantizer::SpeedQuantizer(unsigned n):
        weight_limit(10)
 {
        if(n<1)
-               throw InvalidParameterValue("Must have at leats one speed step");
+               throw invalid_argument("SpeedQuantizer::SpeedQuantizer");
 }
 
 void SpeedQuantizer::learn(unsigned i, float s, float w)
 {
        if(i>=steps.size())
-               throw InvalidParameterValue("Speed step index out of range");
+               throw out_of_range("SpeedQuantizer::learn");
        steps[i].add(s, w);
 }
 
@@ -82,7 +82,7 @@ unsigned SpeedQuantizer::find_speed_step(float speed) const
                        else
                                return 0;
                }
-               return min(min(static_cast<unsigned>(low*speed/steps[low].speed), steps.size()-1), last+limit);
+               return min(min<unsigned>(low*speed/steps[low].speed, steps.size()-1), last+limit);
        }
 
        float f = (speed-steps[low].speed)/(steps[high].speed-steps[low].speed);