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


Java SparseSequence.put方法代码示例

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


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

示例1: or

import kodkod.util.ints.SparseSequence; //导入方法依赖的package包/类
/**
 * Returns a new matrix such that an entry in the returned matrix represents
 * a combination of the corresponding entries in this and other matrix. The
 * effect of this method is the same as calling
 * this.compose(ExprOperator.Binary.OR, other).
 *
 * @return { m: BooleanMatrix | m.dimensions = this.dimensions && m.factory
 *         = this.factory && all i: [0..m.dimensions.capacity) |
 *         m.elements[i] = this.elements[i] OR other.elements[i] }
 * @throws NullPointerException other = null
 * @throws IllegalArgumentException
 *             !other.dimensions.equals(this.dimensions) || this.factory !=
 *             other.factory
 */
public final BooleanMatrix or(BooleanMatrix other) {
	checkFactory(this.factory, other.factory);
	checkDimensions(this.dims, other.dims);
	if (this.cells.isEmpty())
		return other.clone();
	else if (other.cells.isEmpty())
		return this.clone();

	final BooleanMatrix ret = new BooleanMatrix(dims, factory, cells, other.cells);
	ret.mergeDefConds(this, other);

	final SparseSequence<BooleanValue> retSeq = ret.cells;
	for (IndexedEntry<BooleanValue> e0 : cells) {
		BooleanValue v1 = other.cells.get(e0.index());
		if (v1 == null)
			retSeq.put(e0.index(), e0.value());
		else
			retSeq.put(e0.index(), factory.or(e0.value(), v1));
	}
	for (IndexedEntry<BooleanValue> e1 : other.cells) {
		if (!cells.containsIndex(e1.index()))
			retSeq.put(e1.index(), e1.value());
	}
	return ret;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:40,代码来源:BooleanMatrix.java

示例2: or

import kodkod.util.ints.SparseSequence; //导入方法依赖的package包/类
/**
 * Returns a new matrix such that an entry in the returned matrix represents a 
 * combination of the corresponding entries in this and other matrix.  The effect 
 * of this method is the same as calling this.compose(ExprOperator.Binary.OR, other).
 * 
 * @return { m: BooleanMatrix | m.dimensions = this.dimensions && m.factory = this.factory &&
 *                              all i: [0..m.dimensions.capacity) | 
 *                               m.elements[i] = this.elements[i] OR other.elements[i] }
 * @throws NullPointerException  other = null 
 * @throws IllegalArgumentException  !other.dimensions.equals(this.dimensions) || this.factory != other.factory
 */
public final BooleanMatrix or(BooleanMatrix  other) {
    checkFactory(this.factory, other.factory); checkDimensions(this.dims, other.dims);
    
    final BooleanMatrix ret = new BooleanMatrix(dims, factory, cells, other.cells);
    ret.mergeDefConds(this, other);
    
    final SparseSequence<BooleanValue> retSeq = ret.cells;
    for(IndexedEntry<BooleanValue> e0 : cells) {
        BooleanValue v1 = other.cells.get(e0.index());
        if (v1==null)
            retSeq.put(e0.index(), e0.value());
        else
            retSeq.put(e0.index(), factory.or(e0.value(), v1));
    }
    for(IndexedEntry<BooleanValue> e1 : other.cells) {
        if (!cells.containsIndex(e1.index()))
            retSeq.put(e1.index(), e1.value());
    }
    return ret;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:32,代码来源:BooleanMatrix.java

示例3: or

import kodkod.util.ints.SparseSequence; //导入方法依赖的package包/类
/**
 * Returns a new matrix such that an entry in the returned matrix represents a 
 * combination of the corresponding entries in this and other matrix.  The effect 
 * of this method is the same as calling this.compose(ExprOperator.Binary.OR, other).
 * 
 * @return { m: BooleanMatrix | m.dimensions = this.dimensions && m.factory = this.factory &&
 *                              all i: [0..m.dimensions.capacity) | 
 *                               m.elements[i] = this.elements[i] OR other.elements[i] }
 * @throws NullPointerException  other = null 
 * @throws IllegalArgumentException  !other.dimensions.equals(this.dimensions) || this.factory != other.factory
 */
public final BooleanMatrix or(BooleanMatrix  other) {
	checkFactory(this.factory, other.factory); 
	checkDimensions(this.dims, other.dims);
	if (this.cells.isEmpty())
		return other.clone();
	else if (other.cells.isEmpty())
		return this.clone();
	final BooleanMatrix ret = new BooleanMatrix(dims, factory, cells, other.cells);
	final SparseSequence<BooleanValue> retSeq = ret.cells;
	for(IndexedEntry<BooleanValue> e0 : cells) {
		BooleanValue v1 = other.cells.get(e0.index());
		if (v1==null)
			retSeq.put(e0.index(), e0.value());
		else
			retSeq.put(e0.index(), factory.or(e0.value(), v1));
	}
	for(IndexedEntry<BooleanValue> e1 : other.cells) {
		if (!cells.containsIndex(e1.index()))
			retSeq.put(e1.index(), e1.value());
	}

	return ret;
}
 
开发者ID:emina,项目名称:kodkod,代码行数:35,代码来源:BooleanMatrix.java

示例4: dot

import kodkod.util.ints.SparseSequence; //导入方法依赖的package包/类
/**
 * Returns the dot product of this and other matrix, using conjunction
 * instead of multiplication and disjunction instead of addition.
 *
 * @return { m: BooleanMatrix | m = this*other }
 * @throws NullPointerException other = null
 * @throws IllegalArgumentException this.factory != other.factory
 * @throws IllegalArgumentException dimensions incompatible for
 *             multiplication
 */
public final BooleanMatrix dot(final BooleanMatrix other) {
	checkFactory(this.factory, other.factory);

	final BooleanMatrix ret = new BooleanMatrix(dims.dot(other.dims), factory, cells, other.cells);
	ret.mergeDefConds(this, other);

	if (cells.isEmpty() || other.cells.isEmpty())
		return ret;

	final SparseSequence<BooleanValue> mutableCells = ret.clone().cells;
	final int b = other.dims.dimension(0);
	final int c = other.dims.capacity() / b;

	for (IndexedEntry<BooleanValue> e0 : cells) {
		int i = e0.index();
		BooleanValue iVal = e0.value();
		int rowHead = (i % b) * c, rowTail = rowHead + c - 1;
		for (Iterator<IndexedEntry<BooleanValue>> iter1 = other.cells.iterator(rowHead, rowTail); iter1
				.hasNext();) {
			IndexedEntry<BooleanValue> e1 = iter1.next();
			BooleanValue retVal = factory.and(iVal, e1.value());
			if (retVal != FALSE) {
				int k = (i / b) * c + e1.index() % c;
				if (retVal == TRUE)
					mutableCells.put(k, TRUE);
				else {
					BooleanValue kVal = mutableCells.get(k);
					if (kVal != TRUE) {
						if (kVal == null) {
							kVal = BooleanAccumulator.treeGate(OR);
							mutableCells.put(k, kVal);
						}
						((BooleanAccumulator) kVal).add(retVal);
					}
				}
			}
		}
	}

	// make mutable gates immutable
	for (IndexedEntry<BooleanValue> e : mutableCells) {
		if (e.value() != TRUE) {
			ret.fastSet(e.index(), factory.accumulate((BooleanAccumulator) e.value()));
		} else {
			ret.fastSet(e.index(), TRUE);
		}
	}

	return ret;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:61,代码来源:BooleanMatrix.java

示例5: dot

import kodkod.util.ints.SparseSequence; //导入方法依赖的package包/类
/**
 * Returns the dot product of this and other matrix, using conjunction instead of 
 * multiplication and disjunction instead of addition.
 * 
 * @return { m: BooleanMatrix | m = this*other }
 * @throws NullPointerException  other = null
 * @throws IllegalArgumentException  this.factory != other.factory
 * @throws IllegalArgumentException  dimensions incompatible for multiplication
 */
public final BooleanMatrix dot(final BooleanMatrix other) {  
    checkFactory(this.factory, other.factory);
    
    final BooleanMatrix ret =  new BooleanMatrix(dims.dot(other.dims), factory, cells, other.cells);
    ret.mergeDefConds(this, other);
    
    if (cells.isEmpty() || other.cells.isEmpty()) return ret;
    
    final SparseSequence<BooleanValue> mutableCells = ret.clone().cells;
    final int b = other.dims.dimension(0); 
    final int c = other.dims.capacity() / b; 
    
    for(IndexedEntry<BooleanValue> e0 : cells) {
        int i = e0.index();
        BooleanValue iVal = e0.value();
        int rowHead = (i % b)*c, rowTail = rowHead + c - 1;
        for(Iterator<IndexedEntry<BooleanValue>> iter1 = other.cells.iterator(rowHead, rowTail); iter1.hasNext();) {
            IndexedEntry<BooleanValue> e1 = iter1.next();
            BooleanValue retVal = factory.and(iVal, e1.value());
            if (retVal != FALSE) {
                int k = (i / b)*c + e1.index()%c;
                if (retVal==TRUE) mutableCells.put(k, TRUE);
                else {
                    BooleanValue kVal = mutableCells.get(k);
                    if (kVal != TRUE) {
                        if (kVal==null) {
                            kVal = BooleanAccumulator.treeGate(OR);
                            mutableCells.put(k, kVal);
                        } 
                        ((BooleanAccumulator) kVal).add(retVal);
                    }
                }
            }
        }       
    }
    
    // make mutable gates immutable
    for(IndexedEntry<BooleanValue> e : mutableCells) {
        if (e.value()!=TRUE) {
            ret.fastSet(e.index(), factory.accumulate((BooleanAccumulator) e.value()));
        } else {
            ret.fastSet(e.index(), TRUE);
        }
    }
    
    return ret;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:57,代码来源:BooleanMatrix.java

示例6: dot

import kodkod.util.ints.SparseSequence; //导入方法依赖的package包/类
/**
    * Returns the dot product of this and other matrix, using conjunction instead of 
    * multiplication and disjunction instead of addition.
    * 
    * @return { m: BooleanMatrix | m = this*other }
    * @throws NullPointerException  other = null
    * @throws IllegalArgumentException  this.factory != other.factory
    * @throws IllegalArgumentException  dimensions incompatible for multiplication
    */
public final BooleanMatrix dot(final BooleanMatrix other) {  
	checkFactory(this.factory, other.factory);
	
	final BooleanMatrix ret =  new BooleanMatrix(dims.dot(other.dims), factory, cells, other.cells);
	if (cells.isEmpty() || other.cells.isEmpty()) return ret;
	
	final SparseSequence<BooleanValue> mutableCells = ret.clone().cells;
	final int b = other.dims.dimension(0); 
	final int c = other.dims.capacity() / b; 
	
	for(IndexedEntry<BooleanValue> e0 : cells) {
		int i = e0.index();
		BooleanValue iVal = e0.value();
		int rowHead = (i % b)*c, rowTail = rowHead + c - 1;
		for(Iterator<IndexedEntry<BooleanValue>> iter1 = other.cells.iterator(rowHead, rowTail); iter1.hasNext();) {
			IndexedEntry<BooleanValue> e1 = iter1.next();
			BooleanValue retVal = factory.and(iVal, e1.value());
			if (retVal != FALSE) {
				int k = (i / b)*c + e1.index()%c;
				if (retVal==TRUE) mutableCells.put(k, TRUE);
				else {
					BooleanValue kVal = mutableCells.get(k);
					if (kVal != TRUE) {
						if (kVal==null) {
							kVal = BooleanAccumulator.treeGate(OR);
							mutableCells.put(k, kVal);
						} 
						((BooleanAccumulator) kVal).add(retVal);
					}
				}
			}
		}		
	}
	
	// make mutable gates immutable
	for(IndexedEntry<BooleanValue> e : mutableCells) {
		if (e.value()!=TRUE) {
			ret.fastSet(e.index(), factory.accumulate((BooleanAccumulator) e.value()));
		} else {
			ret.fastSet(e.index(), TRUE);
		}
	}
	return ret;
}
 
开发者ID:emina,项目名称:kodkod,代码行数:54,代码来源:BooleanMatrix.java

示例7: evaluate

import kodkod.util.ints.SparseSequence; //导入方法依赖的package包/类
/**
 * Returns the sparse sequence mapping each index in this.indeces[ref]
 * to its corresponding value in this.values[ref], as given by the
 * specified evaluator. In particular, if the
 * type if this.values is RealExpression, then the returned value will be 
 * a sequence of Floats; if the type of 
 * this value is an IntExpression, the returned value will be a sequence of Integers; 
 * if the type of this value is an Expression, the returned value will be a sequence of Objects; 
 * finally, if the type of this.values is Formula, the returned value will be a sequence of Booleans.
 * @requires  the given evaluator's instance has bindings
 * for all relations (if any) at the leaves of this array expression.
 * @requires eval.evaluate(ref) in eval.evaluate(this.refs)
 * @return sparse sequence mapping each index in this.indeces[ref]
 * to its corresponding value in this.values[ref], as given by the
 * specified evaluator.
 */
@SuppressWarnings("unchecked")
public final <V> SparseSequence<V> evaluate(Expression ref, Evaluator eval) {
	final SparseSequence<V> ret = new TreeSequence<V>();
	for(int i = 0, card = cardinality(); i < card; i++) { 
		int idx = eval.evaluate(idxMeaning.fromObj(ref.join(indices[i])));
		V value = (V) valMeaning.evaluate(valMeaning.fromObj(ref.join(values[i])),eval);
		ret.put(idx, value);
	}
	return ret;
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:27,代码来源:ArrayExpression.java


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