本文整理汇总了Java中edu.mit.csail.sdg.alloy4.Pair类的典型用法代码示例。如果您正苦于以下问题:Java Pair类的具体用法?Java Pair怎么用?Java Pair使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Pair类属于edu.mit.csail.sdg.alloy4包,在下文中一共展示了Pair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: highLevelCore
import edu.mit.csail.sdg.alloy4.Pair; //导入依赖的package包/类
/**
* If this solution is unsatisfiable and its unsat core is available, then
* return the core; else return an empty set.
*/
public Pair<Set<Pos>,Set<Pos>> highLevelCore() {
if (hCoreCache != null)
return hCoreCache;
Set<Pos> ans1 = new LinkedHashSet<Pos>(), ans2 = new LinkedHashSet<Pos>();
if (hCore != null)
for (Node f : hCore) {
Object x = k2pos(f);
if (x instanceof Pos) {
// System.out.println("F: "+f+" at "+x+"\n");
// System.out.flush();
ans1.add((Pos) x);
} else if (x instanceof Expr) {
Expr expr = (Expr) x;
Pos p = ((Expr) x).span();
ans1.add(p);
// System.out.println("F: "+f+" by
// "+p.x+","+p.y+"->"+p.x2+","+p.y2+" for "+x+"\n\n");
// System.out.flush();
for (Func func : expr.findAllFunctions())
ans2.add(func.getBody().span());
}
}
return hCoreCache = new Pair<Set<Pos>,Set<Pos>>(Collections.unmodifiableSet(ans1),
Collections.unmodifiableSet(ans2));
}
示例2: convertValueToText
import edu.mit.csail.sdg.alloy4.Pair; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public String convertValueToText(Object val, boolean selected, boolean expanded, boolean leaf, int row, boolean focus) {
String c = ">";
if (onWindows) c = selected ? " style=\"color:#ffffff;\">" : " style=\"color:#000000;\">";
if (val instanceof A4Solution) return "<html> <b" + c + encode(title==null ? "" : title)+"</b></html>";
if (val instanceof Sig) {
String label = ((Sig)val).label;
if (label.startsWith("this/")) label = label.substring(5);
return "<html> <b" + c + "sig " + encode(label) + "</b></html>";
}
if (val instanceof ExprVar) return "<html> <b" + c + "set " + encode(((ExprVar)val).label) + "</b></html>";
if (val instanceof String) return "<html> <span" + c + encode((String)val) + "</span></html>";
if (val instanceof Pair) return "<html> <b" + c + "field " + encode(((ExprHasName)(((Pair<?,?>)val).b)).label) + "</b></html>";
if (val instanceof A4Tuple) {
StringBuilder sb = new StringBuilder("<html> <span" + c);
A4Tuple tp = (A4Tuple) val;
for(int i=1; i<tp.arity(); i++) {
if (i>1) sb.append(" -> ");
sb.append(encode(tp.atom(i)));
}
sb.append("</span></html>");
return sb.toString();
}
return "";
}
示例3: highLevelCore
import edu.mit.csail.sdg.alloy4.Pair; //导入依赖的package包/类
/** If this solution is unsatisfiable and its unsat core is available, then return the core; else return an empty set. */
public Pair<Set<Pos>,Set<Pos>> highLevelCore() {
if (hCoreCache!=null) return hCoreCache;
Set<Pos> ans1 = new LinkedHashSet<Pos>(), ans2 = new LinkedHashSet<Pos>();
if (hCore!=null) for(Node f: hCore) {
Object x = k2pos(f);
if (x instanceof Pos) {
// System.out.println("F: "+f+" at "+x+"\n"); System.out.flush();
ans1.add((Pos)x);
} else if (x instanceof Expr) {
Expr expr = (Expr)x;
Pos p = ((Expr)x).span();
ans1.add(p);
// System.out.println("F: "+f+" by "+p.x+","+p.y+"->"+p.x2+","+p.y2+" for "+x+"\n\n"); System.out.flush();
for(Func func: expr.findAllFunctions()) ans2.add(func.getBody().span());
}
}
return hCoreCache = new Pair<Set<Pos>,Set<Pos>>(Collections.unmodifiableSet(ans1), Collections.unmodifiableSet(ans2));
}
示例4: convertValueToText
import edu.mit.csail.sdg.alloy4.Pair; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public String convertValueToText(Object val, boolean selected, boolean expanded, boolean leaf, int row,
boolean focus) {
String c = ">";
if (onWindows)
c = selected ? " style=\"color:#ffffff;\">" : " style=\"color:#000000;\">";
if (val instanceof A4Solution)
return "<html> <b" + c + encode(title == null ? "" : title) + "</b></html>";
if (val instanceof Sig) {
String label = ((Sig) val).label;
if (label.startsWith("this/"))
label = label.substring(5);
return "<html> <b" + c + "sig " + encode(label) + "</b></html>";
}
if (val instanceof ExprVar)
return "<html> <b" + c + "set " + encode(((ExprVar) val).label) + "</b></html>";
if (val instanceof String)
return "<html> <span" + c + encode((String) val) + "</span></html>";
if (val instanceof Pair)
return "<html> <b" + c + "field " + encode(((ExprHasName) (((Pair< ? , ? >) val).b)).label) + "</b></html>";
if (val instanceof A4Tuple) {
StringBuilder sb = new StringBuilder("<html> <span" + c);
A4Tuple tp = (A4Tuple) val;
for (int i = 1; i < tp.arity(); i++) {
if (i > 1)
sb.append(" -> ");
sb.append(encode(tp.atom(i)));
}
sb.append("</span></html>");
return sb.toString();
}
return "";
}
示例5: getAllAssertions
import edu.mit.csail.sdg.alloy4.Pair; //导入依赖的package包/类
/** Return an unmodifiable list of all assertions in this module. */
public ConstList<Pair<String,Expr>> getAllAssertions() {
TempList<Pair<String,Expr>> ans = new TempList<Pair<String,Expr>>(asserts.size());
for (Map.Entry<String,Expr> e : asserts.entrySet()) {
ans.add(new Pair<String,Expr>(e.getKey(), e.getValue()));
}
return ans.makeConst();
}
示例6: addFact
import edu.mit.csail.sdg.alloy4.Pair; //导入依赖的package包/类
/** Add a FACT declaration. */
void addFact(Pos pos, String name, Expr value) throws Err {
status = 3;
if (name == null || name.length() == 0)
name = "fact$" + (1 + facts.size());
facts.add(new Pair<String,Expr>(name, ExprUnary.Op.NOOP.make(value.span().merge(pos), value)));
}
示例7: resolveFacts
import edu.mit.csail.sdg.alloy4.Pair; //导入依赖的package包/类
/**
* Each fact name now points to a typechecked Expr rather than an
* untypechecked Exp; we'll also add the sig appended facts.
*/
private JoinableList<Err> resolveFacts(CompModule res, A4Reporter rep, JoinableList<Err> errors,
List<ErrorWarning> warns) throws Err {
Context cx = new Context(this, warns);
for (int i = 0; i < facts.size(); i++) {
String name = facts.get(i).a;
Expr expr = facts.get(i).b;
Expr checked = cx.check(expr);
expr = checked.resolve_as_formula(warns);
if (expr.errors.isEmpty()) {
facts.set(i, new Pair<String,Expr>(name, expr));
rep.typecheck("Fact " + name + ": " + expr.type() + "\n");
} else
errors = errors.make(expr.errors);
}
for (Sig s : sigs.values()) {
Expr f = res.old2appendedfacts.get(res.new2old.get(s));
if (f == null)
continue;
if (f instanceof ExprConstant && ((ExprConstant) f).op == ExprConstant.Op.TRUE)
continue;
Expr formula;
cx.rootsig = s;
if (s.isOne == null) {
cx.put("this", s.decl.get());
formula = cx.check(f).resolve_as_formula(warns);
} else {
cx.put("this", s);
formula = cx.check(f).resolve_as_formula(warns);
}
cx.remove("this");
if (formula.errors.size() > 0)
errors = errors.make(formula.errors);
else {
s.addFact(formula);
rep.typecheck("Fact " + s + "$fact: " + formula.type() + "\n");
}
}
return errors;
}
示例8: getAllReachableFacts
import edu.mit.csail.sdg.alloy4.Pair; //导入依赖的package包/类
/**
* Return the conjunction of all facts in this module and all reachable
* submodules (not including field constraints, nor including sig appended
* constraints)
*/
public Expr getAllReachableFacts() {
ArrayList<Expr> facts = new ArrayList<Expr>();
for (CompModule m : world.getAllReachableModules())
for (Pair<String,Expr> f : m.facts)
facts.add(f.b);
if (facts.size() == 0)
return ExprConstant.TRUE;
else
return ExprList.make(null, null, ExprList.Op.AND, facts);
}
示例9: kv2typepos
import edu.mit.csail.sdg.alloy4.Pair; //导入依赖的package包/类
/**
* Maps a Kodkod variable to an Alloy Type and Alloy Pos (if no association
* exists, it will return (Type.EMPTY , Pos.UNKNOWN)
*/
Pair<Type,Pos> kv2typepos(Variable var) {
Pair<Type,Pos> ans = decl2type.get(var);
if (ans != null)
return ans;
if (cachedPAIR == null)
cachedPAIR = new Pair<Type,Pos>(Type.EMPTY, Pos.UNKNOWN);
return cachedPAIR;
}
示例10: TranslateAlloyToKodkod
import edu.mit.csail.sdg.alloy4.Pair; //导入依赖的package包/类
/**
* Construct a translator based on the given list of sigs and the given
* command.
*
* @param rep - if nonnull, it's the reporter that will receive diagnostics
* and progress reports
* @param opt - the solving options (must not be null)
* @param sigs - the list of sigs (must not be null, and must be a complete
* list)
* @param cmd - the command to solve (must not be null)
*/
private TranslateAlloyToKodkod(A4Reporter rep, A4Options opt, Iterable<Sig> sigs, Command cmd) throws Err {
this.unrolls = opt.unrolls;
this.rep = (rep != null) ? rep : A4Reporter.NOP;
this.cmd = cmd;
Pair<A4Solution,ScopeComputer> pair = ScopeComputer.compute(this.rep, opt, sigs, cmd);
this.frame = pair.a;
this.bitwidth = pair.a.getBitwidth();
this.min = pair.a.min();
this.max = pair.a.max();
this.a2k = null;
this.s2k = null;
BoundsComputer.compute(rep, frame, pair.b, sigs);
}
示例11: getAllAssertions
import edu.mit.csail.sdg.alloy4.Pair; //导入依赖的package包/类
/** Return an unmodifiable list of all assertions in this module. */
public ConstList<Pair<String,Expr>> getAllAssertions() {
TempList<Pair<String,Expr>> ans = new TempList<Pair<String,Expr>>(asserts.size());
for(Map.Entry<String,Expr> e: asserts.entrySet()) {
ans.add(new Pair<String,Expr>(e.getKey(), e.getValue()));
}
return ans.makeConst();
}
示例12: resolveFacts
import edu.mit.csail.sdg.alloy4.Pair; //导入依赖的package包/类
/** Each fact name now points to a typechecked Expr rather than an untypechecked Exp; we'll also add the sig appended facts. */
private JoinableList<Err> resolveFacts(CompModule res, A4Reporter rep, JoinableList<Err> errors, List<ErrorWarning> warns) throws Err {
Context cx = new Context(this, warns);
for(int i=0; i<facts.size(); i++) {
String name = facts.get(i).a;
Expr expr = facts.get(i).b;
expr = cx.check(expr).resolve_as_formula(warns);
if (expr.errors.isEmpty()) {
facts.set(i, new Pair<String,Expr>(name, expr));
rep.typecheck("Fact " + name + ": " + expr.type()+"\n");
} else errors = errors.make(expr.errors);
}
for(Sig s: sigs.values()) {
Expr f = res.old2appendedfacts.get(res.new2old.get(s));
if (f == null) continue;
if (f instanceof ExprConstant && ((ExprConstant)f).op==ExprConstant.Op.TRUE) continue;
Expr formula;
cx.rootsig = s;
if (s.isOne==null) {
cx.put("this", s.decl.get());
formula = cx.check(f).resolve_as_formula(warns);
} else {
cx.put("this", s);
formula = cx.check(f).resolve_as_formula(warns);
}
cx.remove("this");
if (formula.errors.size()>0) errors = errors.make(formula.errors); else { s.addFact(formula); rep.typecheck("Fact "+s+"$fact: " + formula.type()+"\n"); }
}
return errors;
}
示例13: kv2typepos
import edu.mit.csail.sdg.alloy4.Pair; //导入依赖的package包/类
/** Maps a Kodkod variable to an Alloy Type and Alloy Pos (if no association exists, it will return (Type.EMPTY , Pos.UNKNOWN) */
Pair<Type,Pos> kv2typepos(Variable var) {
Pair<Type,Pos> ans=decl2type.get(var);
if (ans!=null) return ans;
if (cachedPAIR==null) cachedPAIR=new Pair<Type,Pos>(Type.EMPTY, Pos.UNKNOWN);
return cachedPAIR;
}
示例14: TranslateAlloyToKodkod
import edu.mit.csail.sdg.alloy4.Pair; //导入依赖的package包/类
/** Construct a translator based on the given list of sigs and the given command.
* @param rep - if nonnull, it's the reporter that will receive diagnostics and progress reports
* @param opt - the solving options (must not be null)
* @param sigs - the list of sigs (must not be null, and must be a complete list)
* @param cmd - the command to solve (must not be null)
*/
private TranslateAlloyToKodkod (A4Reporter rep, A4Options opt, Iterable<Sig> sigs, Command cmd) throws Err {
this.unrolls = opt.unrolls;
this.rep = (rep != null) ? rep : A4Reporter.NOP;
this.cmd = cmd;
Pair<A4Solution, ScopeComputer> pair = ScopeComputer.compute(this.rep, opt, sigs, cmd);
this.frame = pair.a;
this.bitwidth = pair.a.getBitwidth();
this.min = pair.a.min();
this.max = pair.a.max();
this.a2k = null;
this.s2k = null;
BoundsComputer.compute(rep, frame, pair.b, sigs);
}
示例15: getAllFacts
import edu.mit.csail.sdg.alloy4.Pair; //导入依赖的package包/类
/** Return an unmodifiable list of all facts in this module. */
public SafeList<Pair<String,Expr>> getAllFacts() {
return (new SafeList<Pair<String,Expr>>(facts)).dup();
}