本文整理汇总了Java中kodkod.instance.Tuple.arity方法的典型用法代码示例。如果您正苦于以下问题:Java Tuple.arity方法的具体用法?Java Tuple.arity怎么用?Java Tuple.arity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kodkod.instance.Tuple
的用法示例。
在下文中一共展示了Tuple.arity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseTuple
import kodkod.instance.Tuple; //导入方法依赖的package包/类
/** Parse tuple. */
private Tuple parseTuple(XMLNode tuple, int arity) throws Err {
Tuple ans = null;
try {
for (XMLNode sub : tuple)
if (sub.is("atom")) {
Tuple x = factory.tuple(sub.getAttribute("label"));
if (ans == null)
ans = x;
else
ans = ans.product(x);
}
if (ans == null)
throw new ErrorFatal("Expecting: <tuple> <atom label=\"..\"/> .. </tuple>");
if (ans.arity() != arity)
throw new ErrorFatal("Expecting: tuple of arity " + arity + " but got tuple of arity " + ans.arity());
return ans;
} catch (Throwable ex) {
throw new ErrorFatal("Expecting: <tuple> <atom label=\"..\"/> .. </tuple>", ex);
}
}
示例2: convert
import kodkod.instance.Tuple; //导入方法依赖的package包/类
private TupleSet convert(TupleFactory factory, Expr f) throws Err {
TupleSet old = ((A4TupleSet) (partial.eval(f))).debugGetKodkodTupleset();
TupleSet ans = factory.noneOf(old.arity());
for (Tuple oldT : old) {
Tuple newT = null;
for (int i = 0; i < oldT.arity(); i++) {
if (newT == null)
newT = factory.tuple(oldT.atom(i));
else
newT = newT.product(factory.tuple(oldT.atom(i)));
}
ans.add(newT);
}
return ans;
}
示例3: parseTuple
import kodkod.instance.Tuple; //导入方法依赖的package包/类
/** Parse tuple. */
private Tuple parseTuple(XMLNode tuple, int arity) throws Err {
Tuple ans = null;
try {
for(XMLNode sub:tuple) if (sub.is("atom")) {
Tuple x = factory.tuple(sub.getAttribute("label"));
if (ans==null) ans=x; else ans=ans.product(x);
}
if (ans==null) throw new ErrorFatal("Expecting: <tuple> <atom label=\"..\"/> .. </tuple>");
if (ans.arity()!=arity) throw new ErrorFatal("Expecting: tuple of arity "+arity+" but got tuple of arity "+ans.arity());
return ans;
} catch(Throwable ex) {
throw new ErrorFatal("Expecting: <tuple> <atom label=\"..\"/> .. </tuple>", ex);
}
}
示例4: convert
import kodkod.instance.Tuple; //导入方法依赖的package包/类
private TupleSet convert(TupleFactory factory, Expr f) throws Err {
TupleSet old = ((A4TupleSet) (partial.eval(f))).debugGetKodkodTupleset();
TupleSet ans = factory.noneOf(old.arity());
for(Tuple oldT: old) {
Tuple newT = null;
for(int i=0; i<oldT.arity(); i++) {
if (newT==null) newT=factory.tuple(oldT.atom(i)); else newT=newT.product(factory.tuple(oldT.atom(i)));
}
ans.add(newT);
}
return ans;
}
示例5: join
import kodkod.instance.Tuple; //导入方法依赖的package包/类
public static TupleSet join(TupleSet ts1, TupleSet ts2, TupleFactory f) {
int arity = ts1.arity() + ts2.arity() - 2;
TupleSet result = f.noneOf(arity);
for (Tuple t1 : ts1)
for (Tuple t2 : ts2)
if (t1.atom(t1.arity() - 1) == t2.atom(0)) {
Object[] atoms = new Object[arity];
for (int i = 0; i < t1.arity() - 1; i++) atoms[i] = t1.atom(i);
for (int i = 1; i < t2.arity(); i++) atoms[t1.arity() + i - 2] = t2.atom(i);
result.add(f.tuple(atoms));
}
return result;
}