本文整理汇总了Java中org.apache.commons.lang3.tuple.MutablePair.setLeft方法的典型用法代码示例。如果您正苦于以下问题:Java MutablePair.setLeft方法的具体用法?Java MutablePair.setLeft怎么用?Java MutablePair.setLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.tuple.MutablePair
的用法示例。
在下文中一共展示了MutablePair.setLeft方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prefixSplitter
import org.apache.commons.lang3.tuple.MutablePair; //导入方法依赖的package包/类
private Pair<String, String> prefixSplitter(String input) {
MutablePair<String, String> result = new MutablePair<>("", input);
if (input.startsWith("Device")) {
result.setLeft("Device");
result.setRight(input.replaceFirst("Device", ""));
} else if (input.startsWith("OperatingSystem")) {
result.setLeft("Operating System");
result.setRight(input.replaceFirst("OperatingSystem", ""));
} else if (input.startsWith("LayoutEngine")) {
result.setLeft("Layout Engine");
result.setRight(input.replaceFirst("LayoutEngine", ""));
} else if (input.startsWith("Agent")) {
result.setLeft("Agent");
result.setRight(input.replaceFirst("Agent", ""));
}
return result;
}
示例2: onRemove
import org.apache.commons.lang3.tuple.MutablePair; //导入方法依赖的package包/类
/**
* Invoked when a mapping of a map of one of the settings is removed.<br>
* This is used to adjust the merged map accordingly
*
* @param sc the setting of which the entry was removed
* @param key the key of the mapping to be removed
*/
private synchronized void onRemove(SettingsContainer sc, Object key) {
MutablePair<V, Integer> pair = this.mergedMap.get(key);
if (pair != null && pair.getRight() == sc.listIndex) {
Pair<V, Integer> newVal = getIndexAndValueForKey(key);
if (newVal != null) {
pair.setLeft(newVal.getLeft());
pair.setRight(newVal.getRight());
}
else this.mergedMap.remove(key);
}
removeMapIfEmpty(sc.listIndex);
}
示例3: setComment
import org.apache.commons.lang3.tuple.MutablePair; //导入方法依赖的package包/类
@Override
public void setComment(String path, @Nullable String comment)
{
MutablePair<String, CommentsNodeImpl> nodePair = this.dataMap.computeIfAbsent(path, k -> new MutablePair<>(null, null));
if (comment == null)
{
nodePair.setLeft(null);
return;
}
nodePair.setLeft(comment);
}
示例4: average
import org.apache.commons.lang3.tuple.MutablePair; //导入方法依赖的package包/类
/**
* @see com.ottogroup.bi.streaming.operator.json.aggregate.functions.JsonContentAggregateFunction#average(org.apache.commons.lang3.tuple.MutablePair, java.io.Serializable)
*/
public MutablePair<Double, Integer> average(MutablePair<Double, Integer> sumAndCount, Double value) throws Exception {
if(sumAndCount == null && value == null)
return new MutablePair<>(Double.valueOf(0), Integer.valueOf(0));
if(sumAndCount == null && value != null)
return new MutablePair<>(Double.valueOf(value.doubleValue()), Integer.valueOf(1));
if(sumAndCount != null && value == null)
return sumAndCount;
sumAndCount.setLeft(sumAndCount.getLeft().doubleValue() + value.doubleValue());
sumAndCount.setRight(sumAndCount.getRight().intValue() + 1);
return sumAndCount;
}
示例5: average
import org.apache.commons.lang3.tuple.MutablePair; //导入方法依赖的package包/类
/**
* @see com.ottogroup.bi.streaming.operator.json.aggregate.functions.JsonContentAggregateFunction#average(org.apache.commons.lang3.tuple.Pair, java.io.Serializable)
*/
public MutablePair<Integer, Integer> average(MutablePair<Integer, Integer> sumAndCount, Integer value) throws Exception {
if(sumAndCount == null && value == null)
return new MutablePair<>(Integer.valueOf(0), Integer.valueOf(0));
if(sumAndCount == null && value != null)
return new MutablePair<>(Integer.valueOf(value.intValue()), Integer.valueOf(1));
if(sumAndCount != null && value == null)
return sumAndCount;
sumAndCount.setLeft(sumAndCount.getLeft().intValue() + value.intValue());
sumAndCount.setRight(sumAndCount.getRight().intValue() + 1);
return sumAndCount;
}
示例6: updateBlock
import org.apache.commons.lang3.tuple.MutablePair; //导入方法依赖的package包/类
public void updateBlock(long time, BlockChangeRecord record) {
MutablePair<Long, BlockChangeRecord> pair = blockChanges(record.getPosition());
if (pair.getLeft() < time) {
pair.setLeft(time);
pair.setRight(record);
}
}
示例7: resourceCsvToBatchedPair
import org.apache.commons.lang3.tuple.MutablePair; //导入方法依赖的package包/类
Pair<List<String>, List<Object[]>> resourceCsvToBatchedPair(final Resource resource)
throws IOException {
XLOGGER.entry(resource.getDescription());
// parse CSV
try (InputStreamReader isReader = new InputStreamReader(resource.getInputStream())) {
CSVParser parser = CSVFormat.DEFAULT.withHeader().withNullString("").parse(isReader);
// read header row
MutablePair<List<String>, List<Object[]>> readData = new MutablePair<>();
readData.setLeft( new ArrayList<>( parser.getHeaderMap().keySet() ) );
XLOGGER.info("Read header: " + readData.getLeft() );
// read data rows
List<Object[]> rows = new ArrayList<>();
for ( CSVRecord record : parser.getRecords() ) {
if ( ! record.isConsistent() ) {
throw new IllegalArgumentException("CSV record inconsistent: " + record);
}
List theRow = IteratorUtils.toList(record.iterator());
rows.add( theRow.toArray() );
}
readData.setRight(rows);
XLOGGER.exit("Records read: " + readData.getRight().size());
return readData;
}
}
示例8: accumulate
import org.apache.commons.lang3.tuple.MutablePair; //导入方法依赖的package包/类
@Override
public MutablePair<Double, Long> accumulate(MutablePair<Double, Long> accu, Double input)
{
accu.setLeft(accu.getLeft() * ((double)accu.getRight() / (accu.getRight() + 1)) + input / (accu.getRight() + 1));
accu.setRight(accu.getRight() + 1);
return accu;
}
示例9: merge
import org.apache.commons.lang3.tuple.MutablePair; //导入方法依赖的package包/类
@Override
public MutablePair<Double, Long> merge(MutablePair<Double, Long> accu1, MutablePair<Double, Long> accu2)
{
accu1.setLeft(accu1.getLeft() * ((double)accu1.getRight() / accu1.getRight() + accu2.getRight()) +
accu2.getLeft() * ((double)accu2.getRight() / accu1.getRight() + accu2.getRight()));
accu1.setRight(accu1.getRight() + accu2.getRight());
return accu1;
}
示例10: onEntryRemove
import org.apache.commons.lang3.tuple.MutablePair; //导入方法依赖的package包/类
/**
* Invoked when an entry of a map of one of the settings is removed.<br>
* This is used to adjust the merged map accordingly
*
* @param sc the setting of which the entry was removed
* @param entry the removed entry
*/
private synchronized void onEntryRemove(SettingsContainer sc, Map.Entry<K, V> entry) {
MutablePair<V, Integer> pair = this.mergedMap.get(entry.getKey());
if (pair != null && pair.getRight() == sc.listIndex) {
Pair<V, Integer> newVal = getIndexAndValueForKey(entry.getKey());
if (newVal != null) {
pair.setLeft(newVal.getLeft());
pair.setRight(newVal.getRight());
}
}
removeMapIfEmpty(sc.listIndex);
}
示例11: onPut
import org.apache.commons.lang3.tuple.MutablePair; //导入方法依赖的package包/类
/**
* Invoked when a mapping was put into a map of one of the settings.<br>
* This is used to adjust the merged map accordingly
*
* @param sc the setting into which the mapping was put
* @param key the key of the mapping
* @param value the value of the mapping
*/
private synchronized void onPut(SettingsContainer sc, K key, V value) {
MutablePair<V, Integer> pair = this.mergedMap.get(key);
if (pair == null)
this.mergedMap.put(key, MutablePair.of(value, sc.listIndex));
else if (pair.getRight() >= sc.listIndex) {
pair.setLeft(value);
pair.setRight(sc.listIndex);
}
}
示例12: DeferredEvent
import org.apache.commons.lang3.tuple.MutablePair; //导入方法依赖的package包/类
/**
* Allows constructing objects that will receive an eventAction() call from
* Timed after delay ticks.
*
* @param delay
* the number of ticks that should pass before this deferred event
* object's eventAction() will be called.
*/
public DeferredEvent(final long delay) {
if (delay <= 0) {
eventArrival = Timed.getFireCount();
eventAction();
received = true;
return;
}
eventArrival = Timed.calcTimeJump(delay);
MutablePair<Integer, DeferredEvent[]> simultaneousReceiverPairs = toSweep.get(eventArrival);
if (simultaneousReceiverPairs == null) {
simultaneousReceiverPairs = new MutablePair<Integer, DeferredEvent[]>(0, new DeferredEvent[5]);
toSweep.put(eventArrival, simultaneousReceiverPairs);
}
int len = simultaneousReceiverPairs.getLeft();
DeferredEvent[] simultaneousReceivers = simultaneousReceiverPairs.getRight();
if (len == simultaneousReceivers.length) {
DeferredEvent[] temp = new DeferredEvent[simultaneousReceivers.length * 2];
System.arraycopy(simultaneousReceivers, 0, temp, 0, len);
simultaneousReceivers = temp;
simultaneousReceiverPairs.setRight(temp);
}
simultaneousReceivers[len++] = this;
simultaneousReceiverPairs.setLeft(len);
if (!dispatcherSingleton.isSubscribed() || dispatcherSingleton.getNextEvent() > eventArrival) {
dispatcherSingleton.updateDispatcher();
}
}
示例13: cancel
import org.apache.commons.lang3.tuple.MutablePair; //导入方法依赖的package包/类
/**
* If the call for eventAction() is no longer necessary at the previously
* specified time then the user can cancel this call to arrive with this
* function.
*
* Calling this function will have no effect on events that are already past
* due.
*/
public void cancel() {
if (received)
return;
if (!cancelled) {
cancelled = true;
MutablePair<Integer, DeferredEvent[]> simultaneousReceiverPairs = toSweep.get(eventArrival);
if (simultaneousReceiverPairs != null) {
int len = simultaneousReceiverPairs.getLeft();
DeferredEvent[] simultaneousReceivers = simultaneousReceiverPairs.getRight();
// For performance reasons this removal operation does not keep
// the order of the array entries
for (int i = 0; i < len; i++) {
if (simultaneousReceivers[i] == this) {
len--;
if (len > i) {
simultaneousReceivers[i] = simultaneousReceivers[len];
}
simultaneousReceivers[len] = null;
break;
}
}
if (len == 0) {
toSweep.remove(eventArrival);
dispatcherSingleton.updateDispatcher();
} else {
simultaneousReceiverPairs.setLeft(len);
}
}
}
}
示例14: write
import org.apache.commons.lang3.tuple.MutablePair; //导入方法依赖的package包/类
public void write(Bundle bundle, Progress progress) throws IOException {
this.bundle = bundle;
// add offset placeholders
levelOffsetMap.clear();
bundle.entries().stream()
.filter(entry -> {
if (bundle.entries().size() == 1) {
return true;
}
String name = entry.name();
return name.equals("mainData") || name.startsWith("level");
})
.forEach(entry -> levelOffsetMap.put(entry, new MutablePair<>(0L, 0L)));
BundleHeader header = bundle.header();
header.levelByteEnd().clear();
header.levelByteEnd().addAll(levelOffsetMap.values());
header.numberOfLevelsToDownload(levelOffsetMap.size());
// write header
out.writeStruct(header);
header.headerSize((int) out.position());
// write bundle data
if (header.compressed()) {
// write data to temporary file
try (DataWriter outData = DataWriters.forFile(dataFile,
CREATE, WRITE, TRUNCATE_EXISTING)) {
writeData(outData, progress);
}
// configure LZMA encoder
LzmaEncoderProps props = new LzmaEncoderProps();
props.setDictionarySize(1 << 23); // 8 MiB
props.setNumFastBytes(273); // maximum
props.setUncompressedSize(Files.size(dataFile));
props.setEndMarkerMode(true);
// stream the temporary bundle data compressed into the bundle file
try (OutputStream os = new LzmaOutputStream(new BufferedOutputStream(out.stream()), props)) {
Files.copy(dataFile, os);
}
for (MutablePair<Long, Long> levelOffset : levelOffsetMap.values()) {
levelOffset.setLeft(out.size());
}
} else {
// write data directly to file
writeData(out, progress);
}
// update header
int fileSize = (int) out.size();
header.completeFileSize(fileSize);
header.minimumStreamedBytes(fileSize);
out.position(0);
out.writeStruct(header);
}
示例15: checkSave
import org.apache.commons.lang3.tuple.MutablePair; //导入方法依赖的package包/类
private void checkSave(Pair<StatusCode, ValueDataField> pair, MutablePair<Boolean, Boolean> changesAndErrors) {
if(pair.getLeft() == StatusCode.FIELD_INSERT || pair.getLeft() == StatusCode.FIELD_UPDATE) {
changesAndErrors.setLeft(true);
}
}