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


Java TempList.size方法代码示例

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


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

示例1: 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());
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:20,代码来源:SimTupleset.java

示例2: 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();
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:33,代码来源:Sig.java

示例3: 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

示例4: project

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/**
 * Project this relation and return an unmodifiable list of remaining types
 * (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 List<AlloyType> project(Collection<Integer> columns) {
	TempList<AlloyType> list = new TempList<AlloyType>(types.size());
	for (int i = 0; i < types.size(); i++)
		if (!columns.contains(i))
			list.add(types.get(i));
	if (list.size() == types.size())
		return types;
	else
		return list.makeConst();
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:18,代码来源:AlloyRelation.java

示例5: find

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/**
 * Returns the index position if the list of tuples contains the tuple (a,b)
 * (or return -1 if not found).
 */
private static int find(TempList<SimTuple> tuples, SimAtom a, SimAtom b) {
	if (tuples.size() == 0 || tuples.get(0).arity() != 2)
		return -1;
	for (int i = tuples.size() - 1; i >= 0; i--) {
		SimTuple x = tuples.get(i);
		if (x.head() == a && x.tail() == b)
			return i;
	}
	return -1;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:15,代码来源:SimTupleset.java

示例6: domain

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/** Returns this<:that (NOTE: if this.arity!=1, then we return the empty set) */
public SimTupleset domain(SimTupleset that) {
   if (arity()!=1 || that.empty()) return EMPTY;
   TempList<SimTuple> ans = new TempList<SimTuple>(that.size());
   for(SimTuple x: that) if (has(x.head())) ans.add(x);
   return ans.size()==that.longsize() ? that : (ans.size()==0 ? EMPTY : new SimTupleset(ans.makeConst()));
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:8,代码来源:SimTupleset.java

示例7: difference

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/** Return this minus that; (if this tupleset and that tuple does not have compatible arity, then we return this tupleset as is).
 * <br/> Note: The resulting tuples will keep their original order.
 * <br/> Note: if this operation is a no-op, we guarantee we'll return this SimTupleset as is.
 */
public SimTupleset difference(SimTuple that) {
   if (empty() || arity()!=that.arity()) return this;
   TempList<SimTuple> ans = new TempList<SimTuple>(size()-1);
   for(SimTuple x: this) {
      if (that==null || !x.equals(that)) ans.add(x); else that=null;
   }
   return that!=null ? this : (ans.size()==0 ? EMPTY : new SimTupleset(ans.makeConst()));
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:13,代码来源:SimTupleset.java

示例8: difference

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/**
 * Return this minus that; (if this tupleset and that tuple does not have
 * compatible arity, then we return this tupleset as is). <br/>
 * Note: The resulting tuples will keep their original order. <br/>
 * Note: if this operation is a no-op, we guarantee we'll return this
 * SimTupleset as is.
 */
public SimTupleset difference(SimTuple that) {
	if (empty() || arity() != that.arity())
		return this;
	TempList<SimTuple> ans = new TempList<SimTuple>(size() - 1);
	for (SimTuple x : this) {
		if (that == null || !x.equals(that))
			ans.add(x);
		else
			that = null;
	}
	return that != null ? this : (ans.size() == 0 ? EMPTY : new SimTupleset(ans.makeConst()));
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:20,代码来源:SimTupleset.java

示例9: 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:ModelWriter,项目名称:Tarski,代码行数:12,代码来源:SimTupleset.java

示例10: find

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/** Returns the index position if the list of tuples contains the tuple (a,b) (or return -1 if not found). */
private static int find(TempList<SimTuple> tuples, SimAtom a, SimAtom b) {
   if (tuples.size() == 0 || tuples.get(0).arity() != 2) return -1;
   for(int i=tuples.size()-1; i >= 0; i--) {
      SimTuple x = tuples.get(i);
      if (x.head()==a && x.tail()==b) return i;
   }
   return -1;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:10,代码来源:SimTupleset.java

示例11: domain

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/**
 * Returns this<:that (NOTE: if this.arity!=1, then we return the empty set)
 */
public SimTupleset domain(SimTupleset that) {
	if (arity() != 1 || that.empty())
		return EMPTY;
	TempList<SimTuple> ans = new TempList<SimTuple>(that.size());
	for (SimTuple x : that)
		if (has(x.head()))
			ans.add(x);
	return ans.size() == that.longsize() ? that : (ans.size() == 0 ? EMPTY : new SimTupleset(ans.makeConst()));
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:13,代码来源:SimTupleset.java

示例12: range

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/**
 * Returns this:>that (NOTE: if that.arity!=1, then we return the empty set)
 */
public SimTupleset range(SimTupleset that) {
	if (that.arity() != 1 || this.empty())
		return EMPTY;
	TempList<SimTuple> ans = new TempList<SimTuple>(this.size());
	for (SimTuple x : this)
		if (that.has(x.head()))
			ans.add(x);
	return ans.size() == this.longsize() ? this : (ans.size() == 0 ? EMPTY : new SimTupleset(ans.makeConst()));
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:13,代码来源:SimTupleset.java

示例13: 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()));
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:14,代码来源:SimTupleset.java

示例14: 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());
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:18,代码来源:SimTupleset.java

示例15: make

import edu.mit.csail.sdg.alloy4.ConstList.TempList; //导入方法依赖的package包/类
/** Generates a call to a builtin predicate */
public static ExprList make(Pos pos, Pos closingBracket, Op op, List<? extends Expr> args) {
    boolean ambiguous = false;
    JoinableList<Err> errs = emptyListOfErrors;
    TempList<Expr> newargs = new TempList<Expr>(args.size());
    long weight = 0;
    Type commonArity = null;
    for(int i=0; i<args.size(); i++) {
        Expr a = (op==Op.AND || op==Op.OR) ? args.get(i).typecheck_as_formula() : args.get(i).typecheck_as_set();
        ambiguous = ambiguous || a.ambiguous;
        weight = weight + a.weight;
        if (a.mult != 0) errs = errs.make(new ErrorSyntax(a.span(), "Multiplicity expression not allowed here."));
        if (!a.errors.isEmpty()) errs = errs.make(a.errors); else if (commonArity==null) commonArity = a.type; else commonArity = commonArity.pickCommonArity(a.type);
        if (op==Op.AND) addAND(newargs, a); else if (op==Op.OR) addOR(newargs, a); else newargs.add(a);
    }
    if (op==Op.TOTALORDER) {
       if (newargs.size()!=3) {
          errs = errs.make(new ErrorSyntax(pos, "The builtin pred/totalOrder[] predicate must be called with exactly three arguments."));
       } else if (errs.isEmpty()) {
          if (!newargs.get(0).type.hasArity(1)) errs = errs.make(new ErrorType(pos, "The first argument to pred/totalOrder must be unary."));
          if (!newargs.get(1).type.hasArity(1)) errs = errs.make(new ErrorType(pos, "The second argument to pred/totalOrder must be unary."));
          if (!newargs.get(2).type.hasArity(2)) errs = errs.make(new ErrorType(pos, "The third argument to pred/totalOrder must be binary."));
       }
    }
    if (op==Op.DISJOINT) {
       if (newargs.size()<2) errs = errs.make(new ErrorSyntax(pos, "The builtin disjoint[] predicate must be called with at least two arguments."));
       if (commonArity==EMPTY) errs = errs.make(new ErrorType(pos, "The builtin predicate disjoint[] cannot be used among expressions of different arities."));
    }
    return new ExprList(pos, closingBracket, op, ambiguous, newargs.makeConst(), weight, errs);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:31,代码来源:ExprList.java


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