Java Code Examples for com.google.common.collect.Table#containsRow()
The following examples show how to use
com.google.common.collect.Table#containsRow() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Transaction.java From sequence-mining with GNU General Public License v3.0 | 6 votes |
/** Calculate cached cost for structural EM-step */ private double calculateCachedCost(final Table<Sequence, Integer, Double> sequences, final Multiset<Sequence> covering) { double totalCost = 0; int lenCovering = 0; for (final Sequence seq : cachedSequences.rowKeySet()) { if (sequences.containsRow(seq)) { if (covering.contains(seq)) { final int occur = covering.count(seq); totalCost += -Math.log(sequences.get(seq, occur)); for (int m = 1; m <= occur; m++) { totalCost += sumLogRange(lenCovering + 1, lenCovering + seq.size()); lenCovering += seq.size(); } } else if (seq.size() == 1 && sum(cachedSequences.row(seq).values()) == 0.) { continue; // ignore seqs used to fill incomplete coverings } else { totalCost += -Math.log(sequences.get(seq, 0)); } } } return totalCost; }
Example 2
Source File: ToolchainResolutionFunction.java From bazel with Apache License 2.0 | 6 votes |
/** * Finds the first platform from {@code availableExecutionPlatformKeys} that is present in {@code * resolvedToolchains} and has all required toolchain types. */ private static Optional<ConfiguredTargetKey> findExecutionPlatformForToolchains( ImmutableSet<ToolchainTypeInfo> requiredToolchainTypes, ImmutableList<ConfiguredTargetKey> availableExecutionPlatformKeys, Table<ConfiguredTargetKey, ToolchainTypeInfo, Label> resolvedToolchains) { for (ConfiguredTargetKey executionPlatformKey : availableExecutionPlatformKeys) { if (!resolvedToolchains.containsRow(executionPlatformKey)) { continue; } Map<ToolchainTypeInfo, Label> toolchains = resolvedToolchains.row(executionPlatformKey); if (!toolchains.keySet().containsAll(requiredToolchainTypes)) { // Not all toolchains are present, ignore this execution platform. continue; } return Optional.of(executionPlatformKey); } return Optional.empty(); }
Example 3
Source File: GuavaTableUnitTest.java From tutorials with MIT License | 6 votes |
@Test public void givenTable_whenContains_returnsSuccessfully() { final Table<String, String, Integer> universityCourseSeatTable = HashBasedTable.create(); universityCourseSeatTable.put("Mumbai", "Chemical", 120); universityCourseSeatTable.put("Mumbai", "IT", 60); universityCourseSeatTable.put("Harvard", "Electrical", 60); universityCourseSeatTable.put("Harvard", "IT", 120); final boolean entryIsPresent = universityCourseSeatTable.contains("Mumbai", "IT"); final boolean entryIsAbsent = universityCourseSeatTable.contains("Oxford", "IT"); final boolean courseIsPresent = universityCourseSeatTable.containsColumn("IT"); final boolean universityIsPresent = universityCourseSeatTable.containsRow("Mumbai"); final boolean seatCountIsPresent = universityCourseSeatTable.containsValue(60); assertThat(entryIsPresent).isEqualTo(true); assertThat(entryIsAbsent).isEqualTo(false); assertThat(courseIsPresent).isEqualTo(true); assertThat(universityIsPresent).isEqualTo(true); assertThat(seatCountIsPresent).isEqualTo(true); }
Example 4
Source File: Guava.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
@ExpectWarning(value="GC", num=9) public static void testTable(Table<String, Integer, Long> t) { t.contains("x", "x"); t.contains(1, 1); t.containsRow(1); t.containsColumn("x"); t.containsValue(1); t.get("x", "x"); t.get(1, 1); t.remove("x", "x"); t.remove(1, 1); }
Example 5
Source File: Guava.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
@NoWarning(value="GC") public static void testTableOK(Table<String, Integer, Long> t) { t.contains("x", 1); t.containsRow("x"); t.containsColumn(1); t.containsValue(1L); t.get("x", 1); t.remove("x", 1); }