While doing some refactoring I've found that I'm quite often using a pair or floats to represent an initial value and how much this value linearly varies over time. I want to create a struct to hold both fields but I just can't find the right name for it.
在进行一些重构时,我发现我经常使用一对或浮点数来表示初始值以及该值随时间线性变化的程度。我想创建一个结构来保存两个字段,但我找不到正确的名称。
It should look something like this:
它应该看起来像这样:
struct XXX
{
float Value;
float Slope; // or Delta? or Variation?
}
Any suggestions will be much appreciated.
任何建议将不胜感激。
7 个解决方案
#1
Since you have an initial value, and a value indicating how 'something' evolves, you could go with something like "Linear Function".
由于你有一个初始值,以及一个表示“某事”如何演变的值,你可以使用像“线性函数”这样的东西。
I would also add the necessary member functions:
我还会添加必要的成员函数:
struct LinearFunction {
float constant;
float slope;
float increment( float delta ) const { return constant + delta*slope; }
void add( const LinearFunction& other ) { constant += other.constant; slope += other.slope; }
LinearFunction invert() const {
LinearFunction inv = { -constant/slope, 1./slope; };
return inv;
}
};
Or am I to eager here?
还是我要在这里渴望?
#2
I guess i would prefer this kind of naming:
我想我更喜欢这种命名:
struct ValueDeltaDuplet
{
float Value;
float Delta;
}
#3
Initial value + constant slope : isn't this an affine function ?
初始值+恒定斜率:这不是一个仿射函数吗?
#4
Feels like a "Scale" to me...
对我来说感觉就像“规模”......
struct ValueScale
{
float Value;
float Slope;
}
or maybe
struct ScalableValue
{
float Value;
float Slope;
}
#5
It's like Arithmetic progression (or arithmetic sequence)
这就像算术级数(或算术序列)
struct sequence_num_t {
float value;
float delta;
};
or
struct SequencePoint
{
float Value;
float Delta;
};
#6
struct ValueSlopePair
{
float Value;
float Slope;
}
#7
struct FloatPair
{
float Value;
float Slope;
}
#1
Since you have an initial value, and a value indicating how 'something' evolves, you could go with something like "Linear Function".
由于你有一个初始值,以及一个表示“某事”如何演变的值,你可以使用像“线性函数”这样的东西。
I would also add the necessary member functions:
我还会添加必要的成员函数:
struct LinearFunction {
float constant;
float slope;
float increment( float delta ) const { return constant + delta*slope; }
void add( const LinearFunction& other ) { constant += other.constant; slope += other.slope; }
LinearFunction invert() const {
LinearFunction inv = { -constant/slope, 1./slope; };
return inv;
}
};
Or am I to eager here?
还是我要在这里渴望?
#2
I guess i would prefer this kind of naming:
我想我更喜欢这种命名:
struct ValueDeltaDuplet
{
float Value;
float Delta;
}
#3
Initial value + constant slope : isn't this an affine function ?
初始值+恒定斜率:这不是一个仿射函数吗?
#4
Feels like a "Scale" to me...
对我来说感觉就像“规模”......
struct ValueScale
{
float Value;
float Slope;
}
or maybe
struct ScalableValue
{
float Value;
float Slope;
}
#5
It's like Arithmetic progression (or arithmetic sequence)
这就像算术级数(或算术序列)
struct sequence_num_t {
float value;
float delta;
};
or
struct SequencePoint
{
float Value;
float Delta;
};
#6
struct ValueSlopePair
{
float Value;
float Slope;
}
#7
struct FloatPair
{
float Value;
float Slope;
}