3 #include <cassowary/Cl.h>
5 /* This bug fixed --02/15/99 gjb
6 Replaced the parallel vectors for edit constraints
7 (the errorPlus..., errorMinus..., prevEditConstants vectors)
8 with a ClEditInfo class that is the Value of the _editVarMap map.
10 Later I realized that I need to go to a _editVars list so that
11 multiple edits on the same variable that nest are handled properly.
17 ClSimplexSolver solver;
34 solver.SuggestValue(x,1);
35 solver.SuggestValue(z,2);
37 solver.RemoveEditVar(y);
39 solver.SuggestValue(x,3);
40 solver.SuggestValue(z,4);
44 } catch (ExCLError &e) {
45 cerr << e.description() << endl;
48 cout << x << endl << y << endl << z <<endl;
52 #if 0 /* Message below */
53 From: "Michael Kaufmann" <Michael.Kaufmann@ubs.com>
54 To: <noth@cs.washington.edu>
56 Date: Thu, 1 Oct 1998 11:40:55 +0200
57 Message-Id: <000001bded1f$973a2060$230e1fac@itc_mk.sbcs.swissbank.com>
59 Content-Type: text/plain;
61 Content-Transfer-Encoding: 7bit
62 X-Priority: 3 (Normal)
63 X-Msmail-Priority: Normal
64 X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0
66 X-Mimeole: Produced By Microsoft MimeOLE V4.72.2106.4
70 I am currently working with the Java implementation of Cassowary and found
73 If I Add several editConstraints, remove some of them again later and
74 perform a 'ClSimplexSolver.SuggestValue()', the indices of
75 'ClConstraintAndIndex' in the variable 'cai' are sometimes wrong (see
76 ClSimplexSolver.SuggestValue(ClVariable v, double x), the 3rd line). This is
77 because if you remove an element from a 'java.util.Vector', and the element
78 is somewhere in the middle of the Vector, the indices of the Vector change.
79 (see java.util.Vector.removeElementAt(int index):
81 public final synchronized void removeElementAt(int index) {
82 if (index >= elementCount) {
83 throw new ArrayIndexOutOfBoundsException(index + " >= " +
87 throw new ArrayIndexOutOfBoundsException(index);
89 int j = elementCount - index - 1;
91 System.arraycopy(elementData, index + 1, elementData, index, j);
94 elementData[elementCount] = null; /* to let gc do its work */
98 My workaround now is, that everytime when I remove an EditVariable from the
99 Solver, I have to remove all the EditVariables and Add then the ones again,
100 that I do not want to remove.