当前位置: 首页>>代码示例>>Java>>正文


Java Expression.IDEN属性代码示例

本文整理汇总了Java中kodkod.ast.Expression.IDEN属性的典型用法代码示例。如果您正苦于以下问题:Java Expression.IDEN属性的具体用法?Java Expression.IDEN怎么用?Java Expression.IDEN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在kodkod.ast.Expression的用法示例。


在下文中一共展示了Expression.IDEN属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: interpret

/**
 * Returns a {@link kodkod.engine.bool.BooleanMatrix matrix} m of
 * {@link kodkod.engine.bool.BooleanValue boolean formulas} representing the
 * specified constant expression.
 * 
 * @return { m: BooleanMatrix | let dset = [0..this.universe.size()^c.arity)
 *         | m.dimensions.dimensions = [0..c.arity) ->one
 *         this.universe.size() && c = UNIV => m.elements[dset] = TRUE, c =
 *         NONE => m.elements[dset] = FALSE, c = IDEN => (all i: dset |
 *         (some j: int | i = j*(1+this.universe.size())) => m.elements[i] =
 *         TRUE, m.elements[i] = FALSE), c = INT => (all i: dset | (some j:
 *         int | this.interpret(j)=i) => m.elements[i] = TRUE, m.elements[i]
 *         = FALSE }
 */
public final BooleanMatrix interpret(ConstantExpression c) {
	final int univSize = universe().size();
	if (c == Expression.UNIV) {
		final IntSet all = Ints.rangeSet(Ints.range(0, univSize - 1));
		return factory().matrix(Dimensions.square(univSize, 1), all, all);
	} else if (c == Expression.IDEN) {
		final Dimensions dim2 = Dimensions.square(univSize, 2);
		final IntSet iden = Ints.bestSet(dim2.capacity());
		for (int i = 0; i < univSize; i++) {
			iden.add(i * univSize + i);
		}
		return factory().matrix(dim2, iden, iden);
	} else if (c == Expression.NONE) {
		return factory().matrix(Dimensions.square(univSize, 1), Ints.EMPTY_SET, Ints.EMPTY_SET);
	} else if (c == Expression.INTS) {
		final IntSet ints = Ints.bestSet(univSize);
		for (IntIterator iter = ints().iterator(); iter.hasNext();) {
			ints.add(interpret(iter.next()));
		}
		return factory().matrix(Dimensions.square(univSize, 1), ints, ints);
	} else {
		throw new IllegalArgumentException("unknown constant expression: " + c);
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:38,代码来源:LeafInterpreter.java

示例2: visit

/** {@inheritDoc} */
public void visit(ConstantExpression x) {
	if (map.containsKey(x))
		return;
	String newname = null;
	if (x == Expression.NONE)
		newname = "Expression.NONE";
	else if (x == Expression.UNIV)
		newname = "Expression.UNIV";
	else if (x == Expression.IDEN)
		newname = "Expression.IDEN";
	else if (x == Expression.INTS)
		newname = "Expression.INTS";
	else
		throw new RuntimeException("Unknown kodkod ConstantExpression \"" + x + "\" encountered");
	map.put(x, newname);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:17,代码来源:TranslateKodkodToJava.java

示例3: interpret

/**
 * Returns a {@link kodkod.engine.bool.BooleanMatrix matrix} m of 
 * {@link kodkod.engine.bool.BooleanValue boolean formulas} representing
 * the specified constant expression.    
 * @return { m: BooleanMatrix | let dset = [0..this.universe.size()^c.arity) | 
 *           m.dimensions.dimensions = [0..c.arity) ->one this.universe.size() && 
 *           c = UNIV => m.elements[dset] = TRUE, c = NONE => m.elements[dset] = FALSE,
 *           c = IDEN => (all i: dset | (some j: int | i = j*(1+this.universe.size())) => m.elements[i] = TRUE, m.elements[i] = FALSE),
 *           c = INT => (all i: dset | (some j: int | this.interpret(j)=i) => m.elements[i] = TRUE, m.elements[i] = FALSE }
 */
public final BooleanMatrix interpret(ConstantExpression c) {
	final int univSize = universe().size();
	if (c==Expression.UNIV) {
		final IntSet all =  Ints.rangeSet(Ints.range(0, univSize-1));
		return factory().matrix(Dimensions.square(univSize, 1), all, all);
	} else if (c==Expression.IDEN) {
		final Dimensions dim2 = Dimensions.square(univSize, 2);
		final IntSet iden = Ints.bestSet(dim2.capacity());
		for(int i = 0; i < univSize; i++) {
			iden.add(i*univSize + i);
		}			
		return factory().matrix(dim2, iden, iden);
	} else if (c==Expression.NONE) {
		return factory().matrix(Dimensions.square(univSize, 1), Ints.EMPTY_SET, Ints.EMPTY_SET);
	} else if (c==Expression.INTS) {
		final IntSet ints = Ints.bestSet(univSize);
		for(IntIterator iter = ints().iterator(); iter.hasNext(); ) {
			ints.add(interpret(iter.next()));
		}
		return factory().matrix(Dimensions.square(univSize, 1), ints, ints);
	} else {
		throw new IllegalArgumentException("unknown constant expression: " + c);
	}
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:34,代码来源:LeafInterpreter.java

示例4: visit

/** {@inheritDoc} */
public void visit(ConstantExpression x) {
    if (map.containsKey(x)) return;
    String newname=null;
    if (x==Expression.NONE) newname="Expression.NONE";
       else if (x==Expression.UNIV) newname="Expression.UNIV";
       else if (x==Expression.IDEN) newname="Expression.IDEN";
       else if (x==Expression.INTS) newname="Expression.INTS";
       else throw new RuntimeException("Unknown kodkod ConstantExpression \""+x+"\" encountered");
    map.put(x,newname);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:11,代码来源:TranslateKodkodToJava.java


注:本文中的kodkod.ast.Expression.IDEN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。