List of usage examples for org.apache.commons.lang3.tuple Pair getLeft
public abstract L getLeft();
Gets the left element from this pair.
When treated as a key-value pair, this is the key.
From source file:edu.umd.umiacs.clip.tools.math.CorrelationUtils.java
public static double pr(final double[] xUnsorted, final double[] yUnsorted) { Pair<double[], double[]> pairs = sort(xUnsorted, yUnsorted); double[] x = minMaxScale(pairs.getLeft()); double[] y = minMaxScale(pairs.getRight()); return range(1, x.length).parallel() .mapToDouble(i -> x[i] * (range(0, i).mapToDouble(j -> (x[j] - x[i]) * (y[j] - y[i])).sum()) / (Math.sqrt((range(0, i).mapToDouble(j -> Math.pow(x[j] - x[i], 2)).sum()) * (range(0, i).mapToDouble(j -> Math.pow(y[j] - y[i], 2)).sum())))) .sum() / range(1, x.length).mapToDouble(i -> x[i]).sum(); }
From source file:edu.uci.ics.hyracks.control.cc.partitions.PartitionUtils.java
public static void reportPartitionMatch(ClusterControllerService ccs, final PartitionId pid, Pair<PartitionDescriptor, PartitionRequest> match) throws Exception { PartitionDescriptor desc = match.getLeft(); PartitionRequest req = match.getRight(); NodeControllerState producerNCS = ccs.getNodeMap().get(desc.getNodeId()); NodeControllerState requestorNCS = ccs.getNodeMap().get(req.getNodeId()); final NetworkAddress dataport = producerNCS.getDataPort(); final INodeController requestorNC = requestorNCS.getNodeController(); requestorNC.reportPartitionAvailability(pid, dataport); }
From source file:ivorius.ivtoolkit.rendering.grid.BlockQuadCache.java
public static GridQuadCache<?> createQuadCache(final IvBlockCollection blockCollection, float[] scale) { final Object handle = new Object(); final int[] size = { blockCollection.width, blockCollection.height, blockCollection.length }; return GridQuadCache.createQuadCache(size, scale, new Function<Pair<BlockCoord, ForgeDirection>, Object>() { @Nullable//from w ww.j a v a 2 s . c om @Override public Object apply(Pair<BlockCoord, ForgeDirection> input) { Block block = blockCollection.getBlock(input.getLeft()); return block.isOpaqueCube() && blockCollection.shouldRenderSide(input.getLeft(), input.getRight()) ? handle : null; } }); }
From source file:com.github.steveash.jg2p.Grams.java
public static Iterable<Pair<String, String>> wordPairsToAllGrams(Iterable<? extends Pair<Word, Word>> words, final GramOptions opts) { return concat(transform(words, new Function<Pair<Word, Word>, Iterable<Pair<String, String>>>() { @Override/*from ww w. jav a 2 s .c o m*/ public Iterable<Pair<String, String>> apply(Pair<Word, Word> input) { return gramProduct(input.getLeft(), input.getRight(), opts); } })); }
From source file:blusunrize.immersiveengineering.api.tool.RailgunHandler.java
public static RailgunProjectileProperties getProjectileProperties(ItemStack stack) { for (Pair<IngredientStack, RailgunProjectileProperties> pair : projectilePropertyMap) if (pair.getLeft().matchesItemStack(stack)) return pair.getRight(); return null;/*from w w w. ja v a2s . co m*/ }
From source file:com.github.blindpirate.gogradle.util.MapUtils.java
private static <K, V> Map<K, V> asMapWithoutNull(Pair<K, V>... entries) { Map<K, V> ret = new HashMap<>(); for (Pair<K, V> entry : entries) { if (entry.getLeft() != null && entry.getRight() != null) { ret.put(entry.getLeft(), entry.getRight()); }/*from w w w . ja va 2s. c o m*/ } return ret; }
From source file:com.github.blindpirate.gogradle.util.MapUtils.java
private static <K, V> Map<K, V> asMap(Pair<K, V>... entries) { Map<K, V> ret = new HashMap<>(); for (Pair<K, V> entry : entries) { ret.put(entry.getLeft(), entry.getRight()); }/*from w w w. ja va 2 s .c o m*/ return ret; }
From source file:com.twitter.distributedlog.ZooKeeperClusterTestCase.java
@BeforeClass public static void setupZooKeeper() throws Exception { zkDir = IOUtils.createTempDir("zookeeper", ZooKeeperClusterTestCase.class.getName()); Pair<ZooKeeperServerShim, Integer> serverAndPort = LocalDLMEmulator.runZookeeperOnAnyPort(zkDir); zks = serverAndPort.getLeft(); zkPort = serverAndPort.getRight();/*from w ww.ja va 2 s . c o m*/ zkServers = "127.0.0.1:" + zkPort; }
From source file:net.mindengine.blogix.tests.RequestSampleParser.java
public static String[][] loadSamplesAsDataProvider(File file) throws IOException, URISyntaxException { List<Pair<String, String>> checks = loadRequestChecksFromFile(file); String[][] arr = new String[checks.size()][]; int i = -1;//from ww w.j av a2 s. c om for (Pair<String, String> check : checks) { i++; arr[i] = new String[] { check.getLeft(), check.getRight() }; } return arr; }
From source file:com.netflix.spinnaker.clouddriver.kubernetes.v2.op.handler.CanLoadBalance.java
static CanLoadBalance lookupProperties(KubernetesResourcePropertyRegistry registry, String accountName, Pair<KubernetesKind, String> name) { KubernetesResourceProperties loadBalancerProperties = registry.get(accountName, name.getLeft()); if (loadBalancerProperties == null) { throw new IllegalArgumentException( "No properties are registered for " + name + ", are you sure it's a valid load balancer type?"); }/*from w w w . jav a 2s.c o m*/ KubernetesHandler loadBalancerHandler = loadBalancerProperties.getHandler(); if (loadBalancerHandler == null) { throw new IllegalArgumentException( "No handler registered for " + name + ", are you sure it's a valid load balancer type?"); } if (!(loadBalancerHandler instanceof CanLoadBalance)) { throw new IllegalArgumentException( "No support for load balancing via " + name + " exists in Spinnaker"); } return (CanLoadBalance) loadBalancerHandler; }