Merge pull request #78 from jameshball/code-cleanup

Minor code cleanup
pull/170/head
James H Ball 2023-11-25 20:57:07 +00:00 zatwierdzone przez GitHub
commit 21c054726e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
9 zmienionych plików z 28 dodań i 32 usunięć

Wyświetl plik

@ -39,8 +39,9 @@ http://www.audiosynth.com
#include "Env.h"
Env::Env(std::vector<double> levels,
std::vector<double> times,
Env::Env(
const std::vector<double>& levels,
const std::vector<double>& times,
EnvCurveList const& curves,
const int releaseNode,
const int loopNode) throw()

Wyświetl plik

@ -69,8 +69,8 @@ public:
/**
Creates an Env with supplied specification.
*/
Env(std::vector<double> levels = { 0.0, 1.0, 0.0 }, /**< A Buffer of levels. e.g. B(0.0, 1.0, 1.0, 0.0) you can also use the macro LL - List Levels. */
std::vector<double> times = { 1.0, 1.0 }, /**< A Buffer of times. e.g., B(0.1, 0.8, 0.1) would have a total duration of 1sec. Macro LT - List Times can be used.
Env(const std::vector<double>& levels = { 0.0, 1.0, 0.0 }, /**< A Buffer of levels. e.g. B(0.0, 1.0, 1.0, 0.0) you can also use the macro LL - List Levels. */
const std::vector<double>& times = { 1.0, 1.0 }, /**< A Buffer of times. e.g., B(0.1, 0.8, 0.1) would have a total duration of 1sec. Macro LT - List Times can be used.
There should be one fewer time than level. */
EnvCurveList const& curves = EnvCurve(EnvCurve::Linear), /**< The shape of each segment. An EnvCurveList, with upto
the same number of elements as the times Buffer.

Wyświetl plik

@ -41,9 +41,7 @@ EnvCurveList::EnvCurveList(EnvCurve const& i00) throw() {
data.push_back(i00);
}
EnvCurveList::EnvCurveList(std::vector<EnvCurve> curves) throw() {
data = curves;
}
EnvCurveList::EnvCurveList(const std::vector<EnvCurve>& curves) throw() : data(curves) {}
EnvCurveList::EnvCurveList(EnvCurve::CurveType type, const int size) throw(){
for(int i = 0; i < size; i++)

Wyświetl plik

@ -112,7 +112,7 @@ public:
/// @{
EnvCurveList(EnvCurve const& i00) throw();
EnvCurveList(std::vector<EnvCurve>) throw();
EnvCurveList(const std::vector<EnvCurve>&) throw();
EnvCurveList(EnvCurve::CurveType type, const int size = 1) throw();
EnvCurveList(const double curve, const int size = 1) throw();

Wyświetl plik

@ -1,15 +1,19 @@
#include "Effect.h"
#include <numbers>
Effect::Effect(std::shared_ptr<EffectApplication> effectApplication, std::vector<EffectParameter*> parameters) : effectApplication(effectApplication), parameters(parameters), enabled(nullptr) {
actualValues = std::vector<double>(parameters.size(), 0.0);
}
Effect::Effect(std::shared_ptr<EffectApplication> effectApplication, const std::vector<EffectParameter*>& parameters) :
effectApplication(effectApplication),
parameters(parameters),
enabled(nullptr),
actualValues(std::vector<double>(parameters.size(), 0.0)) {}
Effect::Effect(std::shared_ptr<EffectApplication> effectApplication, EffectParameter* parameter) : Effect(effectApplication, std::vector<EffectParameter*>{parameter}) {}
Effect::Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, std::vector<EffectParameter*> parameters) : application(application), parameters(parameters), enabled(nullptr) {
actualValues = std::vector<double>(parameters.size(), 0.0);
}
Effect::Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, const std::vector<EffectParameter*>& parameters) :
application(application),
parameters(parameters),
enabled(nullptr),
actualValues(std::vector<double>(parameters.size(), 0.0)) {}
Effect::Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, EffectParameter* parameter) : Effect(application, std::vector<EffectParameter*>{parameter}) {}

Wyświetl plik

@ -8,9 +8,9 @@
class Effect {
public:
Effect(std::shared_ptr<EffectApplication> effectApplication, std::vector<EffectParameter*> parameters);
Effect(std::shared_ptr<EffectApplication> effectApplication, const std::vector<EffectParameter*>& parameters);
Effect(std::shared_ptr<EffectApplication> effectApplication, EffectParameter* parameter);
Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, std::vector<EffectParameter*> parameters);
Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, const std::vector<EffectParameter*>& parameters);
Effect(std::function<Vector2(int, Vector2, const std::vector<double>&, double)> application, EffectParameter* parameter);
Vector2 apply(int index, Vector2 input);

Wyświetl plik

@ -214,12 +214,12 @@ void Matching::Expand(int start, bool expandBlocked = false)
for (list<int>::iterator it = shallow[u].begin(); it != shallow[u].end() and not found; )
{
int si = *it;
for (vector<int>::iterator jt = deep[si].begin(); jt != deep[si].end() and not found; jt++)
for (vector<int>::iterator jt = deep[si].begin(); jt != deep[si].end() and not found; ++jt)
{
if (*jt == p)
found = true;
}
it++;
++it;
if (not found)
{
shallow[u].push_back(si);
@ -230,16 +230,16 @@ void Matching::Expand(int start, bool expandBlocked = false)
list<int>::iterator it = shallow[u].begin();
//Adjust the mate of the tip
mate[*it] = mate[u];
it++;
++it;
//
//Now we go through the odd circuit adjusting the new mates
while (it != shallow[u].end())
{
list<int>::iterator itnext = it;
itnext++;
++itnext;
mate[*it] = *itnext;
mate[*itnext] = *it;
itnext++;
++itnext;
it = itnext;
}
@ -378,7 +378,7 @@ int Matching::Blossom(int u, int v)
shallow[t].clear();
deep[t].clear();
for(list<int>::iterator it = circuit.begin(); it != circuit.end(); it++)
for(list<int>::iterator it = circuit.begin(); it != circuit.end(); ++it)
{
shallow[t].push_back(*it);
}
@ -547,16 +547,9 @@ pair< list<int>, double> Matching::SolveMinimumCostPerfectMatching(vector<double
list<int> matching = RetrieveMatching();
double obj = 0;
for(list<int>::iterator it = matching.begin(); it != matching.end(); it++)
for(list<int>::iterator it = matching.begin(); it != matching.end(); ++it)
obj += cost[*it];
double dualObj = 0;
for(int i = 0; i < 2*n; i++)
{
if(i < n) dualObj += dual[i];
else if(blocked[i]) dualObj += dual[i];
}
return pair< list<int>, double >(matching, obj);
}

Wyświetl plik

@ -42,7 +42,7 @@ std::vector<std::vector<int>> ConnectedComponents(Graph& G) {
return components;
}
WorldObject::WorldObject(std::string obj_string) {
WorldObject::WorldObject(const std::string& obj_string) {
tinyobj::ObjReaderConfig reader_config;
reader_config.triangulate = false;
reader_config.vertex_color = false;

Wyświetl plik

@ -4,7 +4,7 @@
class WorldObject {
public:
WorldObject(std::string);
WorldObject(const std::string&);
void setBaseRotationX(double x);
void setBaseRotationY(double y);