[haiku-commits] r38741 - in haiku/trunk: headers/libs/alm headers/libs/linprog src/libs/alm src/libs/linprog

  • From: clemens.zeidler@xxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 20 Sep 2010 08:09:20 +0200 (CEST)

Author: czeidler
Date: 2010-09-20 08:09:19 +0200 (Mon, 20 Sep 2010)
New Revision: 38741
Changeset: http://dev.haiku-os.org/changeset/38741

Modified:
   haiku/trunk/headers/libs/alm/Area.h
   haiku/trunk/headers/libs/linprog/Constraint.h
   haiku/trunk/headers/libs/linprog/LinearSpec.h
   haiku/trunk/headers/libs/linprog/Summand.h
   haiku/trunk/src/libs/alm/Area.cpp
   haiku/trunk/src/libs/alm/BALMLayout.cpp
   haiku/trunk/src/libs/linprog/Constraint.cpp
   haiku/trunk/src/libs/linprog/LinearSpec.cpp
   haiku/trunk/src/libs/linprog/Variable.cpp
Log:
- Hide constraint header in Area file.
- Start to replace BList with BObjectList.



Modified: haiku/trunk/headers/libs/alm/Area.h
===================================================================
--- haiku/trunk/headers/libs/alm/Area.h 2010-09-20 05:42:31 UTC (rev 38740)
+++ haiku/trunk/headers/libs/alm/Area.h 2010-09-20 06:09:19 UTC (rev 38741)
@@ -18,11 +18,14 @@
 #include "Area.h"
 #include "Row.h"
 #include "Column.h"
