本文整理汇总了Java中kodkod.util.collections.Containers类的典型用法代码示例。如果您正苦于以下问题:Java Containers类的具体用法?Java Containers怎么用?Java Containers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Containers类属于kodkod.util.collections包,在下文中一共展示了Containers类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: compose
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* Returns the composition of the given formulas using the given operator.
*
* @requires formulas.length != 2 => op.nary()
* @return
*
* <pre>
* formulas.length = 0 => constant(op=AND) else
* formulas.length=1 => formulas[0] else
* {e: Formula | e.children = formulas and e.op = this }
* </pre>
*/
public static Formula compose(FormulaOperator op, Formula... formulas) {
switch (formulas.length) {
case 0 :
switch (op) {
case AND :
return TRUE;
case OR :
return FALSE;
default :
throw new IllegalArgumentException(
"Expected at least one argument: " + Arrays.toString(formulas));
}
case 1 :
return formulas[0];
case 2 :
return new BinaryFormula(formulas[0], op, formulas[1]);
default :
return new NaryFormula(op, Containers.copy(formulas, new Formula[formulas.length]));
}
}
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:33,代码来源:Formula.java
示例2: override
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* Overrides the values in this matrix with those in <code>other</code>.
*
* @return others.length = 0 => { m: BooleanMatrix | m.dimensions =
* this.dimensions && m.elements = this.elements) else others.length
* = 1 => {m: BooleanMatrix | m.dimensions = this.dimensions && all
* i: [0..m.capacity()) | m.elements[i] = other.elements[i] ||
* this.elements[i] && !OR(other.elements[rowOf(i)]) } else
* this.override(others[0).override(others[1..others.length))
* @throws NullPointerException others = null
* @throws IllegalArgumentException others[int].factory != this.factory or
* others[int].dimensions != this.dimensions
*/
public final BooleanMatrix override(BooleanMatrix... others) {
if (others.length == 0)
return clone();
final BooleanMatrix[] matrices = Containers.copy(others, 0, new BooleanMatrix[others.length + 1], 1,
others.length);
matrices[0] = this;
for (int part = matrices.length; part > 1; part -= part / 2) {
final int max = part - 1;
for (int i = 0; i < max; i += 2) {
matrices[i / 2] = matrices[i].override(matrices[i + 1]);
}
if (max % 2 == 0) { // even max => odd number of entries
matrices[max / 2] = matrices[max];
}
}
return matrices[0];
}
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:31,代码来源:BooleanMatrix.java
示例3: FileLogger
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* Constructs a new file logger from the given annotated formula.
*
* @ensures this.formula' = annotated.node
* @ensures this.originalFormula' = annotated.source[annotated.node]
* @ensures this.bounds' = bounds
* @ensures this.log().roots() = Nodes.conjuncts(annotated)
* @ensures no this.records'
*/
FileLogger(final AnnotatedNode<Formula> annotated, Bounds bounds) {
this.annotated = annotated;
try {
this.file = File.createTempFile("kodkod", ".log");
this.out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
} catch (IOException e1) {
throw new RuntimeException(e1);
}
final Map<Formula,Set<Variable>> freeVarMap = freeVars(annotated);
final Variable[] empty = new Variable[0];
this.logMap = new FixedMap<Formula,Variable[]>(freeVarMap.keySet());
for (Map.Entry<Formula,Variable[]> e : logMap.entrySet()) {
Set<Variable> vars = freeVarMap.get(e.getKey());
int size = vars.size();
if (size == 0) {
e.setValue(empty);
} else {
e.setValue(Containers.identitySort(vars.toArray(new Variable[size])));
}
}
this.bounds = bounds.unmodifiableView();
}
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:35,代码来源:FileLogger.java
示例4: override
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* Overrides the values in this matrix with those in <code>other</code>.
* @return others.length = 0 => { m: BooleanMatrix | m.dimensions = this.dimensions && m.elements = this.elements) else
* others.length = 1 => {m: BooleanMatrix | m.dimensions = this.dimensions &&
* all i: [0..m.capacity()) | m.elements[i] =
* other.elements[i] || this.elements[i] && !OR(other.elements[rowOf(i)]) } else
* this.override(others[0).override(others[1..others.length))
* @throws NullPointerException others = null
* @throws IllegalArgumentException others[int].factory != this.factory or others[int].dimensions != this.dimensions
*/
public final BooleanMatrix override(BooleanMatrix... others) {
if (others.length==0) return clone();
final BooleanMatrix[] matrices = Containers.copy(others, 0, new BooleanMatrix[others.length+1], 1, others.length);
matrices[0] = this;
for(int part = matrices.length; part > 1; part -= part/2) {
final int max = part-1;
for(int i = 0; i < max; i += 2) {
matrices[i/2] = matrices[i].override(matrices[i+1]);
}
if (max%2==0) { // even max => odd number of entries
matrices[max/2] = matrices[max];
}
}
return matrices[0];
}
开发者ID:ModelWriter,项目名称:Tarski,代码行数:26,代码来源:BooleanMatrix.java
示例5: get
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* {@inheritDoc}
* @see kodkod.engine.satlab.ResolutionTrace#get(int)
*/
public Clause get(final int index) {
if (index>=0 && index<trace.length) {
if (axiom(index)) { // return a self-contained clause
return new Clause() {
final int[] literals = trace[index];
final int hashCode = Ints.superFastHash(literals);
public Iterator<Clause> antecedents() { return Containers.emptyIterator(); }
public IntIterator literals() { return new IntArrayIterator(literals,0,literals.length); }
public int maxVariable() { return StrictMath.abs(literals[literals.length-1]); }
public int numberOfAntecedents() { return 0; }
public int size() { return literals.length; }
public int[] toArray(int[] array) {
if (array.length<literals.length) { array = new int[literals.length]; }
System.arraycopy(literals, 0, array, 0, literals.length);
return array;
}
public int hashCode() { return hashCode; }
};
} else {
return new ClauseView(index);
}
}
throw new IndexOutOfBoundsException("invalid index: " + index);
}
开发者ID:ModelWriter,项目名称:Tarski,代码行数:29,代码来源:LazyTrace.java
示例6: FileLogger
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* Constructs a new file logger from the given annotated formula.
* @ensures this.formula' = annotated.node
* @ensures this.originalFormula' = annotated.source[annotated.node]
* @ensures this.bounds' = bounds
* @ensures this.log().roots() = Nodes.conjuncts(annotated)
* @ensures no this.records'
*/
FileLogger(final AnnotatedNode<Formula> annotated, Bounds bounds) {
this.annotated = annotated;
try {
this.file = File.createTempFile("kodkod", ".log");
this.out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
} catch (IOException e1) {
throw new RuntimeException(e1);
}
final Map<Formula,Set<Variable>> freeVarMap = freeVars(annotated);
final Variable[] empty = new Variable[0];
this.logMap = new FixedMap<Formula, Variable[]>(freeVarMap.keySet());
for(Map.Entry<Formula, Variable[]> e : logMap.entrySet()) {
Set<Variable> vars = freeVarMap.get(e.getKey());
int size = vars.size();
if (size==0) {
e.setValue(empty);
} else {
e.setValue(Containers.identitySort(vars.toArray(new Variable[size])));
}
}
this.bounds = bounds.unmodifiableView();
}
开发者ID:ModelWriter,项目名称:Tarski,代码行数:34,代码来源:FileLogger.java
示例7: override
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* Overrides the values in this matrix with those in <code>other</code>.
* @return others.length = 0 => { m: BooleanMatrix | m.dimensions = this.dimensions && m.elements = this.elements) else
* others.length = 1 => {m: BooleanMatrix | m.dimensions = this.dimensions &&
* all i: [0..m.capacity()) | m.elements[i] =
* other.elements[i] || this.elements[i] && !OR(other.elements[rowOf(i)]) } else
* this.override(others[0).override(others[1..others.length))
* @throws NullPointerException others = null
* @throws IllegalArgumentException others[int].factory != this.factory or others[int].dimensions != this.dimensions
*/
public final BooleanMatrix override(BooleanMatrix... others) {
if (others.length==0) return clone();
final BooleanMatrix[] matrices = Containers.copy(others, 0, new BooleanMatrix[others.length+1], 1, others.length);
matrices[0] = this;
for(int part = matrices.length; part > 1; part -= part/2) {
final int max = part-1;
for(int i = 0; i < max; i += 2) {
matrices[i/2] = matrices[i].override(matrices[i+1]);
}
if (max%2==0) { // even max => odd number of entries
matrices[max/2] = matrices[max];
}
}
return matrices[0];
}
开发者ID:emina,项目名称:kodkod,代码行数:26,代码来源:BooleanMatrix.java
示例8: compose
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* Returns the composition of the given int expressions using the given
* operator.
*
* @requires intExprs.length = 2 => op.binary(), intExprs.length > 2 =>
* op.nary()
* @return intExprs.length=1 => intExprs[0] else {e: IntExpression |
* e.children = intExprs and e.op = this }
*/
public static IntExpression compose(IntOperator op, IntExpression... intExprs) {
switch (intExprs.length) {
case 0 :
throw new IllegalArgumentException("Expected at least one argument: " + Arrays.toString(intExprs));
case 1 :
return intExprs[0];
case 2 :
return new BinaryIntExpression(intExprs[0], op, intExprs[1]);
default :
return new NaryIntExpression(op, Containers.copy(intExprs, new IntExpression[intExprs.length]));
}
}
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:22,代码来源:IntExpression.java
示例9: compose
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* Returns the composition of the given expressions using the given
* operator.
*
* @requires exprs.length = 2 => op.binary(), exprs.length > 2 => op.nary()
* @return exprs.length=1 => exprs[0] else {e: Expression | e.children =
* exprs and e.op = this }
*/
public static Expression compose(ExprOperator op, Expression... exprs) {
switch (exprs.length) {
case 0 :
throw new IllegalArgumentException("Expected at least one argument: " + Arrays.toString(exprs));
case 1 :
return exprs[0];
case 2 :
return new BinaryExpression(exprs[0], op, exprs[1]);
default :
return new NaryExpression(op, Containers.copy(exprs, new Expression[exprs.length]));
}
}
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:21,代码来源:Expression.java
示例10: Universe
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* Constructs a new Universe consisting of the given atoms, in the order
* that they appear in the specified array
*
* @ensures this.size' = atoms.length && this.atoms' = atoms
* @throws NullPointerException atoms = null
* @throws IllegalArgumentException atoms contains duplicates
* @throws IllegalArgumentException atoms is empty
*/
public Universe(Object... atoms) {
if (atoms.length == 0)
throw new IllegalArgumentException("Cannot create an empty universe.");
this.atoms = Containers.copy(atoms, new Object[atoms.length]);
this.indices = new HashMap<Object,Integer>();
for (int i = 0; i < atoms.length; i++) {
if (indices.containsKey(atoms[i]))
throw new IllegalArgumentException(atoms[i] + " appears multiple times.");
indices.put(atoms[i], i);
}
this.factory = new TupleFactory(this);
}
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:22,代码来源:Universe.java
示例11: apply
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* If the plus flag is true, returns a sum of this and other ints, with a
* cascade of adders or logarithmic depth. If the plus flag is false,
* returns a product of this and other ints, with a cascade of multipliers
* of logarithmic depth.
*
* @return plus => PLUS(this, others) else MULTIPLY(this, others)
*/
private Int apply(boolean plus, Int... others) {
final Int[] ints = Containers.copy(others, 0, new Int[others.length + 1], 1, others.length);
ints[0] = this;
for (int part = ints.length; part > 1; part -= part / 2) {
final int max = part - 1;
for (int i = 0; i < max; i += 2) {
ints[i / 2] = plus ? ints[i].plus(ints[i + 1]) : ints[i].multiply(ints[i + 1]);
}
if (max % 2 == 0) { // even max => odd number of entries
ints[max / 2] = ints[max];
}
}
return ints[0];
}
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:23,代码来源:TwosComplementInt.java
示例12: compose
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* Returns the composition of the given int expressions using the given operator.
* @requires intExprs.length = 2 => op.binary(), intExprs.length > 2 => op.nary()
* @return intExprs.length=1 => intExprs[0] else {e: IntExpression | e.children = intExprs and e.op = this }
*/
public static IntExpression compose(IntOperator op, IntExpression...intExprs) {
switch(intExprs.length) {
case 0 : throw new IllegalArgumentException("Expected at least one argument: " + Arrays.toString(intExprs));
case 1 : return intExprs[0];
case 2 : return new BinaryIntExpression(intExprs[0], op, intExprs[1]);
default :
return new NaryIntExpression(op, Containers.copy(intExprs, new IntExpression[intExprs.length]));
}
}
开发者ID:ModelWriter,项目名称:Tarski,代码行数:15,代码来源:IntExpression.java
示例13: compose
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* Returns the composition of the given expressions using the given operator.
* @requires exprs.length = 2 => op.binary(), exprs.length > 2 => op.nary()
* @return exprs.length=1 => exprs[0] else {e: Expression | e.children = exprs and e.op = this }
*/
public static Expression compose(ExprOperator op, Expression...exprs) {
switch(exprs.length) {
case 0 : throw new IllegalArgumentException("Expected at least one argument: " + Arrays.toString(exprs));
case 1 : return exprs[0];
case 2 : return new BinaryExpression(exprs[0], op, exprs[1]);
default : return new NaryExpression(op, Containers.copy(exprs, new Expression[exprs.length]));
}
}
开发者ID:ModelWriter,项目名称:Tarski,代码行数:14,代码来源:Expression.java
示例14: compose
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* Returns the composition of the given formulas using the given operator.
* @requires formulas.length != 2 => op.nary()
* @return
* <pre>
* formulas.length = 0 => constant(op=AND) else
* formulas.length=1 => formulas[0] else
* {e: Formula | e.children = formulas and e.op = this }
* </pre>
*/
public static Formula compose(FormulaOperator op, Formula...formulas) {
switch(formulas.length) {
case 0 :
switch(op) {
case AND : return TRUE;
case OR : return FALSE;
default : throw new IllegalArgumentException("Expected at least one argument: " + Arrays.toString(formulas));
}
case 1 : return formulas[0];
case 2 : return new BinaryFormula(formulas[0], op, formulas[1]);
default : return new NaryFormula(op, Containers.copy(formulas, new Formula[formulas.length]));
}
}
开发者ID:ModelWriter,项目名称:Tarski,代码行数:24,代码来源:Formula.java
示例15: Universe
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* Constructs a new Universe consisting of the given atoms, in the order that they appear
* in the specified array
*
* @ensures this.size' = atoms.length && this.atoms' = atoms
* @throws NullPointerException - atoms = null
* @throws IllegalArgumentException - atoms contains duplicates
* @throws IllegalArgumentException - atoms is empty
*/
public Universe(Object...atoms) {
if (atoms.length==0) throw new IllegalArgumentException("Cannot create an empty universe.");
this.atoms = Containers.copy(atoms, new Object[atoms.length]);
this.indices = new HashMap<Object, Integer>();
for (int i = 0; i < atoms.length; i++) {
if (indices.containsKey(atoms[i]))
throw new IllegalArgumentException(atoms[i] + " appears multiple times.");
indices.put(atoms[i], i);
}
this.factory = new TupleFactory(this);
}
开发者ID:ModelWriter,项目名称:Tarski,代码行数:21,代码来源:Universe.java
示例16: apply
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* If the plus flag is true, returns a sum of this and other ints,
* with a cascade of adders or logarithmic depth. If the plus flag
* is false, returns a product of this and other ints, with a cascade
* of multipliers of logarithmic depth.
* @return plus => PLUS(this, others) else MULTIPLY(this, others)
*/
private Int apply(boolean plus, Int...others) {
final Int[] ints = Containers.copy(others, 0, new Int[others.length+1], 1, others.length);
ints[0] = this;
for(int part = ints.length; part > 1; part -= part/2) {
final int max = part-1;
for(int i = 0; i < max; i += 2) {
ints[i/2] = plus ? ints[i].plus(ints[i+1]) : ints[i].multiply(ints[i+1]);
}
if (max%2==0) { // even max => odd number of entries
ints[max/2] = ints[max];
}
}
return ints[0];
}
开发者ID:ModelWriter,项目名称:Tarski,代码行数:22,代码来源:TwosComplementInt.java
示例17: conjuncts
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* Returns an unmodifiable set consisting of the children of the given formula, if the formula is a binary or an nary conjunction. Otherwise
* returns a singleton set containing the formula itself.
* @return an unmodifiable set consisting of children of the given formula, if the formula is a binary or an nary conjunction. Otherwise
* returns a singleton set containing the formula itself.
*/
public static Set<Formula> conjuncts(Formula formula) {
if (formula instanceof BinaryFormula) {
final BinaryFormula bin = (BinaryFormula) formula;
if (bin.op()==FormulaOperator.AND) {
final Formula left = bin.left(), right = bin.right();
if (left==right) return Collections.singleton(left);
else return new AbstractSet<Formula>() {
@Override
public boolean contains(Object o) { return left==o || right==o; }
@Override
public Iterator<Formula> iterator() { return Containers.iterate(left, right); }
@Override
public int size() { return 2; }
};
}
} else if (formula instanceof NaryFormula) {
final NaryFormula nf = (NaryFormula) formula;
if (nf.op()==FormulaOperator.AND) {
final LinkedHashSet<Formula> children = new LinkedHashSet<Formula>(1+(nf.size()*4)/3);
for(Formula child : nf) { children.add(child); }
return Collections.unmodifiableSet(children);
}
}
return Collections.singleton(formula);
}
开发者ID:ModelWriter,项目名称:Tarski,代码行数:35,代码来源:Nodes.java
示例18: Universe
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* Constructs a new Universe consisting of the given atoms, in the order that they appear
* in the specified array
*
* @ensures this.size' = atoms.length && this.atoms' = atoms
* @throws NullPointerException atoms = null
* @throws IllegalArgumentException atoms contains duplicates
* @throws IllegalArgumentException atoms is empty
*/
public Universe(Object...atoms) {
if (atoms.length==0) throw new IllegalArgumentException("Cannot create an empty universe.");
this.atoms = Containers.copy(atoms, new Object[atoms.length]);
this.indices = new HashMap<Object, Integer>();
for (int i = 0; i < atoms.length; i++) {
if (indices.containsKey(atoms[i]))
throw new IllegalArgumentException(atoms[i] + " appears multiple times.");
indices.put(atoms[i], i);
}
this.factory = new TupleFactory(this);
}
开发者ID:emina,项目名称:kodkod,代码行数:21,代码来源:Universe.java
示例19: getPredNodes
import kodkod.util.collections.Containers; //导入依赖的package包/类
/** {@inheritDoc}
* @see com.ibm.wala.util.graph.EdgeManager#getPredNodes(java.lang.Object)
*/
public Iterator<T> getPredNodes(final T N) {
if (containsNode(N)) {
return new Iterator<T>() {
final Iterator<T> itr = edges.keySet().iterator();
T next, last;
public boolean hasNext() {
while(next==null && itr.hasNext()) {
final T node = itr.next();
if (edges.get(node).contains(N)) {
next = node;
}
}
return next != null;
}
public T next() {
if (!hasNext()) throw new NoSuchElementException();
last = next;
next = null;
return last;
}
public void remove() {
if (last==null) throw new IllegalStateException();
removeAllIncidentEdges(last);
itr.remove();
last = null;
}
};
}
return Containers.emptyIterator();
}
开发者ID:wala,项目名称:MemSAT,代码行数:38,代码来源:LinkedHashGraph.java
示例20: get
import kodkod.util.collections.Containers; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see kodkod.engine.satlab.ResolutionTrace#get(int)
*/
public Clause get(final int index) {
if (index >= 0 && index < trace.length) {
if (axiom(index)) { // return a self-contained clause
return new Clause() {
final int[] literals = trace[index];
final int hashCode = Ints.superFastHash(literals);
public Iterator<Clause> antecedents() {
return Containers.emptyIterator();
}
public IntIterator literals() {
return new IntArrayIterator(literals, 0, literals.length);
}
public int maxVariable() {
return StrictMath.abs(literals[literals.length - 1]);
}
public int numberOfAntecedents() {
return 0;
}
public int size() {
return literals.length;
}
public int[] toArray(int[] array) {
if (array.length < literals.length) {
array = new int[literals.length];
}
System.arraycopy(literals, 0, array, 0, literals.length);
return array;
}
public int hashCode() {
return hashCode;
}
};
} else {
return new ClauseView(index);
}
}
throw new IndexOutOfBoundsException("invalid index: " + index);
}
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:51,代码来源:LazyTrace.java
注:本文中的kodkod.util.collections.Containers类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论