本文整理汇总了Java中edu.mit.csail.sdg.alloy4.ConstList.TempList.add方法的典型用法代码示例。如果您正苦于以下问题:Java TempList.add方法的具体用法?Java TempList.add怎么用?Java TempList.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.mit.csail.sdg.alloy4.ConstList.TempList
的用法示例。
在下文中一共展示了TempList.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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();
}
示例4: 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.
}
示例5: makeOR
import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/** Generates the expression (arg1 || arg2) */
public static ExprList makeOR(Pos pos, Pos closingBracket, Expr a, Expr b) {
TempList<Expr> list = new TempList<Expr>(2);
list.add(a);
list.add(b);
return make(pos, closingBracket, Op.OR, list.makeConst());
}
示例6: 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();
}
示例7: beginWith
import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/** Return the set of tuples which begins with the given tuple (where we remove the "matching leading part") */
public SimTupleset beginWith(SimTuple x) {
int shift = arity() - x.arity();
if (shift <= 0) return EMPTY;
TempList<SimTuple> ans = new TempList<SimTuple>();
again:
for(SimTuple r: this) {
for(int i=0; i<x.arity(); i++) if (r.get(i) != x.get(i)) continue again;
ans.add(r.tail(shift));
}
return ans.size()==0 ? EMPTY : new SimTupleset(ans.makeConst());
}
示例8: product
import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/** Return the cartesian product of this and that. */
public SimTupleset product(SimTupleset that) {
if (empty() || that.empty()) return EMPTY;
TempList<SimTuple> ans = new TempList<SimTuple>(size() * that.size());
for(SimTuple a: this) for(SimTuple b: that) {
ans.add(a.product(b)); // We don't have to check for duplicates, because we assume every tuple in "this" has same arity, and every tuple in "that" has same arity
}
return new SimTupleset(ans.makeConst());
}
示例9: intersect
import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/** Return the intersection of this and that. */
public SimTupleset intersect(SimTupleset that) {
if (this==that) return this; else if (empty() || that.empty()) return EMPTY;
TempList<SimTuple> ans = new TempList<SimTuple>(size() < that.size() ? size() : that.size());
for(SimTuple x: that) if (has(x)) ans.add(x);
if (ans.size()==0) return EMPTY;
if (ans.size()==this.longsize()) return this;
if (ans.size()==that.longsize()) return that; else return new SimTupleset(ans.makeConst());
}
示例10: getAllReachableSigs
import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/**
* Return the list containing UNIV, SIGINT, SEQIDX, STRING, NONE, and all
* sigs defined in this module or a reachable submodule.
*/
public ConstList<Sig> getAllReachableSigs() {
TempList<Sig> x = new TempList<Sig>();
x.add(UNIV);
x.add(SIGINT);
x.add(SEQIDX);
x.add(STRING);
x.add(NONE);
x.addAll(getAllReachableUserDefinedSigs());
return x.makeConst();
}
示例11: removeAll
import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/**
* Return this minus any tuple that contains the given atom. <br/>
* Note: The resulting tuples will keep their original order.
*/
public SimTupleset removeAll(SimAtom that) {
if (empty())
return EMPTY;
TempList<SimTuple> ans = new TempList<SimTuple>(size() - 1);
again: for (SimTuple x : this) {
for (int i = x.arity() - 1; i >= 0; i--)
if (x.get(i) == that)
continue again;
ans.add(x);
}
return ans.size() == longsize() ? this : (ans.size() == 0 ? EMPTY : new SimTupleset(ans.makeConst()));
}
示例12: makeConstList
import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/** Constructs an unmodifiable ConstList containing the same elements as this list. */
public ConstList<T> makeConstList() {
synchronized(SafeList.class) {
int n = size();
TempList<T> ans = new TempList<T>(n);
for(int i=0; i<n; i++) ans.add(list.get(i));
return ans.makeConst();
}
}
示例13: 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;
}
示例14: 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);
}
示例15: getAllAssertions
import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的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();
}