diff --git a/lib/core/include/qx/core/qx-cumulation.h b/lib/core/include/qx/core/qx-cumulation.h index 7eb4df96..0a33430f 100644 --- a/lib/core/include/qx/core/qx-cumulation.h +++ b/lib/core/include/qx/core/qx-cumulation.h @@ -7,7 +7,7 @@ // Extra-component Includes #include "qx/utility/qx-concepts.h" -/* TODO: An iterator can't be added to this class unless it deferences to a special class like the QJsonValueRef +/* TODO: An iterator can't be added to this class unless it dereferences to a special class like the QJsonValueRef * approach since when the value is modified the running total would need to be changed as well. That or the running * total needs to be done away with and the total() method needs to calculate the total each time its called (ehhhh) */ @@ -22,7 +22,7 @@ class Cumulation //-Instance Variables---------------------------------------------------------------------------------------------- private: QHash mComponents; - QHash mScalers; + QHash mScalars; V mTotal; //-Constructor---------------------------------------------------------------------------------------------- @@ -47,31 +47,31 @@ class Cumulation return !mComponents.isEmpty() ? mTotal/mComponents.count() : 0; } - void basicInsert(K component, V value, V scaler) + void basicInsert(K component, V value, V scalar) { - mTotal += value * scaler; + mTotal += value * scalar; mComponents[component] = value; - mScalers[component] = scaler; + mScalars[component] = scalar; } public: - void insert(K component, V value, V scaler = 1) + void insert(K component, V value, V scalar = 1) { // If replacing an existing value, remove its portion from the running total if its not the same if(mComponents.contains(component)) { const V& curVal = mComponents[component]; - const V& curScal = mScalers[component]; + const V& curScal = mScalars[component]; // Remove old component portion from running total if different - if(curVal != value || curScal != scaler) + if(curVal != value || curScal != scalar) mTotal -= curVal * curScal; else return; } // Insert/replace - basicInsert(component, value, scaler); + basicInsert(component, value, scalar); } void setValue(K component, V value) @@ -81,8 +81,8 @@ class Cumulation V& curVal = mComponents[component]; if(value != curVal) { - const V& scaler = mScalers[component]; - mTotal += (value * scaler) - (curVal * scaler); + const V& scalar = mScalars[component]; + mTotal += (value * scalar) - (curVal * scalar); curVal = value; } } @@ -90,27 +90,27 @@ class Cumulation basicInsert(component, value, 1); } - void setScaler(K component, V scaler) + void setScalar(K component, V scalar) { if(mComponents.contains(component)) { - V& curScaler = mScalers[component]; - if(scaler != curScaler) + V& curScalar = mScalars[component]; + if(scalar != curScalar) { const V& value = mComponents[component]; - mTotal += (value * scaler) - (value * curScaler); - curScaler = scaler; + mTotal += (value * scalar) - (value * curScalar); + curScalar = scalar; } } else - basicInsert(component, 0, scaler); + basicInsert(component, 0, scalar); } void increase(K component, V amount) { if(mComponents.contains(component)) { - mTotal += amount * mScalers[component]; + mTotal += amount * mScalars[component]; mComponents[component] += amount; } else @@ -121,7 +121,7 @@ class Cumulation { if(mComponents.contains(component)) { - mTotal -= amount * mScalers[component]; + mTotal -= amount * mScalars[component]; mComponents[component] -= amount; } else @@ -132,7 +132,7 @@ class Cumulation { if(mComponents.contains(component)) { - mTotal += mScalers[component]; + mTotal += mScalars[component]; mComponents[component]++; } else @@ -145,7 +145,7 @@ class Cumulation { if(mComponents.contains(component)) { - mTotal -= mScalers[component]; + mTotal -= mScalars[component]; mComponents[component]--; } else @@ -158,16 +158,16 @@ class Cumulation { if(mComponents.contains(component)) { - mTotal -= (mComponents[component] * mScalers[component]); + mTotal -= (mComponents[component] * mScalars[component]); mComponents.remove(component); - mScalers.remove(component); + mScalars.remove(component); } } void clear() { mComponents.clear(); - mScalers.clear(); + mScalars.clear(); mTotal = 0; } @@ -182,7 +182,7 @@ class Cumulation bool operator==(const Cumulation& other) const { - return mComponents == other.mComponents && mScalers == other.mScalers && mTotal == other.mTotal; + return mComponents == other.mComponents && mScalars == other.mScalars && mTotal == other.mTotal; } bool operator!=(const Cumulation& other) const { return !(*this == other); } diff --git a/lib/core/src/qx-cumulation.dox b/lib/core/src/qx-cumulation.dox index 877a1a54..21e23d9c 100644 --- a/lib/core/src/qx-cumulation.dox +++ b/lib/core/src/qx-cumulation.dox @@ -15,7 +15,7 @@ namespace Qx * contained values is always known, and any individual value can be added, removed, or updated through its * corresponding key. * - * Additionally, a cumulation can have optional scalers applied to its components in order to differently + * Additionally, a cumulation can have optional scalars applied to its components in order to differently * weight their individual effect on the total. * * This is generally useful for keeping a running total, but when a previously added value may need to be @@ -34,12 +34,12 @@ namespace Qx //-Class Functions---------------------------------------------------------------------------------------------- //Public: /*! - * @fn void Cumulation::insert(K component, V value, V scaler = 1) + * @fn void Cumulation::insert(K component, V value, V scalar = 1) * - * Inserts a new component with key @a component, value @a value, and scaler @a scaler. + * Inserts a new component with key @a component, value @a value, and scalar @a scalar. * - * If there is already a component with the same key, that component's value and scaler are replaced with - * @a value and @a scaler respectively. + * If there is already a component with the same key, that component's value and scalar are replaced with + * @a value and @a scalar respectively. */ /*! @@ -48,19 +48,19 @@ namespace Qx * Sets the value of @a component to @a value. * * If the cumulation does not contain the specified component it will be added with a value of - * @a value and a scaler of 1. + * @a value and a scalar of 1. */ /*! - * @fn void Cumulation::setScaler(K component, V scaler) + * @fn void Cumulation::setScalar(K component, V scalar) * - * Sets the scaler of @a component to @a scaler. + * Sets the scalar of @a component to @a scalar. * * The amount that a component contributes to a cumulation's total is its value multiplied - * by its scaler. + * by its scalar. * * If the cumulation does not contain the specified component it will be added with a value of - * 0 and a scaler of @a scaler. + * 0 and a scalar of @a scalar. */ /*! @@ -69,7 +69,7 @@ namespace Qx * Adds @a amount to the value of @a component. * * If the cumulation does not contain the specified component it will be added with a value of - * @a amount and a scaler of 1. + * @a amount and a scalar of 1. */ /*! @@ -78,7 +78,7 @@ namespace Qx * Subtracts @a amount from the value of @a component. * * If the cumulation does not contain the specified component it will be added with a value of -* -amount and a scaler of 1. +* -amount and a scalar of 1. */ /*! @@ -87,7 +87,7 @@ namespace Qx * Increments the value of the given @a component and returns the new total. * * If the cumulation does not contain the specified component it will be added with a value of - * 1 and a scaler of 1. + * 1 and a scalar of 1. */ /*! @@ -96,7 +96,7 @@ namespace Qx * Decrements the value of the given @a component and returns the new total. * * If the cumulation does not contain the specified component it will be added with a value of - * -1 and a scaler of 1. + * -1 and a scalar of 1. */ /*!