X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fspeedquantizer.cpp;h=fa7a4be8b31311d348118cb47c4237e0e59ae8c7;hb=dda1e6c8716b6ac70d63a3f6ff95474a8b8b7336;hp=acd1983f0ab0d42eee5da5509b0e331eaab04d54;hpb=e77b01f9fed6d5f653dbd0123f0f1f61a13c3dfa;p=r2c2.git diff --git a/source/libr2c2/speedquantizer.cpp b/source/libr2c2/speedquantizer.cpp index acd1983..fa7a4be 100644 --- a/source/libr2c2/speedquantizer.cpp +++ b/source/libr2c2/speedquantizer.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2011 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #include "speedquantizer.h" using namespace std; @@ -17,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); } @@ -89,7 +82,7 @@ unsigned SpeedQuantizer::find_speed_step(float speed) const else return 0; } - return min(min(static_cast(low*speed/steps[low].speed), steps.size()-1), last+limit); + return min(min(low*speed/steps[low].speed, steps.size()-1), last+limit); } float f = (speed-steps[low].speed)/(steps[high].speed-steps[low].speed);