本文整理匯總了Java中org.apache.commons.lang3.mutable.MutableInt.setValue方法的典型用法代碼示例。如果您正苦於以下問題:Java MutableInt.setValue方法的具體用法?Java MutableInt.setValue怎麽用?Java MutableInt.setValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang3.mutable.MutableInt
的用法示例。
在下文中一共展示了MutableInt.setValue方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fromKeyValueGAE
import org.apache.commons.lang3.mutable.MutableInt; //導入方法依賴的package包/類
/**
* Creates an {@link Aggregate} from a serialized {@link EventKey} and a
* serialize {@link GPOMutable} object.
*
* @param key A serialized {@link EventKey}.
* @param aggregate A serialized {@link GPOMutable} containing all the values of the aggregates.
* @return An {@link Aggregate} object with the given {@link EventKey} and aggregate payload.
*/
public Aggregate fromKeyValueGAE(Slice key, byte[] aggregate)
{
MutableInt offset = new MutableInt(Type.LONG.getByteSize());
int schemaID = GPOUtils.deserializeInt(key.buffer,
offset);
int dimensionDescriptorID = GPOUtils.deserializeInt(key.buffer,
offset);
int aggregatorID = GPOUtils.deserializeInt(key.buffer,
offset);
FieldsDescriptor keysDescriptor = getKeyDescriptor(schemaID, dimensionDescriptorID);
FieldsDescriptor aggDescriptor = getValueDescriptor(schemaID, dimensionDescriptorID, aggregatorID);
FieldsDescriptor metaDataDescriptor = null;
if (getAggregator(aggregatorID) != null) {
metaDataDescriptor = getAggregator(aggregatorID).getMetaDataDescriptor();
} else {
metaDataDescriptor = getCompositeAggregator(aggregatorID).getMetaDataDescriptor();
}
GPOMutable keys = GPOUtils.deserialize(keysDescriptor, key.buffer, offset);
offset.setValue(0);
GPOMutable metaData = null;
if (metaDataDescriptor != null) {
metaData = GPOUtils.deserialize(metaDataDescriptor, aggregate, offset);
metaData.applyObjectPayloadFix();
}
GPOMutable aggs = GPOUtils.deserialize(aggDescriptor, aggregate, offset);
Aggregate gae = new Aggregate(keys,
aggs,
metaData,
schemaID,
dimensionDescriptorID,
aggregatorID);
return gae;
}
示例2: computeClusters
import org.apache.commons.lang3.mutable.MutableInt; //導入方法依賴的package包/類
private void computeClusters(Mutable<ILogicalOperator> parentRef, Mutable<ILogicalOperator> opRef,
MutableInt currentClusterId) {
// only replicate operator has multiple outputs
int outputIndex = 0;
if (opRef.getValue().getOperatorTag() == LogicalOperatorTag.REPLICATE) {
ReplicateOperator rop = (ReplicateOperator) opRef.getValue();
List<Mutable<ILogicalOperator>> outputs = rop.getOutputs();
for (outputIndex = 0; outputIndex < outputs.size(); outputIndex++) {
if (outputs.get(outputIndex).equals(parentRef)) {
break;
}
}
}
AbstractLogicalOperator aop = (AbstractLogicalOperator) opRef.getValue();
Pair<int[], int[]> labels = aop.getPhysicalOperator().getInputOutputDependencyLabels(opRef.getValue());
List<Mutable<ILogicalOperator>> inputs = opRef.getValue().getInputs();
for (int i = 0; i < inputs.size(); i++) {
Mutable<ILogicalOperator> inputRef = inputs.get(i);
if (labels.second[outputIndex] == 1 && labels.first[i] == 0) { // 1 -> 0
if (labels.second.length == 1) {
clusterMap.put(opRef, currentClusterId);
// start a new cluster
MutableInt newClusterId = new MutableInt(++lastUsedClusterId);
computeClusters(opRef, inputRef, newClusterId);
BitSet waitForList = clusterWaitForMap.get(currentClusterId.getValue());
if (waitForList == null) {
waitForList = new BitSet();
clusterWaitForMap.put(currentClusterId.getValue(), waitForList);
}
waitForList.set(newClusterId.getValue());
}
} else { // 0 -> 0 and 1 -> 1
MutableInt prevClusterId = clusterMap.get(opRef);
if (prevClusterId == null || prevClusterId.getValue().equals(currentClusterId.getValue())) {
clusterMap.put(opRef, currentClusterId);
computeClusters(opRef, inputRef, currentClusterId);
} else {
// merge prevClusterId and currentClusterId: update all the map entries that has currentClusterId to prevClusterId
for (BitSet bs : clusterWaitForMap.values()) {
if (bs.get(currentClusterId.getValue())) {
bs.clear(currentClusterId.getValue());
bs.set(prevClusterId.getValue());
}
}
currentClusterId.setValue(prevClusterId.getValue());
}
}
}
}
示例3: bresenham
import org.apache.commons.lang3.mutable.MutableInt; //導入方法依賴的package包/類
/**
* Bresenham.
*
* @param nx
* the nx
* @param ny
* the ny
* @param px
* the px
* @param py
* the py
* @param length
* the length
* @param line
* the line
* @param num_points
* the num points
*/
/*
* Modified Bresenham algorithm. It returns in line all pixels that are
* intersected by a half line less than length away from the point (px,py) aint
* the direction (nx,ny). The point (px,py) must lie within the pixel of the
* origin, i.e., fabs(px) <= 0.5 and fabs(py) <= 0.5.
*/
public void bresenham(double nx, double ny, double px, double py, double length, Offset[] line,
MutableInt num_points) {
int i, n, x, y, s1, s2, xchg, maxit;
double e, dx, dy, t;
x = 0;
y = 0;
dx = Math.abs(nx);
dy = Math.abs(ny);
s1 = (int) Math.signum(nx);
s2 = (int) Math.signum(ny);
px *= s1;
py *= s2;
if (dy > dx) {
t = dx;
dx = dy;
dy = t;
t = px;
px = py;
py = t;
xchg = 1;
} else {
xchg = 0;
}
maxit = (int) Math.ceil(length * dx);
e = (0.5 - px) * dy / dx - (0.5 - py);
n = 0;
for (i = 0; i <= maxit; i++) {
line[n].x = x;
line[n].y = y;
n++;
while (e >= -1e-8) {
if (!(xchg == 0))
x += s1;
else
y += s2;
e--;
if (e > -1) {
line[n].x = x;
line[n].y = y;
n++;
}
}
if (!(xchg == 0))
y += s2;
else
x += s1;
e += dy / dx;
}
num_points.setValue(n);
}
示例4: solve_linear
import org.apache.commons.lang3.mutable.MutableInt; //導入方法依賴的package包/類
/**
* Solve the linear equation a*x+b=0 and return the result in t and the number
* of solutions in num.
*
* @param a
* the a
* @param b
* the b
* @param t
* the t
* @param num
* the num
*/
public void solve_linear(double a, double b, MutableDouble t, MutableInt num) {
if (a == 0.0) { //
num.setValue(0);
return;
} else {
num.setValue(1);
t.setValue(-b / a);
return;
}
}