@Override public Set<V> values() { return inverse.keySet(); } }
@Override public Set<V> values() { return inverse.keySet(); } }
@Override public Set<V> values() { return inverse().keySet(); }
/** Retrieve the native object for given id. Throws if object with that id cannot be found */ public synchronized T getNativeObject(long nativeId) { T object = nativeObjToIdMap.get(nativeId); if (object != null) { return object; } else { throw new NullPointerException( String.format( "Could not find object with nativeId: %d. Currently registered ids: %s", nativeId, nativeObjToIdMap.keySet())); } }
@Implementation(minSdk = LOLLIPOP) protected List<UserHandle> getUserProfiles() { return ImmutableList.copyOf(userProfiles.keySet()); }
@Override public Set<V> values() { return inverse().keySet(); }
/** See {@link SynchronizedBiMapTest} for more tests. */ public void testSynchronizedBiMap() { BiMap<String, Integer> bimap = HashBiMap.create(); bimap.put("one", 1); BiMap<String, Integer> sync = Maps.synchronizedBiMap(bimap); bimap.put("two", 2); sync.put("three", 3); assertEquals(ImmutableSet.of(1, 2, 3), bimap.inverse().keySet()); assertEquals(ImmutableSet.of(1, 2, 3), sync.inverse().keySet()); }
@SuppressWarnings("unchecked") @MapFeature.Require(SUPPORTS_REMOVE) @CollectionSize.Require(absent = ZERO) public void testRemoveFromInverseKeySetRemovesFromForward() { getMap().inverse().keySet().remove(v0()); expectMissing(e0()); }
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE) @CollectionSize.Require(absent = ZERO) public void testKeySetIteratorRemove() { int initialSize = getNumElements(); Iterator<K> iterator = getMap().keySet().iterator(); iterator.next(); iterator.remove(); assertEquals(initialSize - 1, getMap().size()); assertEquals(initialSize - 1, getMap().inverse().size()); } }
@MapFeature.Require(SUPPORTS_REMOVE) public void testClearInverseKeySetClears() { BiMap<V, K> inv = getMap().inverse(); inv.keySet().clear(); assertTrue(getMap().isEmpty()); assertTrue(inv.isEmpty()); }
@SuppressWarnings("unchecked") @MapFeature.Require(SUPPORTS_REMOVE) @CollectionSize.Require(absent = ZERO) public void testRemoveKeyFromKeySetRemovesFromInverse() { getMap().keySet().remove(k0()); expectMissing(e0()); }
public void testIdentityKeySetIteratorRemove() { BiMap<Integer, String> bimap = new AbstractBiMap<Integer, String>( new IdentityHashMap<Integer, String>(), new IdentityHashMap<String, Integer>()) {}; bimap.put(1, "one"); bimap.put(2, "two"); bimap.put(3, "three"); Iterator<Integer> iterator = bimap.keySet().iterator(); iterator.next(); iterator.next(); iterator.remove(); iterator.next(); iterator.remove(); assertEquals(1, bimap.size()); assertEquals(1, bimap.inverse().size()); }
@MapFeature.Require(SUPPORTS_REMOVE) public void testKeySetClearClearsInverse() { BiMap<V, K> inv = getMap().inverse(); getMap().keySet().clear(); assertTrue(getMap().isEmpty()); assertTrue(inv.isEmpty()); }
private PlanWithProperties planAndEnforce( PlanNode node, HashComputationSet requiredHashes, boolean pruneExtraHashSymbols, HashComputationSet preferredHashes) { PlanWithProperties result = plan(node, preferredHashes); boolean preferenceSatisfied; if (pruneExtraHashSymbols) { // Make sure that // (1) result has all required hashes // (2) any extra hashes are preferred hashes (e.g. no pruning is needed) Set<HashComputation> resultHashes = result.getHashSymbols().keySet(); Set<HashComputation> requiredAndPreferredHashes = ImmutableSet.<HashComputation>builder() .addAll(requiredHashes.getHashes()) .addAll(preferredHashes.getHashes()) .build(); preferenceSatisfied = resultHashes.containsAll(requiredHashes.getHashes()) && requiredAndPreferredHashes.containsAll(resultHashes); } else { preferenceSatisfied = result.getHashSymbols().keySet().containsAll(requiredHashes.getHashes()); } if (preferenceSatisfied) { return result; } return enforce(result, requiredHashes); }
public static Set<String> getOrganizationNames() { Subject currentUser = getSubject(); if ( currentUser == null ) { return null; } if ( !currentUser.hasRole( ROLE_ORGANIZATION_ADMIN ) ) { return null; } BiMap<UUID, String> organizations = getOrganizations(); if ( organizations == null ) { return null; } return organizations.inverse().keySet(); }
return inverse.keySet();
public void testValuesIteratorRemove() { // The enum orderings are alphabetical, leading to the bimap and its inverse // having inconsistent iteration orderings. Map<Currency, Country> map = ImmutableMap.of( Currency.DOLLAR, Country.CANADA, Currency.PESO, Country.CHILE, Currency.FRANC, Country.SWITZERLAND); EnumBiMap<Currency, Country> bimap = EnumBiMap.create(map); Iterator<Currency> iter = bimap.keySet().iterator(); assertEquals(Currency.DOLLAR, iter.next()); assertEquals(Currency.FRANC, iter.next()); iter.remove(); // forward map ordered by currency assertThat(bimap.keySet()).containsExactly(Currency.DOLLAR, Currency.PESO).inOrder(); // forward map ordered by currency (even for country values) assertThat(bimap.values()).containsExactly(Country.CANADA, Country.CHILE).inOrder(); // backward map ordered by country assertThat(bimap.inverse().keySet()).containsExactly(Country.CANADA, Country.CHILE).inOrder(); // backward map ordered by country (even for currency values) assertThat(bimap.inverse().values()).containsExactly(Currency.DOLLAR, Currency.PESO).inOrder(); }
public void testKeySetIteratorRemove() { // The enum orderings are alphabetical, leading to the bimap and its inverse // having inconsistent iteration orderings. Map<Currency, Country> map = ImmutableMap.of( Currency.DOLLAR, Country.CANADA, Currency.PESO, Country.CHILE, Currency.FRANC, Country.SWITZERLAND); EnumBiMap<Currency, Country> bimap = EnumBiMap.create(map); Iterator<Currency> iter = bimap.keySet().iterator(); assertEquals(Currency.DOLLAR, iter.next()); iter.remove(); // forward map ordered by currency assertThat(bimap.keySet()).containsExactly(Currency.FRANC, Currency.PESO).inOrder(); // forward map ordered by currency (even for country values) assertThat(bimap.values()).containsExactly(Country.SWITZERLAND, Country.CHILE).inOrder(); // backward map ordered by country assertThat(bimap.inverse().keySet()) .containsExactly(Country.CHILE, Country.SWITZERLAND) .inOrder(); // backward map ordered by country (even for currency values) assertThat(bimap.inverse().values()).containsExactly(Currency.PESO, Currency.FRANC).inOrder(); }
public void testIterationOrder() { // The enum orderings are alphabetical, leading to the bimap and its inverse // having inconsistent iteration orderings. Map<Currency, Country> map = ImmutableMap.of( Currency.DOLLAR, Country.CANADA, Currency.PESO, Country.CHILE, Currency.FRANC, Country.SWITZERLAND); EnumBiMap<Currency, Country> bimap = EnumBiMap.create(map); // forward map ordered by currency assertThat(bimap.keySet()) .containsExactly(Currency.DOLLAR, Currency.FRANC, Currency.PESO) .inOrder(); // forward map ordered by currency (even for country values) assertThat(bimap.values()) .containsExactly(Country.CANADA, Country.SWITZERLAND, Country.CHILE) .inOrder(); // backward map ordered by country assertThat(bimap.inverse().keySet()) .containsExactly(Country.CANADA, Country.CHILE, Country.SWITZERLAND) .inOrder(); // backward map ordered by country (even for currency values) assertThat(bimap.inverse().values()) .containsExactly(Currency.DOLLAR, Currency.PESO, Currency.FRANC) .inOrder(); }
List<? extends E> missing = findNotIndexed(expected, mapping.values()); if (!missing.isEmpty()) { List<? extends A> extra = findNotIndexed(actual, mapping.keySet()); subject.failWithoutActual( facts(