本文整理汇总了Java中org.apache.commons.lang3.tuple.MutablePair类的典型用法代码示例。如果您正苦于以下问题:Java MutablePair类的具体用法?Java MutablePair怎么用?Java MutablePair使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MutablePair类属于org.apache.commons.lang3.tuple包,在下文中一共展示了MutablePair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getValidEdgePosition
import org.apache.commons.lang3.tuple.MutablePair; //导入依赖的package包/类
private void getValidEdgePosition() {
// loops through valid road end points and adds valid edges (both ships and roads)
for (CoordinatePair i : aSessionController.requestValidRoadEndpoints(aSessionController.getPlayerColor())) {
for (CoordinatePair j : aSessionController.getIntersectionsAndEdges()) {
if (aSessionController.isAdjacent(i, j)) {
Pair<CoordinatePair, CoordinatePair> edge = new MutablePair<>(i, j);
validEdges.add(edge);
for (EdgeUnit eu : aSessionController.getRoadsAndShips()) {
if (eu.hasEndpoint(i) && eu.hasEndpoint(j)) {
validEdges.remove(edge);
}
}
}
}
}
}
示例2: updateValidEdges
import org.apache.commons.lang3.tuple.MutablePair; //导入依赖的package包/类
void updateValidEdges(List<Pair<CoordinatePair,CoordinatePair>> validEdges) {
// loops through valid road end points and adds valid edges (both ships and roads)
for (CoordinatePair i : aSessionController.requestValidRoadEndpoints(aSessionController.getPlayerColor())) {
for (CoordinatePair j : aSessionController.getIntersectionsAndEdges()) {
if (aSessionController.isAdjacent(i, j)) {
Pair<CoordinatePair, CoordinatePair> edge = new MutablePair<>(i, j);
validEdges.add(edge);
for (EdgeUnit eu : aSessionController.getRoadsAndShips()) {
if (eu.hasEndpoint(i) && eu.hasEndpoint(j)) {
validEdges.remove(edge);
}
}
}
}
}
}
示例3: createChannel
import org.apache.commons.lang3.tuple.MutablePair; //导入依赖的package包/类
public static int createChannel(@Nonnull String name, @Nullable Map<ChannelProperty, String> channelProperties, @Nullable Map<ChannelPermission, Integer> permissions)
{
MutablePair<ResultType, Object> pair = MutablePair.of(ResultType.INTEGER, -1);
int id = generator++;
TeamSpeakAPI.results.put(id, pair);
final String[] msg = {"createchannel:" + name};
if (channelProperties != null)
channelProperties.forEach(((channelProperty, s) -> msg[0] += ":" + channelProperties.toString().toUpperCase() + "=" + s));
if (permissions != null)
permissions.forEach(((channelPermission, integer) -> msg[0] += ":" + channelPermission.toString().toLowerCase() + "-" + integer));
TeamSpeakAPI.publish(id, msg[0]);
try
{
synchronized (pair)
{
pair.wait(TeamSpeakAPI.TIMEOUT);
}
} catch (Exception ignored) {}
return (int)pair.getRight();
}
示例4: movePlayers
import org.apache.commons.lang3.tuple.MutablePair; //导入依赖的package包/类
public static List<UUID> movePlayers(@Nonnull List<UUID> uuids, int channelId)
{
MutablePair<ResultType, Object> pair = MutablePair.of(ResultType.UUID_LIST, new ArrayList<>());
int id = generator++;
TeamSpeakAPI.results.put(id, pair);
final String[] msg = {"move:" + channelId};
uuids.forEach(uuid -> msg[0] += ":" + uuid);
TeamSpeakAPI.publish(id, msg[0]);
try
{
synchronized (pair)
{
pair.wait(TeamSpeakAPI.TIMEOUT);
}
} catch (Exception ignored) {}
return (List<UUID>) pair.getRight();
}
示例5: getProcNetDevStats
import org.apache.commons.lang3.tuple.MutablePair; //导入依赖的package包/类
public static MutablePair<Long, Long> getProcNetDevStats() throws Exception {
ProcessBuilder ps = new ProcessBuilder("cat", "/proc/net/dev");
Process pr = ps.start();
pr.waitFor();
BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line;
int counter = 0;
long receivedBytes = 0;
long outBytes = 0;
while ((line = in.readLine()) != null) {
System.out.println(counter + ": " + line);
if (line.contains("eth0")) {
String[] strs = line.split(" ");
receivedBytes = Long.parseLong(strs[3]);
outBytes = Long.parseLong(strs[41]);
System.out.println(" inBytes = " + receivedBytes + " outBytes = " + outBytes);
}
counter++;
}
in.close();
MutablePair<Long, Long> result = new MutablePair<>(receivedBytes, outBytes);
return result;
}
示例6: copyMap
import org.apache.commons.lang3.tuple.MutablePair; //导入依赖的package包/类
public Map<String, MutablePair<String, CommentsNodeImpl>> copyMap(CommentsNodeImpl parent)
{
Map<String, MutablePair<String, CommentsNodeImpl>> result = new HashMap<>(this.dataMap.size());
for (Entry<String, MutablePair<String, CommentsNodeImpl>> entry : this.dataMap.entrySet())
{
String keyToCpy = entry.getKey();
MutablePair<String, CommentsNodeImpl> valueToCpy = entry.getValue();
CommentsNodeImpl nodeToCpy = valueToCpy.getRight();
CommentsNodeImpl copiedNode;
if (nodeToCpy == null)
{
copiedNode = null;
}
else
{
copiedNode = new CommentsNodeImpl(parent);
copiedNode.dataMap.putAll(nodeToCpy.copyMap(parent));
}
MutablePair<String, CommentsNodeImpl> copied = new MutablePair<>(valueToCpy.getLeft(), copiedNode);
result.put(keyToCpy, copied);
}
return result;
}
示例7: trim
import org.apache.commons.lang3.tuple.MutablePair; //导入依赖的package包/类
@Override
public void trim()
{
for (Iterator<Entry<String, MutablePair<String, CommentsNodeImpl>>> iterator = this.dataMap.entrySet().iterator(); iterator.hasNext(); )
{
Entry<String, MutablePair<String, CommentsNodeImpl>> entry = iterator.next();
MutablePair<String, CommentsNodeImpl> value = entry.getValue();
CommentsNodeImpl right = value.getRight();
if (right != null)
{
right.trim();
}
if (((right == null) || right.dataMap.isEmpty()) && (value.getLeft() == null))
{
iterator.remove();
continue;
}
if (right == null)
{
continue;
}
right.trim();
}
}
示例8: getComment
import org.apache.commons.lang3.tuple.MutablePair; //导入依赖的package包/类
@Override
@Nullable
public String getComment(String path)
{
MutablePair<String, CommentsNodeImpl> nodePair = this.dataMap.get(path);
if (nodePair != null)
{
String comment = nodePair.getLeft();
if (comment != null)
{
return comment;
}
}
MutablePair<String, CommentsNodeImpl> anyNodePair = this.dataMap.get(ANY);
if (anyNodePair != null)
{
return anyNodePair.getKey();
}
return null;
}
示例9: getNode
import org.apache.commons.lang3.tuple.MutablePair; //导入依赖的package包/类
@Override
public CommentsNodeImpl getNode(String path)
{
MutablePair<String, CommentsNodeImpl> nodePair = this.dataMap.get(path);
CommentsNodeImpl node = (nodePair == null) ? null : nodePair.getRight();
if (node == null)
{
MutablePair<String, CommentsNodeImpl> anyNodePair = this.dataMap.get(ANY);
node = (anyNodePair == null) ? null : anyNodePair.getRight();
if (node == null)
{
CommentsNodeImpl commentsNode = new CommentsNodeImpl(this);
if (nodePair != null)
{
nodePair.setRight(commentsNode);
}
else
{
this.dataMap.put(path, new MutablePair<>(null, commentsNode));
}
return commentsNode;
}
return node;
}
return node;
}
示例10: 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;
}
示例11: reissueContainerRequests
import org.apache.commons.lang3.tuple.MutablePair; //导入依赖的package包/类
/**
* Issue requests to AM RM Client again if previous container requests expired and were not allocated by Yarn
* @param amRmClient
* @param requestedResources
* @param loopCounter
* @param resourceRequestor
* @param containerRequests
* @param removedContainerRequests
*/
public void reissueContainerRequests(AMRMClient<ContainerRequest> amRmClient, Map<StreamingContainerAgent.ContainerStartRequest, MutablePair<Integer, ContainerRequest>> requestedResources, int loopCounter, ResourceRequestHandler resourceRequestor, List<ContainerRequest> containerRequests, List<ContainerRequest> removedContainerRequests)
{
if (!requestedResources.isEmpty()) {
for (Map.Entry<StreamingContainerAgent.ContainerStartRequest, MutablePair<Integer, ContainerRequest>> entry : requestedResources.entrySet()) {
/*
* Create container requests again if pending requests were not allocated by Yarn till timeout.
*/
if ((loopCounter - entry.getValue().getKey()) > NUMBER_MISSED_HEARTBEATS) {
StreamingContainerAgent.ContainerStartRequest csr = entry.getKey();
LOG.debug("Request for container {} timed out. Re-requesting container", csr.container);
removedContainerRequests.add(entry.getValue().getRight());
ContainerRequest cr = resourceRequestor.createContainerRequest(csr, false);
entry.getValue().setLeft(loopCounter);
entry.getValue().setRight(cr);
containerRequests.add(cr);
}
}
}
}
示例12: emitTuples
import org.apache.commons.lang3.tuple.MutablePair; //导入依赖的package包/类
/**
* Implement InputOperator Interface.
*/
@Override
public void emitTuples()
{
if (currentWindowId <= windowDataManager.getLargestCompletedWindow()) {
return;
}
int count = consumer.getQueueSize();
if (maxTuplesPerWindow > 0) {
count = Math.min(count, maxTuplesPerWindow - emitCount);
}
for (int i = 0; i < count; i++) {
Pair<String, Record> data = consumer.pollRecord();
String shardId = data.getFirst();
String recordId = data.getSecond().getSequenceNumber();
emitTuple(data);
MutablePair<String, Integer> shardOffsetAndCount = currentWindowRecoveryState.get(shardId);
if (shardOffsetAndCount == null) {
currentWindowRecoveryState.put(shardId, new MutablePair<String, Integer>(recordId, 1));
} else {
shardOffsetAndCount.setRight(shardOffsetAndCount.right + 1);
}
shardPosition.put(shardId, recordId);
}
emitCount += count;
}
示例13: processTopN
import org.apache.commons.lang3.tuple.MutablePair; //导入依赖的package包/类
private void processTopN(HashMap<String, Number> topNMap, HashMap<String, Object> schemaObj)
{
@SuppressWarnings("unchecked")
HashMap<String, Object>[] result = (HashMap<String, Object>[])Array.newInstance(HashMap.class, topNMap.size());
int j = 0;
for (Entry<String, Number> e : topNMap.entrySet()) {
result[j] = new HashMap<String, Object>();
result[j].put("name", e.getKey());
String val = formatter.format(e.getValue());
result[j++].put("value", val);
}
if (operator.isWebSocketConnected) {
schemaObj.put("type", "topN");
schemaObj.put("n", operator.nInTopN);
operator.wsoo.input.process(new MutablePair<String, Object>(operator.getFullTopic(operator.topNTopic, schemaObj), result));
}
else {
operator.coo.input.process(topNMap);
}
}
示例14: process
import org.apache.commons.lang3.tuple.MutablePair; //导入依赖的package包/类
@Override
public void process(TimeSeriesData[] tuple)
{
@SuppressWarnings({"unchecked", "rawtypes"})
HashMap<String, Number>[] timeseriesMapData = new HashMap[tuple.length];
int i = 0;
for (TimeSeriesData data : tuple) {
HashMap<String, Number> timeseriesMap = Maps.newHashMapWithExpectedSize(2);
timeseriesMap.put("timestamp", data.time);
timeseriesMap.put("value", data.data);
timeseriesMapData[i++] = timeseriesMap;
}
if (operator.isWebSocketConnected) {
HashMap<String, Object> schemaObj = new HashMap<>();
schemaObj.put("type", "timeseries");
schemaObj.put("minValue", operator.timeSeriesMin);
schemaObj.put("maxValue", operator.timeSeriesMax);
operator.wsoo.input.process(new MutablePair<String, Object>(operator.getFullTopic( operator.timeSeriesTopic, schemaObj), timeseriesMapData));
} else {
operator.coo.input.process(tuple);
}
}
示例15: populateDAG
import org.apache.commons.lang3.tuple.MutablePair; //导入依赖的package包/类
@Override
public void populateDAG(DAG dag, Configuration configuration)
{
RandomNumberPairGenerator inputOperator = new RandomNumberPairGenerator();
WindowedOperatorImpl<MutablePair<Double, Double>, MutablePair<MutableLong, MutableLong>, Double> windowedOperator = new WindowedOperatorImpl<>();
Accumulation<MutablePair<Double, Double>, MutablePair<MutableLong, MutableLong>, Double> piAccumulation = new PiAccumulation();
windowedOperator.setAccumulation(piAccumulation);
windowedOperator.setDataStorage(new InMemoryWindowedStorage<MutablePair<MutableLong, MutableLong>>());
windowedOperator.setWindowStateStorage(new InMemoryWindowedStorage<WindowState>());
windowedOperator.setWindowOption(new WindowOption.GlobalWindow());
windowedOperator.setTriggerOption(TriggerOption.AtWatermark().withEarlyFiringsAtEvery(Duration.millis(1000)).accumulatingFiredPanes());
ConsoleOutputOperator outputOperator = new ConsoleOutputOperator();
dag.addOperator("inputOperator", inputOperator);
dag.addOperator("windowedOperator", windowedOperator);
dag.addOperator("outputOperator", outputOperator);
dag.addStream("input_windowed", inputOperator.output, windowedOperator.input);
dag.addStream("windowed_output", windowedOperator.output, outputOperator.input);
}