-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
formula helper for variables() and literals() of multiple formuals
- Loading branch information
1 parent
284b3aa
commit 9bc4a74
Showing
6 changed files
with
65 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.logicng.util; | ||
|
||
import org.logicng.formulas.Formula; | ||
import org.logicng.formulas.Literal; | ||
import org.logicng.formulas.Variable; | ||
|
||
import java.util.Collection; | ||
import java.util.SortedSet; | ||
import java.util.TreeSet; | ||
|
||
public class FormulaHelper { | ||
|
||
private FormulaHelper() { | ||
// Intentionally left empty | ||
} | ||
|
||
public static SortedSet<Variable> variables(Formula... formulas) { | ||
SortedSet<Variable> variables = new TreeSet<>(); | ||
for (Formula f : formulas) { | ||
variables.addAll(f.variables()); | ||
} | ||
return variables; | ||
} | ||
|
||
public static SortedSet<Variable> variables(Collection<? extends Formula> formulas) { | ||
SortedSet<Variable> variables = new TreeSet<>(); | ||
for (Formula f : formulas) { | ||
variables.addAll(f.variables()); | ||
} | ||
return variables; | ||
} | ||
|
||
public static SortedSet<Literal> literals(Formula... formulas) { | ||
SortedSet<Literal> literals = new TreeSet<>(); | ||
for (Formula f : formulas) { | ||
literals.addAll(f.literals()); | ||
} | ||
return literals; | ||
} | ||
|
||
public static SortedSet<Literal> literals(Collection<? extends Formula> formulas) { | ||
SortedSet<Literal> literals = new TreeSet<>(); | ||
for (Formula f : formulas) { | ||
literals.addAll(f.literals()); | ||
} | ||
return literals; | ||
} | ||
} |