private synchronized void purgeAll() { purgeBatches(this.batches.asMap().values().iterator()); }
private synchronized void purgeExpiredBatches() { long now = System.currentTimeMillis(); purgeBatches(this.batches.asMap().subMap(Long.MIN_VALUE, now).values().iterator()); }
@Override protected Set<String> create(String[] elements) { TreeMultimap<Integer, String> multimap = TreeMultimap.create(Ordering.natural(), Ordering.natural().nullsFirst()); multimap.putAll(1, Arrays.asList(elements)); return (Set<String>) multimap.asMap().entrySet().iterator().next().getValue(); }
@Override public NavigableMap<String, Collection<String>> create(Object... elements) { TreeMultimap<String, String> multimap = TreeMultimap.create(); for (Object o : elements) { @SuppressWarnings("unchecked") Entry<String, Collection<String>> entry = (Entry<String, Collection<String>>) o; checkArgument(!multimap.containsKey(entry.getKey())); multimap.putAll(entry.getKey(), entry.getValue()); } return multimap.asMap(); }
public void testOrderedAsMapEntries() { TreeMultimap<String, Integer> multimap = createPopulate(); Iterator<Entry<String, Collection<Integer>>> iterator = multimap.asMap().entrySet().iterator(); Entry<String, Collection<Integer>> entry = iterator.next(); assertEquals("foo", entry.getKey()); assertThat(entry.getValue()).containsExactly(1, 3, 7); entry = iterator.next(); assertEquals("google", entry.getKey()); assertThat(entry.getValue()).containsExactly(2, 6); entry = iterator.next(); assertEquals("tree", entry.getKey()); assertThat(entry.getValue()).containsExactly(0, 4); }
public void testOrderedAsMapEntries() { TreeMultimap<String, Integer> multimap = createPopulate(); Iterator<Entry<String, Collection<Integer>>> iterator = multimap.asMap().entrySet().iterator(); Entry<String, Collection<Integer>> entry = iterator.next(); assertEquals(null, entry.getKey()); assertThat(entry.getValue()).containsExactly(7, 3, 1); entry = iterator.next(); assertEquals("tree", entry.getKey()); assertThat(entry.getValue()).containsExactly(null, 0); entry = iterator.next(); assertEquals("google", entry.getKey()); assertThat(entry.getValue()).containsExactly(6, 2); }
public void testTreeMultimapAsMapSorted() { TreeMultimap<String, Integer> multimap = createPopulate(); SortedMap<String, Collection<Integer>> asMap = multimap.asMap(); assertEquals(Ordering.natural(), asMap.comparator()); assertEquals("foo", asMap.firstKey()); assertEquals("tree", asMap.lastKey()); Set<Integer> fooValues = ImmutableSet.of(1, 3, 7); Set<Integer> googleValues = ImmutableSet.of(2, 6); Set<Integer> treeValues = ImmutableSet.of(4, 0); assertEquals(ImmutableMap.of("google", googleValues, "tree", treeValues), asMap.tailMap("g")); assertEquals(ImmutableMap.of("google", googleValues, "foo", fooValues), asMap.headMap("h")); assertEquals(ImmutableMap.of("google", googleValues), asMap.subMap("g", "h")); }
@Override protected Map<String, Collection<Integer>> makeEmptyMap() { return createMultimap().asMap().subMap("e", "p"); }
@Override protected Map<String, Collection<Integer>> makePopulatedMap() { TreeMultimap<String, Integer> multimap = createMultimap(); multimap.put("f", 1); multimap.put("f", 2); multimap.put("g", 3); multimap.put("h", 4); return multimap.asMap().subMap("e", "p"); }
for (Map.Entry<String, Collection<SingularityDeployHistory>> deployHistoryForRequest : deployHistoryByRequestId.asMap().entrySet()) { schedulerLock.runWithRequestLock(() -> { int i = 0;
/** * @return The controller routes, indexed by their path. */ public NavigableMap<String, Collection<ControllerRouteModel<T>>> getRoutes() { return routes.asMap(); }
// Create my map TreeMultimap<Date, Long> mapRetrieveMostRecent = TreeMultimap.create(); ... // Put an entry into my map mapRetrieveMostRecent.put(xDate, id); ... // Get all the ids corresponding to the most recent date Collection<Long> ids = mapRetrieveMostRecent.asMap().lastEntry().getValue();
public void publish(final List<StepImplementationsDescriptor> stepimplementationDescriptors) { TreeMultimap<String, StepDescriptor> sections = TreeMultimap.create(Ordering.natural(), expressionComparator); for (final StepImplementationsDescriptor descriptor : stepimplementationDescriptors) { for (final StepDescriptor step : descriptor.getExpressions()) { sections.put(getSection(step), step); } } writeToFile(gson.toJson(sections.asMap())); }
private Map<OWLIndividual, ? extends Collection<OWLIndividual>> getTargetIndividuals(OWLObjectPropertyExpression ope) { return ope.isAnonymous() ? Multimaps.invertFrom( MapUtils.createSortedMultiMap(opPos.get(ope.getNamedProperty())), TreeMultimap.create()).asMap() : opPos.get(ope.getNamedProperty()); }
@Override protected void doExecute() { MetricsService metricsService = get(MetricsService.class); MetricFilter filter = metricName != null ? (name, metric) -> name.equals(metricName) : MetricFilter.ALL; TreeMultimap<String, Metric> matched = listMetrics(metricsService, filter); matched.asMap().forEach((name, metrics) -> { if (outputJson()) { metrics.forEach(metric -> print("%s", json(metric))); } else { metrics.forEach(metric -> printMetric(name, metric)); } }); }
@Override protected Set<String> create(String[] elements) { TreeMultimap<Integer, String> multimap = TreeMultimap.create( Ordering.natural(), Ordering.natural().nullsFirst()); multimap.putAll(1, Arrays.asList(elements)); return (Set<String>) multimap.asMap().entrySet().iterator().next().getValue(); }
@Override public NavigableMap<String, Collection<String>> create(Object... elements) { TreeMultimap<String, String> multimap = TreeMultimap.create(); for (Object o : elements) { @SuppressWarnings("unchecked") Entry<String, Collection<String>> entry = (Entry<String, Collection<String>>) o; checkArgument(!multimap.containsKey(entry.getKey())); multimap.putAll(entry.getKey(), entry.getValue()); } return multimap.asMap(); }
public void testOrderedAsMapEntries() { TreeMultimap<String, Integer> multimap = createPopulate(); Iterator<Map.Entry<String, Collection<Integer>>> iterator = multimap.asMap().entrySet().iterator(); Map.Entry<String, Collection<Integer>> entry = iterator.next(); assertEquals("foo", entry.getKey()); assertThat(entry.getValue()).containsExactly(1, 3, 7); entry = iterator.next(); assertEquals("google", entry.getKey()); assertThat(entry.getValue()).containsExactly(2, 6); entry = iterator.next(); assertEquals("tree", entry.getKey()); assertThat(entry.getValue()).containsExactly(0, 4); }
@Override protected Map<String, Collection<Integer>> makeEmptyMap() { return createMultimap().asMap().subMap("e", "p"); }
@Override protected Map<String, Collection<Integer>> makePopulatedMap() { TreeMultimap<String, Integer> multimap = createMultimap(); multimap.put("f", 1); multimap.put("f", 2); multimap.put("g", 3); multimap.put("h", 4); return multimap.asMap().subMap("e", "p"); }