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


Java TempList类代码示例

本文整理汇总了Java中edu.mit.csail.sdg.alloy4.ConstList.TempList的典型用法代码示例。如果您正苦于以下问题:Java TempList类的具体用法?Java TempList怎么用?Java TempList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: union

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入依赖的package包/类
/**
 * Return the union of this and that; (if this tupleset and that tupleset
 * does not have compatible arity, then we return this tupleset as is).
 * <br/>
 * Note: the tuples in the result will be ordered as follows: first comes
 * the tuples in "this" in original order, then the tuples that are in
 * "that" but not in "this".
 */
public SimTupleset union(SimTupleset that) {
	if (this.empty() || this == that)
		return that;
	if (that.empty() || arity() != that.arity())
		return this;
	TempList<SimTuple> ans = null; // when null, it means we haven't found
									// any new tuple to add yet
	for (SimTuple x : that)
		if (!has(x)) {
			if (ans == null)
				ans = new TempList<SimTuple>(tuples);
			ans.add(x);
		}
	return ans == null ? this : new SimTupleset(ans.makeConst(), min, max, next);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:24,代码来源:SimTupleset.java

示例2: join

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入依赖的package包/类
/**
 * Return the relational join between this and that (throws ErrorType if
 * this.arity==1 and that.arity==1)
 */
public SimTupleset join(SimTupleset that) throws ErrorType {
	if (empty() || that.empty())
		return EMPTY;
	if (arity() == 1 && that.arity() == 1)
		throw new ErrorType("Cannot join two unary relations.");
	TempList<SimTuple> ans = new TempList<SimTuple>();
	for (SimTuple a : this)
		for (SimTuple b : that)
			if (a.tail() == b.head()) {
				SimTuple c = a.join(b);
				if (!ans.contains(c))
					ans.add(c);
			}
	return ans.size() == 0 ? EMPTY : new SimTupleset(ans.makeConst());
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:20,代码来源:SimTupleset.java

示例3: resolve

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public Expr resolve(Type t, Collection<ErrorWarning> warns) {
    if (errors.size()>0) return this;
    TempList<Expr> args = new TempList<Expr>(this.args.size());
    boolean changed = false;
    for(int i=0; i<this.args.size(); i++) {
        Type p = fun.get(i).type;
        Expr x = this.args.get(i);
        Expr y = x.resolve(p, warns).typecheck_as_set(); // Use the function's param type to narrow down the choices
        if (x!=y) changed=true;
        args.add(y);
        // if (warns!=null && Version.experimental && !y.type.isSubtypeOf(p))
        //    warns.add(new ErrorWarning(x.span(), "This argument may contain a tuple not in the parameter's type.\n"
        //    +"The Alloy Analyzer's analysis may be unsound\n"
        //    +"if the argument has a tuple outside the parameter's type.\n"
        //    +"The argument has type "+y.type+"\nbut the parameter has type "+p));
    }
    return changed ? make(pos, closingBracket, fun, args.makeConst(), extraWeight) : this;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:20,代码来源:ExprCall.java

示例4: getSubnodes

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public final List< ? extends Browsable> getSubnodes() {
	TempList<Browsable> ans = new TempList<Browsable>();
	if (this instanceof PrimSig) {
		Sig parent = ((PrimSig) this).parent;
		if (parent != null && !parent.builtin)
			ans.add(make(parent.pos, parent.span(), "<b>extends sig</b> " + parent.label, parent.getSubnodes()));
	} else {
		ConstList<Sig> parents = ((SubsetSig) this).parents;
		for (Sig p : parents)
			ans.add(make(p.pos, p.span(), "<b>in sig</b> " + p.label, p.getSubnodes()));
	}
	for (Decl d : fields)
		for (ExprHasName v : d.names) {
			ans.add(make(v.span(), v.span(), "<b>field</b> " + v.label + " <i>" + v.type + "</i>", d.expr));
		}
	for (Expr f : facts)
		ans.add(make(f.span(), f.span(), "<b>fact</b>", f));
	return ans.makeConst();
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:22,代码来源:Sig.java

示例5: add

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入依赖的package包/类
/**
 * Merge "x" into the set of entries, then return the new arity bitmask.
 * <br>
 * Precondition: entries and arities are consistent
 */
private static int add(TempList<ProductType> entries, int arities, ProductType x) {
	if (x == null || x.types.length == 0)
		return arities;
	final int arity = x.types.length;
	// If x is subsumed by a ProductType in this, return. Likewise, remove
	// all entries in this that are subsumed by x.
	for (int n = entries.size(), i = n - 1; i >= 0; i--) {
		ProductType y = entries.get(i);
		if (y.types.length != arity)
			continue;
		if (x.isSubtypeOf(y))
			return arities;
		if (y.isSubtypeOf(x)) {
			n--;
			entries.set(i, entries.get(n)).remove(n);
		}
	}
	if (arity > 30)
		arities = arities | 1;
	else
		arities = arities | (1 << arity);
	entries.add(x);
	return arities;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:30,代码来源:Type.java

示例6: getSubnodes

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public final List<? extends Browsable> getSubnodes() {
   TempList<Browsable> ans = new TempList<Browsable>();
   if (this instanceof PrimSig) {
      Sig parent = ((PrimSig)this).parent;
      if (parent!=null && !parent.builtin) ans.add(make(parent.pos, parent.span(), "<b>extends sig</b> " + parent.label, parent.getSubnodes()));
   } else {
      ConstList<Sig> parents = ((SubsetSig)this).parents;
      for(Sig p: parents) ans.add(make(p.pos, p.span(), "<b>in sig</b> " + p.label, p.getSubnodes()));
   }
   for(Decl d: fields) for(ExprHasName v: d.names) {
      ans.add(make(v.span(), v.span(), "<b>field</b> " + v.label + " <i>" + v.type + "</i>", d.expr));
   }
   for(Expr f: facts) ans.add(make(f.span(), f.span(), "<b>fact</b>", f));
   return ans.makeConst();
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:17,代码来源:Sig.java

示例7: merge

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入依赖的package包/类
/**
 * Returns a new type { A | A is in this, or A == that }
 * <p>
 * ReturnValue.is_int == this.is_int <br>
 * ReturnValue.is_bool == this.is_bool
 */
public Type merge(List<PrimSig> that) {
	if (that.size() == 0)
		return this;
	PrimSig[] array = new PrimSig[that.size()];
	for (int i = 0; i < array.length; i++) {
		array[i] = that.get(i);
		if (array[i] == NONE) {
			if (hasArity(array.length))
				return this;
			for (i = 0; i < array.length; i++)
				array[i] = NONE;
			break;
		}
	}
	TempList<ProductType> ee = new TempList<ProductType>(entries);
	int aa = add(ee, arities, new ProductType(array));
	return make(is_bool, ee.makeConst(), aa);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:25,代码来源:Type.java

示例8: addAND

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入依赖的package包/类
/**
 * Add expr to list, in a way that flattens the conjunctions as much as
 * possible (for better unsat core).
 */
private static void addAND(TempList<Expr> list, Expr expr) {
	Expr x = expr.deNOP();
	if (x.isSame(ExprConstant.TRUE))
		return;
	if (x instanceof ExprBinary && ((ExprBinary) x).op == ExprBinary.Op.AND) {
		addAND(list, ((ExprBinary) x).left);
		addAND(list, ((ExprBinary) x).right);
		return;
	}
	if (x instanceof ExprList && ((ExprList) x).op == ExprList.Op.AND) {
		for (Expr y : ((ExprList) x).args)
			addAND(list, y);
		return;
	}
	list.add(expr);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:21,代码来源:ExprList.java

示例9: addOR

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入依赖的package包/类
/**
 * Add expr to list, in a way that flattens the disjunctions as much as
 * possible (for better unsat core).
 */
private static void addOR(TempList<Expr> list, Expr expr) {
	Expr x = expr.deNOP();
	if (x.isSame(ExprConstant.FALSE))
		return;
	if (x instanceof ExprBinary && ((ExprBinary) x).op == ExprBinary.Op.OR) {
		addOR(list, ((ExprBinary) x).left);
		addOR(list, ((ExprBinary) x).right);
		return;
	}
	if (x instanceof ExprList && ((ExprList) x).op == ExprList.Op.OR) {
		for (Expr y : ((ExprList) x).args)
			addOR(list, y);
		return;
	}
	list.add(expr);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:21,代码来源:ExprList.java

示例10: override

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入依赖的package包/类
/** Return the relational override of this and that; (if this tupleset and that tuple does not have compatible arity, then we return this tupleset as is).
 * <br/> Note: in general, the tuples may be ordered arbitrarily in the result.
 * <br/> Note: if this operation is a no-op, we guarantee we'll return this SimTupleset as is.
 */
public SimTupleset override(final SimTuple that) {
    if (arity()==1) return union(that);
    if (empty()) return SimTupleset.make(that);
    if (arity()!=that.arity()) return this;
    boolean added = false, same = false;
    TempList<SimTuple> ans = new TempList<SimTuple>(size());
    SimAtom head = that.get(0);
    for(SimTuple x: this) {
       if (x.get(0)!=head) { ans.add(x); continue; }
       if (x.equals(that)) same = true;
       if (!added) { ans.add(that); added=true; }
    }
    if (!added) ans.add(that); else if (same && longsize()==ans.size()) return this;
    return new SimTupleset(ans.makeConst());
 }
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:20,代码来源:SimTupleset.java

示例11: closure

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入依赖的package包/类
/** Returns the closure of this tupleset (NOTE: if this.arity!=2, we will return an empty set) */
public SimTupleset closure() {
   if (arity()!=2) return EMPTY;
   TempList<SimTuple> ar = new TempList<SimTuple>(size());
   ar.addAll(this);
   while(true) {
      int n = ar.size();
      for(int i=0; i<n; i++) {
         SimTuple left = ar.get(i);
         if (left.head()==left.tail()) continue;      // whatever "right" is, "left.right" won't add any new tuple to the final answer
         for(int j=0; j<n; j++) if (i!=j) {           // whatever "left" is,  "left.left"  won't add any new tuple to the final answer
            SimTuple right = ar.get(j);
            if (right.head()==right.tail()) continue; // whatever "left" is,  "left.right" won't add any new tuple to the final answer
            if (left.tail()==right.head() && find(ar, left.head(), right.tail())<0) ar.add(SimTuple.make(left.head(), right.tail()));
         }
      }
      if (n == ar.size()) return ar.size()==longsize() ? this : new SimTupleset(ar.makeConst()); // if we went through the loop without making any change, we're done
   }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:20,代码来源:SimTupleset.java

示例12: setOf

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入依赖的package包/类
/** Return an iterator over all subset x of this */
public Iterator<SimTupleset> setOf() {
    if (longsize() > Integer.MAX_VALUE) throw new OutOfMemoryError();
    return new Iterator<SimTupleset>() {
        private boolean in[] = new boolean[size()]; // indicates whether each tuple should appear in the upcoming tupleset; if null, it means no more results
        public SimTupleset next() {
            if (in==null) throw new NoSuchElementException();
            TempList<SimTuple> ans = new TempList<SimTuple>();
            for(int i=0; i<in.length; i++) if (in[i]) ans.add(get(i));
            for(int i=0; ; i++) if (i==in.length) {in=null;break;} else if (!in[i]) {in[i]=true; break;} else {in[i]=false;}
            return new SimTupleset(ans.makeConst());
        }
        public boolean hasNext() { return in!=null; }
        public void remove() { throw new UnsupportedOperationException(); }
    };
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:17,代码来源:SimTupleset.java

示例13: getSubTypes

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入依赖的package包/类
/**
 * Returns a sorted, unmodifiable list of types that are direct or indirect
 * subtypes of the given type. <br>
 * This method will search recursively, so if the subtypes themselves have
 * subtypes, they too are included. <br>
 * If type==null, or it does not exist in this model, or it has no subsigs,
 * then we return an empty set.
 */
public ConstList<AlloyType> getSubTypes(AlloyType type) {
	TempList<AlloyType> subtypes = new TempList<AlloyType>();
	for (AlloyType subType : types)
		if (isSubtype(subType, type))
			subtypes.add(subType);
	return subtypes.makeConst(); // Since this.types is sorted, the result
									// is already sorted.
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:17,代码来源:AlloyModel.java

示例14: getDirectSubTypes

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入依赖的package包/类
/**
 * Returns a sorted, unmodifiable list of types that are direct subtypes of
 * the given type. <br>
 * This method will only return types that are direct subtypes of the given
 * argument. <br>
 * If type==null, or it does not exist in this model, or it has no subsigs,
 * then we return an empty set.
 */
public ConstList<AlloyType> getDirectSubTypes(AlloyType type) {
	TempList<AlloyType> subtypes = new TempList<AlloyType>();
	for (AlloyType subType : types)
		if (isDirectSubtype(subType, type))
			subtypes.add(subType);
	return subtypes.makeConst(); // Since this.types is sorted, the result
									// is already sorted.
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:17,代码来源:AlloyModel.java

示例15: project

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入依赖的package包/类
/**
 * Project this tuple and return an unmodifiable list of remaining atoms
 * (after removing zero or more columns)
 * 
 * @param columns - the collection of columns to remove (0 is the first
 *            column, 1 is the second column...)
 */
public ConstList<AlloyAtom> project(Collection<Integer> columns) {
	TempList<AlloyAtom> list = new TempList<AlloyAtom>(atoms.size());
	for (int i = 0; i < atoms.size(); i++)
		if (!columns.contains(i))
			list.add(atoms.get(i));
	if (list.size() == atoms.size())
		return atoms;
	else
		return list.makeConst();
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:18,代码来源:AlloyTuple.java


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