本文整理汇总了Java中edu.mit.csail.sdg.alloy4.ConstList.TempList.makeConst方法的典型用法代码示例。如果您正苦于以下问题:Java TempList.makeConst方法的具体用法?Java TempList.makeConst怎么用?Java TempList.makeConst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.mit.csail.sdg.alloy4.ConstList.TempList
的用法示例。
在下文中一共展示了TempList.makeConst方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SubsetSig
import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/** Constructs a subset sig.
*
* @param label - the name of this sig (it does not need to be unique)
* @param parents - the list of parents (if this list is null or empty, we assume the caller means UNIV)
* @param attributes - the list of optional attributes such as EXACT, SUBSET, LONE, ONE, SOME, PRIVATE, or META
*
* @throws ErrorSyntax if the signature has two or more multiplicities
* @throws ErrorType if parents only contains NONE
*/
public SubsetSig(String label, Collection<Sig> parents, Attr... attributes) throws Err {
super(getType(label,parents), label, Util.append(attributes, Attr.SUBSET));
if (isEnum!=null) throw new ErrorType(pos, "Subset signature cannot be an enum.");
boolean exact = false;
for(Attr a: attributes) if (a!=null && a.type==AttrType.EXACT) exact = true;
this.exact = exact;
TempList<Sig> temp = new TempList<Sig>(parents==null ? 1 : parents.size());
if (parents==null || parents.size()==0) {
temp.add(UNIV);
} else {
for(Sig parent:parents) {
if (!Version.experimental) {
if (parent==SIGINT) throw new ErrorSyntax(pos, "sig "+label+" cannot be a subset of the builtin \"Int\" signature");
if (parent==SEQIDX) throw new ErrorSyntax(pos, "sig "+label+" cannot be a subset of the builtin \"seq/Int\" signature");
if (parent==STRING) throw new ErrorSyntax(pos, "sig "+label+" cannot be a subset of the builtin \"String\" signature");
}
if (parent==Sig.UNIV) {temp.clear(); temp.add(UNIV); break;}
if (parent!=Sig.NONE && !temp.contains(parent)) temp.add(parent);
}
}
if (temp.size()==0) throw new ErrorType(pos, "Sig "+label+" must have at least one non-empty parent.");
this.parents = temp.makeConst();
}
示例2: 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
}
}
示例3: 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());
}
示例4: endWith
import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/**
* Return the set of tuples which ends with the given tuple (where we remove
* the "matching trailing part")
*/
public SimTupleset endWith(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 + shift) != x.get(i))
continue again;
ans.add(r.head(shift));
}
return ans.size() == 0 ? EMPTY : new SimTupleset(ans.makeConst());
}
示例5: 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);
for(CompModule m:getAllReachableModules()) x.addAll(m.sigs.values());
return x.makeConst();
}
示例6: getAllReachableUserDefinedSigs
import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/**
* Return the list containing all sigs defined in this module or a reachable
* submodule.
*/
public ConstList<Sig> getAllReachableUserDefinedSigs() {
TempList<Sig> x = new TempList<Sig>();
for (CompModule m : getAllReachableModules())
x.addAll(m.sigs.values());
return x.makeConst();
}
示例7: iden
import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/**
* Return the identity over this tupleset; (if this tupleset's arity is not
* 1, then we return an emptyset) <br/>
* Note: the result's tuple order is the same as this tupleset's tuple
* order.
*/
public SimTupleset iden() {
if (arity() != 1)
return EMPTY;
TempList<SimTuple> ans = new TempList<SimTuple>(size());
for (SimTuple x : this)
ans.add(SimTuple.make(x.head(), x.head())); // since "this" has no
// duplicate tuples,
// "ans" will not have
// duplicate tuples
// either
return new SimTupleset(ans.makeConst());
}
示例8: union
import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/** Return the union of this and that; (if this tupleset and that tuple does not have compatible arity, then we return this tupleset as is).
* <br/> Note: if this operation is a no-op, we guarantee we'll return this SimTupleset as is.
*/
public SimTupleset union(SimTuple that) {
if (empty()) return make(that);
if (arity()!=that.arity() || has(that)) return this;
TempList<SimTuple> ans = new TempList<SimTuple>(tuples.size()+1);
ans.addAll(tuples).add(that);
return new SimTupleset(ans.makeConst(), min, max, next);
}
示例9: difference
import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/**
* Return this minus that; (if this tupleset and that tupleset does not have
* compatible arity, then we return this tupleset as is). <br/>
* Note: The resulting tuples will keep their original order.
*/
public SimTupleset difference(SimTupleset that) {
if (this.empty() || this == that)
return EMPTY;
if (that.empty() || arity() != that.arity())
return this;
TempList<SimTuple> ans = new TempList<SimTuple>(size() - 1);
for (SimTuple x : this)
if (!that.has(x))
ans.add(x);
return ans.size() == longsize() ? this : (ans.size() == 0 ? EMPTY : new SimTupleset(ans.makeConst()));
}
示例10: 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());
}
示例11: 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();
}
}
示例12: 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
}
}
示例13: 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());
}
示例14: 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();
}
};
}
示例15: 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.
}