Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
99dc91eb
Commit
99dc91eb
authored
Jul 08, 2015
by
Chinmay Garde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add bulk remove options
parent
e9335659
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
solver.dart
packages/cassowary/lib/solver.dart
+15
-0
cassowary_test.dart
packages/cassowary/test/cassowary_test.dart
+21
-0
No files found.
packages/cassowary/lib/solver.dart
View file @
99dc91eb
...
...
@@ -59,6 +59,13 @@ class Solver {
return
_optimizeObjectiveRow
(
_objective
);
}
Result
removeConstraints
(
List
<
Constraint
>
constraints
)
{
_SolverBulkUpdate
applier
=
(
Constraint
c
)
=>
removeConstraint
(
c
);
_SolverBulkUpdate
undoer
=
(
Constraint
c
)
=>
addConstraint
(
c
);
return
_bulkEdit
(
constraints
,
applier
,
undoer
);
}
Result
removeConstraint
(
Constraint
constraint
)
{
_Tag
tag
=
_constraints
[
constraint
];
if
(
tag
==
null
)
{
...
...
@@ -129,6 +136,14 @@ class Solver {
return
Result
.
success
;
}
Result
removeEditVariables
(
List
<
Variable
>
variables
)
{
_SolverBulkUpdate
applier
=
(
Variable
v
)
=>
removeEditVariable
(
v
);
_SolverBulkUpdate
undoer
=
(
Variable
v
)
=>
addEditVariable
(
v
,
_edits
[
v
].
constraint
.
priority
);
return
_bulkEdit
(
variables
,
applier
,
undoer
);
}
Result
removeEditVariable
(
Variable
variable
)
{
_EditInfo
info
=
_edits
[
variable
];
if
(
info
==
null
)
{
...
...
packages/cassowary/test/cassowary_test.dart
View file @
99dc91eb
...
...
@@ -603,4 +603,25 @@ void main() {
expect
(
s
.
addEditVariables
(
[
left
.
variable
,
right
.
variable
,
mid
.
variable
],
999.0
),
Result
.
success
);
});
test
(
'bulk_remove_constraints_and_variables'
,
()
{
Solver
s
=
new
Solver
();
var
left
=
new
Param
(
0.0
);
var
right
=
new
Param
(
100.0
);
var
mid
=
new
Param
(
0.0
);
expect
(
s
.
addEditVariables
(
[
left
.
variable
,
right
.
variable
,
mid
.
variable
],
999.0
),
Result
.
success
);
var
c1
=
left
<=
mid
;
var
c2
=
mid
<=
right
;
expect
(
s
.
addConstraints
([
c1
,
c2
]),
Result
.
success
);
expect
(
s
.
removeConstraints
([
c1
,
c2
]),
Result
.
success
);
expect
(
s
.
removeEditVariables
(
[
left
.
variable
,
right
.
variable
,
mid
.
variable
]),
Result
.
success
);
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment