Clean up.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38737 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Clemens Zeidler
2010-09-20 04:34:38 +00:00
parent 4403274117
commit b329767e2f
4 changed files with 96 additions and 102 deletions
+6 -6
View File
@@ -3,19 +3,19 @@
* Copyright 2007-2008, James Kim, [email protected]
* Distributed under the terms of the MIT License.
*/
#ifndef CONSTRAINT_H
#define CONSTRAINT_H
#include "OperatorType.h"
#include "Variable.h"
#include "Summand.h"
#include <math.h>
#include <File.h>
#include <List.h>
#include <String.h>
#include <SupportDefs.h>
#include <math.h>
#include "OperatorType.h"
#include "Summand.h"
#include "Variable.h"
namespace LinearProgramming {
@@ -86,7 +86,7 @@ private:
Summand* fDNegObjSummand;
Summand* fDPosObjSummand;
void* fOwner;
char* fLabel;
BString fLabel;
bool fIsValid;
+5 -5
View File
@@ -3,13 +3,13 @@
* Copyright 2007-2008, James Kim, [email protected]
* Distributed under the terms of the MIT License.
*/
#ifndef VARIABLE_H
#define VARIABLE_H
#include <File.h>
#include <SupportDefs.h>
#include <List.h>
#include <String.h>
#include <SupportDefs.h>
namespace LinearProgramming {
@@ -22,7 +22,6 @@ class Summand;
* Contains minimum and maximum values.
*/
class Variable {
public:
int32 Index() const;
LinearSpec* LS() const;
@@ -61,11 +60,12 @@ protected:
private:
LinearSpec* fLS;
BList* fUsingSummands; // All Summands that link to this Variable
BList* fUsingSummands;
// All Summands that link to this Variable
double fValue;
double fMin;
double fMax;
char* fLabel;
BString fLabel;
bool fIsValid;
+2 -5
View File
@@ -325,15 +325,14 @@ Constraint::SetPenaltyPos(double value)
const char*
Constraint::Label()
{
return fLabel;
return fLabel.String();
}
void
Constraint::SetLabel(const char* label)
{
fLabel = (char*) malloc(strlen(label) + 1);
strcpy(fLabel, label);
fLabel = label;
}
@@ -471,7 +470,6 @@ void
Constraint::GetString(BString& string) const
{
string << "Constraint ";
if (fLabel)
string << fLabel;
string << "(" << (int32)this << "): ";
@@ -504,7 +502,6 @@ Constraint::Constraint(LinearSpec* ls, BList* summands, OperatorType op,
fOp(op),
fRightSide(rightSide),
fOwner(NULL),
fLabel(NULL),
fIsValid(true)
{
double coeffs[summands->CountItems() + 2];
+6 -9
View File
@@ -154,15 +154,14 @@ Variable::SetRange(double min, double max)
const char*
Variable::Label()
{
return fLabel;
return fLabel.String();
}
void
Variable::SetLabel(const char* label)
{
fLabel = (char*) malloc(strlen(label) + 1);
strcpy(fLabel, label);
fLabel = label;
}
@@ -298,7 +297,7 @@ Variable::Invalidate()
fLS->Variables()->RemoveItem(this);
// invalidate all constraints that use this variable
BList* markedForInvalidation = new BList();
BList markedForInvalidation;
BList* constraints = fLS->Constraints();
for (int i = 0; i < constraints->CountItems(); i++) {
Constraint* constraint = static_cast<Constraint*>(
@@ -311,15 +310,14 @@ Variable::Invalidate()
for (int j = 0; j < summands->CountItems(); j++) {
Summand* summand = static_cast<Summand*>(summands->ItemAt(j));
if (summand->Var() == this) {
markedForInvalidation->AddItem(constraint);
markedForInvalidation.AddItem(constraint);
break;
}
}
}
for (int i = 0; i < markedForInvalidation->CountItems(); i++)
static_cast<Constraint*>(markedForInvalidation->ItemAt(i))
for (int i = 0; i < markedForInvalidation.CountItems(); i++)
static_cast<Constraint*>(markedForInvalidation.ItemAt(i))
->Invalidate();
delete markedForInvalidation;
}
@@ -355,7 +353,6 @@ Variable::Variable(LinearSpec* ls)
Variable::~Variable()
{
Invalidate();
free(fLabel);
delete fUsingSummands;
}