public Collection<Stream> getByName(String name) { return nameToStream.get(name); }
@Override public SortedSet<V> get(K key) { synchronized (mutex) { return sortedSet(delegate().get(key), mutex); } }
@Override public SortedSet<V> get(K key) { return Collections.unmodifiableSortedSet(delegate().get(key)); }
@Override public SortedSet<V> get(@Nullable K key) { return delegate().get(key); }
@Override public SortedSet<V> get(K key) { synchronized (mutex) { return sortedSet(delegate().get(key), mutex); } }
@Override public SortedSet<V> get(K key) { return Collections.unmodifiableSortedSet(delegate().get(key)); }
@Override public SortedSet<V> get(@NullableDecl K key) { return delegate().get(key); }
public void testValueComparator() { assertEquals(multimap().valueComparator(), multimap().get(k0()).comparator()); } }
@Override public SortedSet<V> get(@NullableDecl K key) { return delegate().get(key); }
private void invokeDelayedOperations(long currentWorldTime) { List<EntityRef> operationsToInvoke = new LinkedList<>(); Iterator<Long> scheduledOperationsIterator = delayedOperationsSortedByTime.keySet().iterator(); long processedTime; while (scheduledOperationsIterator.hasNext()) { processedTime = scheduledOperationsIterator.next(); if (processedTime > currentWorldTime) { break; } operationsToInvoke.addAll(delayedOperationsSortedByTime.get(processedTime)); scheduledOperationsIterator.remove(); } operationsToInvoke.stream().filter(EntityRef::exists).forEach(delayedEntity -> { final DelayedActionComponent delayedActions = delayedEntity.getComponent(DelayedActionComponent.class); // If there is a DelayedActionComponent, proceed. Else report an error to the log. if (delayedActions != null) { final Set<String> actionIds = delayedActions.removeActionsUpTo(currentWorldTime); saveOrRemoveComponent(delayedEntity, delayedActions); if (!delayedActions.isEmpty()) { delayedOperationsSortedByTime.put(delayedActions.getLowestWakeUp(), delayedEntity); } for (String actionId : actionIds) { delayedEntity.send(new DelayedActionTriggeredEvent(actionId)); } } else { logger.error("ERROR: This entity is missing a DelayedActionComponent: {}. " + "So skipping delayed actions for this entity.", delayedEntity); } }); }
private void invokePeriodicOperations(long currentWorldTime) { List<EntityRef> operationsToInvoke = new LinkedList<>(); Iterator<Long> scheduledOperationsIterator = periodicOperationsSortedByTime.keySet().iterator(); long processedTime; while (scheduledOperationsIterator.hasNext()) { processedTime = scheduledOperationsIterator.next(); if (processedTime > currentWorldTime) { break; } operationsToInvoke.addAll(periodicOperationsSortedByTime.get(processedTime)); scheduledOperationsIterator.remove(); } operationsToInvoke.stream().filter(EntityRef::exists).forEach(periodicEntity -> { final PeriodicActionComponent periodicActionComponent = periodicEntity.getComponent(PeriodicActionComponent.class); // If there is a PeriodicActionComponent, proceed. Else report an error to the log. if (periodicActionComponent != null) { final Set<String> actionIds = periodicActionComponent.getTriggeredActionsAndReschedule(currentWorldTime); saveOrRemoveComponent(periodicEntity, periodicActionComponent); if (!periodicActionComponent.isEmpty()) { periodicOperationsSortedByTime.put(periodicActionComponent.getLowestWakeUp(), periodicEntity); } for (String actionId : actionIds) { periodicEntity.send(new PeriodicActionTriggeredEvent(actionId)); } } else { logger.error("ERROR: This entity is missing a DelayedActionComponent: {}. " + "So skipping delayed actions for this entity", periodicEntity); } }); }
public void testSynchronizedSortedSetMultimap() { SortedSetMultimap<String, Integer> multimap = Multimaps.synchronizedSortedSetMultimap(TreeMultimap.<String, Integer>create()); multimap.putAll("foo", Arrays.asList(3, -1, 2, 4, 1)); multimap.putAll("bar", Arrays.asList(1, 2, 3, 1)); assertThat(multimap.removeAll("foo")).containsExactly(-1, 1, 2, 3, 4).inOrder(); assertFalse(multimap.containsKey("foo")); assertThat(multimap.replaceValues("bar", Arrays.asList(6, 5))) .containsExactly(1, 2, 3) .inOrder(); assertThat(multimap.get("bar")).containsExactly(5, 6).inOrder(); }
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()); }
for (String key : sortedApi.keySet()) { System.out.println("## " + key + "\n"); for (String value : sortedApi.get(key)) { System.out.println("* " + value);
continue; SortedSet<byte[]> rowNames = rowsForBatches.get(i); SortedMap<byte[], SortedMap<byte[], Value>> cellsForBatch = Maps.filterKeys( request.isReverse() ? cellsByRow.descendingMap() : cellsByRow,
private void internalAdd(int idx, final Document document) { for (String field : document.getFieldNames()) { Iterator<AToken> tokens = parser.parseDocumentField(field, document.getField(field)); SortedSetMultimap<String, Integer> termPositions = TreeMultimap.create(); int tokenCount = 0; while (tokens.hasNext()) { tokenCount++; AToken token = tokens.next(); termPositions.put(token.getText(), token.getPosition()); } for (String term : termPositions.keySet()) { Key key = new Key(field, term); SortedSet<Integer> positionsSet = termPositions.get(term); int[] positions = new int[positionsSet.size()]; int p = 0; for (Integer i : positionsSet) { positions[p++] = i; } DocTermMatchList original = invertedIndex.putIfAbsent(key, new DocTermMatchList(idx, positions, tokenCount)); if (original != null) { original.add(idx, positions, tokenCount); } } } }
@Override public SortedSet<V> get(K key) { synchronized (mutex) { return sortedSet(delegate().get(key), mutex); } } @Override public SortedSet<V> removeAll(Object key) {
@Override public SortedSet<V> get(K key) { synchronized (mutex) { return sortedSet(delegate().get(key), mutex); } } @Override public SortedSet<V> removeAll(Object key) {
@Override public SortedSet<V> get(K key) { synchronized (mutex) { return sortedSet(delegate().get(key), mutex); } } @Override public SortedSet<V> removeAll(Object key) {
@Override public SortedSet<V> get(K key) { synchronized (mutex) { return sortedSet(delegate().get(key), mutex); } } @Override public SortedSet<V> removeAll(Object key) {