-#include "Constraint.h"
 
 
+class Constraint;
+
+
 namespace BALM {
 
+
 class BALMLayout;
 
 /**

Modified: haiku/trunk/headers/libs/linprog/Constraint.h
===================================================================
--- haiku/trunk/headers/libs/linprog/Constraint.h       2010-09-20 05:42:31 UTC 
(rev 38740)
+++ haiku/trunk/headers/libs/linprog/Constraint.h       2010-09-20 06:09:19 UTC 
(rev 38741)
@@ -9,7 +9,7 @@
 #include <math.h>
 
 #include <File.h>
-#include <List.h>
+#include <ObjectList.h>
 #include <String.h>
 #include <SupportDefs.h>
 
@@ -31,8 +31,8 @@
 public:
                        int32                           Index() const;
 
-                       BList*                          LeftSide();
-                       void                            SetLeftSide(BList* 
summands);
+                       SummandList*            LeftSide();
+                       void                            
SetLeftSide(SummandList* summands);
                        void                            UpdateLeftSide();
                        void                            SetLeftSide(double 
coeff1, Variable* var1);
                        void                            SetLeftSide(double 
coeff1, Variable* var1,
@@ -71,13 +71,14 @@
                                                                ~Constraint();
 
 protected:
-                                                               
Constraint(LinearSpec* ls, BList* summands,
-                                                                               
OperatorType op, double rightSide,
-                                                                               
double penaltyNeg, double penaltyPos);
+                                                               
Constraint(LinearSpec* ls,
+                                                                       
SummandList* summands, OperatorType op,
+                                                                       double 
rightSide, double penaltyNeg,
+                                                                       double 
penaltyPos);
 
 private:
                        LinearSpec*                     fLS;
-                       BList*                          fLeftSide;
+                       SummandList*            fLeftSide;
                        OperatorType            fOp;
                        double                          fRightSide;
                        Summand*                        fDNegObjSummand;
@@ -91,6 +92,10 @@
 
 };
 
+
+typedef BObjectList<Constraint> ConstraintList;
+
+
 }      // namespace LinearProgramming
 
 using LinearProgramming::Constraint;

Modified: haiku/trunk/headers/libs/linprog/LinearSpec.h
===================================================================
--- haiku/trunk/headers/libs/linprog/LinearSpec.h       2010-09-20 05:42:31 UTC 
(rev 38740)
+++ haiku/trunk/headers/libs/linprog/LinearSpec.h       2010-09-20 06:09:19 UTC 
(rev 38741)
@@ -43,7 +43,7 @@
 
                        Variable*                       AddVariable();
 
-                       Constraint*                     AddConstraint(BList* 
summands,
+                       Constraint*                     
AddConstraint(SummandList* summands,
                                                                        
OperatorType op, double rightSide);
                        Constraint*                     AddConstraint(double 
coeff1, Variable* var1,
                                                                        
OperatorType op, double rightSide);
@@ -60,7 +60,7 @@
                                                                        double 
coeff4, Variable* var4,
                                                                        
OperatorType op, double rightSide);
 
-                       Constraint*                     AddConstraint(BList* 
summands,
+                       Constraint*                     
AddConstraint(SummandList* summands,
                                                                        
OperatorType op, double rightSide,
                                                                        double 
penaltyNeg, double penaltyPos);
                        Constraint*                     AddConstraint(double 
coeff1, Variable* var1,
@@ -85,8 +85,8 @@
                        PenaltyFunction*        AddPenaltyFunction(Variable* 
var, BList* xs,
                                                                        BList* 
gs);
 
-                       BList*                          ObjFunction();
-                       void                            SetObjFunction(BList* 
summands);
+                       SummandList*            ObjFunction();
+                       void                            
SetObjFunction(SummandList* summands);
                        void                            UpdateObjFunction();
 
                        ResultType                      Presolve();
@@ -115,7 +115,7 @@
                        lprec*                          fLpPresolved;
                        OptimizationType        fOptimization;
                        lprec*                          fLP;
-                       BList*                          fObjFunction;
+                       SummandList*            fObjFunction;
                        BList                           fVariables;
                        BList                           fConstraints;
                        ResultType                      fResult;

Modified: haiku/trunk/headers/libs/linprog/Summand.h
===================================================================
--- haiku/trunk/headers/libs/linprog/Summand.h  2010-09-20 05:42:31 UTC (rev 
38740)
+++ haiku/trunk/headers/libs/linprog/Summand.h  2010-09-20 06:09:19 UTC (rev 
38741)
@@ -6,7 +6,9 @@
 #ifndef        SUMMAND_H
 #define        SUMMAND_H
 
+#include <ObjectList.h>
 
+
 namespace LinearProgramming {
 
 class LinearSpec;
@@ -31,9 +33,13 @@
                        bool                            fUsedInPenaltyFunction; 
 //not set yet
 };
 
+typedef BObjectList<Summand> SummandList;
+
 }      // namespace LinearProgramming
 
 using LinearProgramming::Summand;
+using LinearProgramming::SummandList;
 
+
 #endif // OBJ_FUNCTION_SUMMAND_H
 

Modified: haiku/trunk/src/libs/alm/Area.cpp
===================================================================
--- haiku/trunk/src/libs/alm/Area.cpp   2010-09-20 05:42:31 UTC (rev 38740)
+++ haiku/trunk/src/libs/alm/Area.cpp   2010-09-20 06:09:19 UTC (rev 38741)
@@ -4,23 +4,25 @@
  * Distributed under the terms of the MIT License.
  */
 
+#include <algorithm>   // for max
+
+#include <Button.h>
+#include <CheckBox.h>
+#include <PictureButton.h>
+#include <RadioButton.h>
+#include <StatusBar.h>
+#include <StringView.h>
+
 #include "Area.h"
+#include "BALMLayout.h"
 #include "Column.h"
-#include "BALMLayout.h"
+#include "Constraint.h"
 #include "OperatorType.h"
 #include "Row.h"
 #include "XTab.h"
 #include "YTab.h"
 
-#include <Button.h>
-#include <RadioButton.h>
-#include <CheckBox.h>
-#include <StringView.h>
-#include <PictureButton.h>
-#include <StatusBar.h>
 
-#include <algorithm>   // for max
-
 using namespace std;
 
 BSize Area::kMaxSize(INT_MAX, INT_MAX);

Modified: haiku/trunk/src/libs/alm/BALMLayout.cpp
===================================================================
--- haiku/trunk/src/libs/alm/BALMLayout.cpp     2010-09-20 05:42:31 UTC (rev 
38740)
+++ haiku/trunk/src/libs/alm/BALMLayout.cpp     2010-09-20 06:09:19 UTC (rev 
38741)
@@ -602,16 +602,16 @@
 BSize
 BALMLayout::CalculateMinSize()
 {
-       BList* oldObjFunction = ObjFunction();
-       BList* newObjFunction = new BList(2);
+       SummandList* oldObjFunction = ObjFunction();
+       SummandList* newObjFunction = new SummandList(2);
        newObjFunction->AddItem(new Summand(1.0, fRight));
        newObjFunction->AddItem(new Summand(1.0, fBottom));
        SetObjFunction(newObjFunction);
        SolveLayout();
        SetObjFunction(oldObjFunction);
        UpdateObjFunction();
-       delete (Summand*)newObjFunction->ItemAt(0);
-       delete (Summand*)newObjFunction->ItemAt(1);
+       delete newObjFunction->ItemAt(0);
+       delete newObjFunction->ItemAt(1);
        delete newObjFunction;
 
        if (Result() == UNBOUNDED)
@@ -631,16 +631,16 @@
 BSize
 BALMLayout::CalculateMaxSize()
 {
-       BList* oldObjFunction = ObjFunction();
-       BList* newObjFunction = new BList(2);
+       SummandList* oldObjFunction = ObjFunction();
+       SummandList* newObjFunction = new SummandList(2);
        newObjFunction->AddItem(new Summand(-1.0, fRight));
        newObjFunction->AddItem(new Summand(-1.0, fBottom));
        SetObjFunction(newObjFunction);
        SolveLayout();
        SetObjFunction(oldObjFunction);
        UpdateObjFunction();
-       delete (Summand*)newObjFunction->ItemAt(0);
-       delete (Summand*)newObjFunction->ItemAt(1);
+       delete newObjFunction->ItemAt(0);
+       delete newObjFunction->ItemAt(1);
        delete newObjFunction;
 
        if (Result() == UNBOUNDED)

Modified: haiku/trunk/src/libs/linprog/Constraint.cpp
===================================================================
--- haiku/trunk/src/libs/linprog/Constraint.cpp 2010-09-20 05:42:31 UTC (rev 
38740)
+++ haiku/trunk/src/libs/linprog/Constraint.cpp 2010-09-20 06:09:19 UTC (rev 
38741)
@@ -43,7 +43,7 @@
  *
  * @return pointer to a BList containing the summands on the left side of the 
constraint
  */
-BList*
+SummandList*
 Constraint::LeftSide()
 {
        return fLeftSide;
@@ -57,7 +57,7 @@
  * @param summands     a BList containing the Summand objects that make up the 
new left side
  */
 void
-Constraint::SetLeftSide(BList* summands)
+Constraint::SetLeftSide(SummandList* summands)
 {
        if (!fIsValid)
                return;
@@ -77,7 +77,7 @@
        int varIndexes[fLeftSide->CountItems() + 2];
        int32 i;
        for (i = 0; i < fLeftSide->CountItems(); i++) {
-               Summand* s = (Summand*)fLeftSide->ItemAt(i);
+               Summand* s = fLeftSide->ItemAt(i);
                coeffs[i] = s->Coeff();
                varIndexes[i] = s->Var()->Index();
        }
@@ -109,7 +109,7 @@
                return;
 
        for (int i=0; i<fLeftSide->CountItems(); i++)
-               delete (Summand*)fLeftSide->ItemAt(i);
+               delete fLeftSide->ItemAt(i);
        fLeftSide->MakeEmpty();
        fLeftSide->AddItem(new Summand(coeff1, var1));
        UpdateLeftSide();
@@ -124,7 +124,7 @@
                return;
 
        for (int i=0; i<fLeftSide->CountItems(); i++)
-               delete (Summand*)fLeftSide->ItemAt(i);
+               delete fLeftSide->ItemAt(i);
        fLeftSide->MakeEmpty();
        fLeftSide->AddItem(new Summand(coeff1, var1));
        fLeftSide->AddItem(new Summand(coeff2, var2));
@@ -141,7 +141,7 @@
                return;
 
        for (int i=0; i<fLeftSide->CountItems(); i++)
-               delete (Summand*)fLeftSide->ItemAt(i);
+               delete fLeftSide->ItemAt(i);
        fLeftSide->MakeEmpty();
        fLeftSide->AddItem(new Summand(coeff1, var1));
        fLeftSide->AddItem(new Summand(coeff2, var2));
@@ -160,7 +160,7 @@
                return;
 
        for (int i=0; i<fLeftSide->CountItems(); i++)
-               delete (Summand*)fLeftSide->ItemAt(i);
+               delete fLeftSide->ItemAt(i);
        fLeftSide->MakeEmpty();
        fLeftSide->AddItem(new Summand(coeff1, var1));
        fLeftSide->AddItem(new Summand(coeff2, var2));
@@ -482,7 +482,7 @@
 /**
  * Constructor.
  */
-Constraint::Constraint(LinearSpec* ls, BList* summands, OperatorType op,
+Constraint::Constraint(LinearSpec* ls, SummandList* summands, OperatorType op,
        double rightSide, double penaltyNeg, double penaltyPos)
        :
        fLS(ls),
@@ -495,7 +495,7 @@
        int varIndexes[summands->CountItems() + 2];
        int32 i;
        for (i = 0; i < summands->CountItems(); i++) {
-               Summand* s = (Summand*)summands->ItemAt(i);
+               Summand* s = summands->ItemAt(i);
                coeffs[i] = s->Coeff();
                varIndexes[i] = s->Var()->Index();
        }

Modified: haiku/trunk/src/libs/linprog/LinearSpec.cpp
===================================================================
--- haiku/trunk/src/libs/linprog/LinearSpec.cpp 2010-09-20 05:42:31 UTC (rev 
38740)
+++ haiku/trunk/src/libs/linprog/LinearSpec.cpp 2010-09-20 06:09:19 UTC (rev 
38741)
@@ -16,7 +16,7 @@
        fCountColumns(0),
        fLpPresolved(NULL),
        fOptimization(MINIMIZE),
-       fObjFunction(new BList()),
+       fObjFunction(new SummandList()),
        fResult(ERROR),
        fObjectiveValue(NAN),
        fSolvingTime(NAN)
@@ -70,7 +70,8 @@
  * @return the new constraint
  */
 Constraint*
-LinearSpec::AddConstraint(BList* summands, OperatorType op, double rightSide)
+LinearSpec::AddConstraint(SummandList* summands, OperatorType op,
+       double rightSide)
 {
        Constraint* c = new Constraint(this, summands, op, rightSide,
                INFINITY, INFINITY);
@@ -92,7 +93,7 @@
 LinearSpec::AddConstraint(double coeff1, Variable* var1,
        OperatorType op, double rightSide)
 {
-       BList* summands = new BList(1);
+       SummandList* summands = new SummandList(1);
        summands->AddItem(new Summand(coeff1, var1));
        Constraint* c = new Constraint(this, summands, op, rightSide,
                INFINITY, INFINITY);
@@ -116,7 +117,7 @@
 LinearSpec::AddConstraint(double coeff1, Variable* var1,
        double coeff2, Variable* var2, OperatorType op, double rightSide)
 {
-       BList* summands = new BList(2);
+       SummandList* summands = new SummandList(2);
        summands->AddItem(new Summand(coeff1, var1));
        summands->AddItem(new Summand(coeff2, var2));
        Constraint* c = new Constraint(this, summands, op, rightSide,
@@ -144,7 +145,7 @@
                double coeff2, Variable* var2, double coeff3, Variable* var3,
                OperatorType op, double rightSide)
 {
-       BList* summands = new BList(3);
+       SummandList* summands = new SummandList(3);
        summands->AddItem(new Summand(coeff1, var1));
        summands->AddItem(new Summand(coeff2, var2));
        summands->AddItem(new Summand(coeff3, var3));
@@ -175,7 +176,7 @@
                double coeff2, Variable* var2, double coeff3, Variable* var3,
                double coeff4, Variable* var4, OperatorType op, double 
rightSide)
 {
-       BList* summands = new BList(3);
+       SummandList* summands = new SummandList(3);
        summands->AddItem(new Summand(coeff1, var1));
        summands->AddItem(new Summand(coeff2, var2));
        summands->AddItem(new Summand(coeff3, var3));
@@ -199,7 +200,7 @@
  * @param penaltyPos   the coefficient penalizing positive deviations from the 
exact solution
  */
 Constraint*
-LinearSpec::AddConstraint(BList* summands, OperatorType op,
+LinearSpec::AddConstraint(SummandList* summands, OperatorType op,
                double rightSide, double penaltyNeg, double penaltyPos)
 {
        Constraint* c = new Constraint(this, summands, op, rightSide,
@@ -223,7 +224,7 @@
 LinearSpec::AddConstraint(double coeff1, Variable* var1,
                OperatorType op, double rightSide, double penaltyNeg, double 
penaltyPos)
 {
-       BList* summands = new BList(1);
+       SummandList* summands = new SummandList(1);
        summands->AddItem(new Summand(coeff1, var1));
        Constraint* c = new Constraint(this, summands, op, rightSide,
                penaltyNeg, penaltyPos);
@@ -249,7 +250,7 @@
        double coeff2, Variable* var2, OperatorType op, double rightSide,
        double penaltyNeg, double penaltyPos)
 {
-       BList* summands = new BList(2);
+       SummandList* summands = new SummandList(2);
        summands->AddItem(new Summand(coeff1, var1));
        summands->AddItem(new Summand(coeff2, var2));
        Constraint* c = new Constraint(this, summands, op, rightSide,
@@ -278,7 +279,7 @@
        double coeff2, Variable* var2, double coeff3, Variable* var3,
        OperatorType op, double rightSide, double penaltyNeg, double penaltyPos)
 {
-       BList* summands = new BList(2);
+       SummandList* summands = new SummandList(2);
        summands->AddItem(new Summand(coeff1, var1));
        summands->AddItem(new Summand(coeff2, var2));
        summands->AddItem(new Summand(coeff3, var3));
@@ -311,7 +312,7 @@
        double coeff4, Variable* var4, OperatorType op, double rightSide,
        double penaltyNeg, double penaltyPos)
 {
-       BList* summands = new BList(2);
+       SummandList* summands = new SummandList(2);
        summands->AddItem(new Summand(coeff1, var1));
        summands->AddItem(new Summand(coeff2, var2));
        summands->AddItem(new Summand(coeff3, var3));
@@ -343,7 +344,7 @@
  *
  * @return BList containing the objective function's summands
  */
-BList*
+SummandList*
 LinearSpec::ObjFunction()
 {
        return fObjFunction;
@@ -357,7 +358,7 @@
  * @param summands     BList containing the objective function's summands
  */
 void
-LinearSpec::SetObjFunction(BList* summands)
+LinearSpec::SetObjFunction(SummandList* summands)
 {
        fObjFunction = summands;
        UpdateObjFunction();

Modified: haiku/trunk/src/libs/linprog/Variable.cpp
===================================================================
--- haiku/trunk/src/libs/linprog/Variable.cpp   2010-09-20 05:42:31 UTC (rev 
38740)
+++ haiku/trunk/src/libs/linprog/Variable.cpp   2010-09-20 06:09:19 UTC (rev 
38741)
@@ -298,9 +298,9 @@
                if (!constraint->IsValid())
                        continue;
 
-               BList* summands = constraint->LeftSide();
+               SummandList* summands = constraint->LeftSide();
                for (int j = 0; j < summands->CountItems(); j++) {
-                       Summand* summand = 
static_cast<Summand*>(summands->ItemAt(j));
+                       Summand* summand = summands->ItemAt(j);
                        if (summand->Var() == this) {
                                markedForInvalidation.AddItem(constraint);
                                break;


Other related posts:

  • » [haiku-commits] r38741 - in haiku/trunk: headers/libs/alm headers/libs/linprog src/libs/alm src/libs/linprog - clemens . zeidler