@Override public <K extends K0, V extends V0> SortedSetMultimap<K, V> build() { return Multimaps.newSortedSetMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new TreeSetSupplier<V>(comparator)); } };
@Override public <K extends K0, V extends V0> SortedSetMultimap<K, V> build() { return Multimaps.newSortedSetMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new TreeSetSupplier<V>(comparator)); } };
@Override public <K extends K0, V extends V0> SortedSetMultimap<K, V> build() { return Multimaps.newSortedSetMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new TreeSetSupplier<V>(comparator)); } };
@GwtIncompatible // SerializableTester public void testNewSortedSetMultimapSerialization() { CountingSupplier<TreeSet<Integer>> factory = new SortedSetSupplier(); Map<Color, Collection<Integer>> map = Maps.newEnumMap(Color.class); SortedSetMultimap<Color, Integer> multimap = Multimaps.newSortedSetMultimap(map, factory); multimap.putAll(Color.BLUE, asList(3, 1, 4)); multimap.putAll(Color.RED, asList(2, 7, 1, 8)); SerializableTester.reserializeAndAssert(multimap); assertEquals(INT_COMPARATOR, multimap.valueComparator()); }
public void testNewSortedSetMultimap() { CountingSupplier<TreeSet<Integer>> factory = new SortedSetSupplier(); Map<Color, Collection<Integer>> map = Maps.newEnumMap(Color.class); SortedSetMultimap<Color, Integer> multimap = Multimaps.newSortedSetMultimap(map, factory); // newSortedSetMultimap calls the factory once to determine the comparator. assertEquals(1, factory.count); multimap.putAll(Color.BLUE, asList(3, 1, 4)); assertEquals(2, factory.count); multimap.putAll(Color.RED, asList(2, 7, 1, 8)); assertEquals(3, factory.count); assertEquals("[4, 3, 1]", multimap.get(Color.BLUE).toString()); assertEquals(INT_COMPARATOR, multimap.valueComparator()); }
ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); SortedSetMultimap<String, String> sortedApi = Multimaps.newSortedSetMultimap(new HashMap<>(), TreeSet::new);
private void verifyRows(Transaction ro) { for (Map.Entry<TableReference, Set<RowRead>> tableAndRowsEntry : rowsRead.entrySet()) { TableReference table = tableAndRowsEntry.getKey(); Set<RowRead> rows = tableAndRowsEntry.getValue(); ConcurrentNavigableMap<Cell, byte[]> readsForTable = getReadsForTable(table); Multimap<ColumnSelection, byte[]> rowsReadByColumns = Multimaps.newSortedSetMultimap( Maps.newHashMap(), () -> Sets.newTreeSet(UnsignedBytes.lexicographicalComparator())); for (RowRead r : rows) { rowsReadByColumns.putAll(r.cols, r.rows); } for (ColumnSelection cols : rowsReadByColumns.keySet()) { verifyColumns(ro, table, readsForTable, rowsReadByColumns, cols); } } }
private DefaultLifecycle() { this.handlersByLevel = Multimaps.newSortedSetMultimap(new ConcurrentHashMap<LifecycleHandlerType.LifecycleLevel, Collection<LifecycleHandler<? extends KillbillService>>>(), new Supplier<SortedSet<LifecycleHandler<? extends KillbillService>>>() { @Override public SortedSet<LifecycleHandler<? extends KillbillService>> get() { return new TreeSet<LifecycleHandler<? extends KillbillService>>(); } }); }
public NamedClusterServiceLocatorImpl( ClusterInitializer clusterInitializer ) { this.clusterInitializer = clusterInitializer; readWriteLock = new ReentrantReadWriteLock(); serviceFactoryMap = Multimaps.newSortedSetMultimap( new HashMap<Class<?>, Collection<ServiceFactoryAndRanking<?>>>(), new Supplier<SortedSet<ServiceFactoryAndRanking<?>>>() { @Override public SortedSet<ServiceFactoryAndRanking<?>> get() { return new TreeSet<>( new Comparator<ServiceFactoryAndRanking<?>>() { @Override public int compare( ServiceFactoryAndRanking<?> o1, ServiceFactoryAndRanking<?> o2 ) { if ( o1.ranking == o2.ranking ) { return o1.namedClusterServiceFactory.toString().compareTo( o2.namedClusterServiceFactory.toString() ); } return o2.ranking - o1.ranking; } } ); } } ); }
private void verifyRows(Transaction ro) { for (Map.Entry<TableReference, Set<RowRead>> tableAndRowsEntry : rowsRead.entrySet()) { TableReference table = tableAndRowsEntry.getKey(); Set<RowRead> rows = tableAndRowsEntry.getValue(); ConcurrentNavigableMap<Cell, byte[]> readsForTable = getReadsForTable(table); Multimap<ColumnSelection, byte[]> rowsReadByColumns = Multimaps.newSortedSetMultimap( Maps.newHashMap(), () -> Sets.newTreeSet(UnsignedBytes.lexicographicalComparator())); for (RowRead r : rows) { rowsReadByColumns.putAll(r.cols, r.rows); } for (ColumnSelection cols : rowsReadByColumns.keySet()) { verifyColumns(ro, table, readsForTable, rowsReadByColumns, cols); } } }
@Override public <K extends K0, V extends V0> SortedSetMultimap<K, V> build() { return Multimaps.newSortedSetMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new TreeSetSupplier<V>(comparator)); } };
@Override public <K extends K0, V extends V0> SortedSetMultimap<K, V> build() { return Multimaps.newSortedSetMultimap( MultimapBuilderWithKeys.this.<K, V> createMap(), new TreeSetSupplier<V>(comparator)); } };
@Override public <K extends K0, V extends V0> SortedSetMultimap<K, V> build() { return Multimaps.newSortedSetMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new TreeSetSupplier<V>(comparator)); } };
@Override public <K extends K0, V extends V0> SortedSetMultimap<K, V> build() { return Multimaps.newSortedSetMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new TreeSetSupplier<V>(comparator)); } };
@Override public <K extends K0, V extends V0> SortedSetMultimap<K, V> build() { return Multimaps.newSortedSetMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new TreeSetSupplier<V>(comparator)); } };
Multimaps.newSortedSetMultimap( Maps.<RelNode, Collection<Correlation>>newHashMap(), new Supplier<TreeSet<Correlation>>() {
private void dataSourceSyncWithinTransaction() { m_lock.writeLock().lock(); try { /* * Make a new list with which we'll replace the existing one, that way * if something goes wrong with the DB we won't lose whatever was already * in there */ final SortedSetMultimap<Key, Value> newAlreadyDiscovered = Multimaps.newSortedSetMultimap(Maps.newHashMap(), TreeSet::new); // Fetch all non-deleted nodes final CriteriaBuilder builder = new CriteriaBuilder(OnmsNode.class); builder.ne("type", String.valueOf(NodeType.DELETED.value())); for (OnmsNode node : m_nodeDao.findMatching(builder.toCriteria())) { for (final OnmsIpInterface iface : node.getIpInterfaces()) { // Skip deleted interfaces // TODO: Refactor the 'D' value with an enumeration if ("D".equals(iface.getIsManaged())) { continue; } LOG.debug("Adding entry: {}:{} -> {}", node.getLocation().getLocationName(), iface.getIpAddress(), node.getId()); newAlreadyDiscovered.put(new Key(node.getLocation().getLocationName(), iface.getIpAddress()), new Value(node.getId(), iface.getIsSnmpPrimary())); } } m_managedAddresses.clear(); m_managedAddresses.putAll(newAlreadyDiscovered); LOG.info("dataSourceSync: initialized list of managed IP addresses with {} members", m_managedAddresses.size()); } finally { m_lock.writeLock().unlock(); } }
@GwtIncompatible // SerializableTester public void testNewSortedSetMultimapSerialization() { CountingSupplier<TreeSet<Integer>> factory = new SortedSetSupplier(); Map<Color, Collection<Integer>> map = Maps.newEnumMap(Color.class); SortedSetMultimap<Color, Integer> multimap = Multimaps.newSortedSetMultimap(map, factory); multimap.putAll(Color.BLUE, asList(3, 1, 4)); multimap.putAll(Color.RED, asList(2, 7, 1, 8)); SerializableTester.reserializeAndAssert(multimap); assertEquals(INT_COMPARATOR, multimap.valueComparator()); }
public void testNewSortedSetMultimap() { CountingSupplier<TreeSet<Integer>> factory = new SortedSetSupplier(); Map<Color, Collection<Integer>> map = Maps.newEnumMap(Color.class); SortedSetMultimap<Color, Integer> multimap = Multimaps.newSortedSetMultimap(map, factory); // newSortedSetMultimap calls the factory once to determine the comparator. assertEquals(1, factory.count); multimap.putAll(Color.BLUE, asList(3, 1, 4)); assertEquals(2, factory.count); multimap.putAll(Color.RED, asList(2, 7, 1, 8)); assertEquals(3, factory.count); assertEquals("[4, 3, 1]", multimap.get(Color.BLUE).toString()); assertEquals(INT_COMPARATOR, multimap.valueComparator()); }