当前位置: 首页>>代码示例>>Java>>正文


Java HashMultimap类代码示例

本文整理汇总了Java中com.google.common.collect.HashMultimap的典型用法代码示例。如果您正苦于以下问题:Java HashMultimap类的具体用法?Java HashMultimap怎么用?Java HashMultimap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HashMultimap类属于com.google.common.collect包,在下文中一共展示了HashMultimap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createPermissions

import com.google.common.collect.HashMultimap; //导入依赖的package包/类
/**
 * Create permissions, note that permissionType + targetId should be unique
 */
@Transactional
public Set<Permission> createPermissions(Set<Permission> permissions) {
    Multimap<String, String> targetIdPermissionTypes = HashMultimap.create();
    for (Permission permission : permissions) {
        targetIdPermissionTypes.put(permission.getTargetId(), permission.getPermissionType());
    }

    for (String targetId : targetIdPermissionTypes.keySet()) {
        Collection<String> permissionTypes = targetIdPermissionTypes.get(targetId);
        List<Permission> current =
                permissionRepository.findByPermissionTypeInAndTargetId(permissionTypes, targetId);
        Preconditions.checkState(CollectionUtils.isEmpty(current),
                "Permission with permissionType %s targetId %s already exists!", permissionTypes,
                targetId);
    }

    Iterable<Permission> results = permissionRepository.save(permissions);
    return FluentIterable.from(results).toSet();
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:23,代码来源:DefaultRolePermissionService.java

示例2: binarize

import com.google.common.collect.HashMultimap; //导入依赖的package包/类
/**
 * Binarize embeddings as described in "Revisiting Embedding Features for Simple Semi-supervised Learning" (Guo et al. 2014).
 * Output is a map of indices, where negative-valued indices are negative, and positive-valued indices are positive. Indices
 * start at 1, so as to avoid loss of information on 0.
 *
 * @param embeddings map from identifiers onto corresponding vectors
 * @return map from identifiers onto indices
 */
public static Multimap<String, Integer> binarize(Map<String, float[]> embeddings) {
    float[] posMean = filteredMean(embeddings.values(), v -> v >= 0);
    float[] negMean = filteredMean(embeddings.values(), v -> v < 0);
    Multimap<String, Integer> binarizedEmbeddings = HashMultimap.create();
    for (Map.Entry<String, float[]> embedding : embeddings.entrySet()) {
        int index = 0;
        for (float val : embedding.getValue()) {
            if (val > posMean[index]) {
                binarizedEmbeddings.put(embedding.getKey(), -(index + 1));
            } else if (val < negMean[index]) {
                binarizedEmbeddings.put(embedding.getKey(), index + 1);
            }
            ++index;
        }
    }
    return binarizedEmbeddings;
}
 
开发者ID:clearwsd,项目名称:clearwsd,代码行数:26,代码来源:EmbeddingIoUtils.java

示例3: configureResourceSetContainerState

import com.google.common.collect.HashMultimap; //导入依赖的package包/类
private void configureResourceSetContainerState(final List<N4JSProject> allProjects) {
	// a container is a project.
	List<String> containers = new LinkedList<>();
	BiMap<String, N4JSProject> container2project = HashBiMap.create();

	// the URIs of all resources directly contained in a project/container.
	Multimap<String, URI> container2Uris = HashMultimap.create();

	for (N4JSProject project : allProjects) {
		String container = FileBasedWorkspace.N4FBPRJ + project.getLocation();
		container2project.put(container, project);
		containers.add(container);

		for (IN4JSSourceContainer sourceContainer : project.getSourceContainers()) {
			Iterables.addAll(container2Uris.get(container), sourceContainer);
		}
	}

	// Define the Mapping of Resources (URIs to Container === Projects),
	rsbAcs.configure(containers, container2Uris);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:22,代码来源:N4HeadlessCompiler.java

示例4: initProjectLocation

import com.google.common.collect.HashMultimap; //导入依赖的package包/类
private Multimap<String, IProject> initProjectLocation() {
	final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	final IProject[] projects = root.getProjects();
	final Multimap<String, IProject> locations = HashMultimap.create();

	// initialize the repository paths
	repositoryPaths = repositoriesProvider.getWorkspaceRepositories().stream()
			.map(r -> r.getDirectory().getParentFile().toPath()).collect(Collectors.toSet());

	for (final IProject project : projects) {
		if (isRemoteEditNature(project)) {
			continue;
		}
		final String pair = getWorkingSetId(project);
		locations.put(pair, project);
	}

	return locations;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:ProjectLocationAwareWorkingSetManager.java

示例5: buildEdgeMap

import com.google.common.collect.HashMultimap; //导入依赖的package包/类
/**
 * Builds a map of {@link Segment}s and their edges in the {@link Subgraph} for either the incoming or
 * outgoing {@link Edge}s.
 * <p>
 * {@link DummyEdge}s will not be added but their original edge, for which they are a diversion, will be added.
 *
 * @param subgraph          the {@link Subgraph}
 * @param sequenceDirection the {@link SequenceDirection}
 * @return map of {@link Edge}s for each {@link Segment}
 */
private Multimap<GfaNode, Edge> buildEdgeMap(final Subgraph subgraph,
                                             final SequenceDirection sequenceDirection) {
    final Multimap<GfaNode, Edge> edgeMap = HashMultimap.create();

    subgraph.getGfaNodes().forEach(segment -> {
        final Set<Edge> edges = sequenceDirection.ternary(segment.getIncomingEdges(), segment.getOutgoingEdges());

        edges.forEach(edge -> {
            if (edge instanceof DummyEdge) {
                edgeMap.put(segment, ((DummyEdge) edge).getOriginalEdge());
            } else {
                edgeMap.put(segment, edge);
            }
        });
    });

    return edgeMap;
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:29,代码来源:PathCalculator.java

示例6: activate

import com.google.common.collect.HashMultimap; //导入依赖的package包/类
@Activate
public void activate() {
    ribTable4 = new ConcurrentInvertedRadixTree<>(
            new DefaultByteArrayNodeFactory());
    ribTable6 = new ConcurrentInvertedRadixTree<>(
            new DefaultByteArrayNodeFactory());

    routesWaitingOnArp = Multimaps.synchronizedSetMultimap(
            HashMultimap.create());

    coreService.registerApplication(ROUTER_APP_ID);

    bgpUpdatesExecutor = Executors.newSingleThreadExecutor(
            new ThreadFactoryBuilder()
            .setNameFormat("rib-updates-%d").build());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:DefaultRouter.java

示例7: parse

import com.google.common.collect.HashMultimap; //导入依赖的package包/类
public static DisableDamageModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
    SetMultimap<DamageCause, PlayerRelation> causes = HashMultimap.create();
    for(Element damageCauseElement : doc.getRootElement().getChildren("disabledamage")) {
        for(Element damageEl : damageCauseElement.getChildren("damage")) {
            DamageCause cause = XMLUtils.parseEnum(damageEl, DamageCause.class, "damage type");
            for(PlayerRelation damagerType : PlayerRelation.values()) {
                // Legacy syntax used "other" instead of "neutral"
                String attrName = damagerType.name().toLowerCase();
                Node attr = damagerType == PlayerRelation.NEUTRAL ? Node.fromAttr(damageEl, attrName, "other")
                                                                  : Node.fromAttr(damageEl, attrName);
                if(XMLUtils.parseBoolean(attr, true)) {
                    causes.put(cause, damagerType);

                    // Bukkit 1.7.10 changed TNT from BLOCK_EXPLOSION to ENTITY_EXPLOSION,
                    // so we include them both to keep old maps working.
                    if(cause == DamageCause.BLOCK_EXPLOSION) {
                        causes.put(DamageCause.ENTITY_EXPLOSION, damagerType);
                    }
                }
            }
        }
    }
    return new DisableDamageModule(causes);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:25,代码来源:DisableDamageModule.java

示例8: SoundManager

import com.google.common.collect.HashMultimap; //导入依赖的package包/类
public SoundManager(SoundHandler p_i45119_1_, GameSettings p_i45119_2_)
{
    this.invPlayingSounds = ((BiMap)this.playingSounds).inverse();
    this.categorySounds = HashMultimap.<SoundCategory, String>create();
    this.tickableSounds = Lists.<ITickableSound>newArrayList();
    this.delayedSounds = Maps.<ISound, Integer>newHashMap();
    this.playingSoundsStopTime = Maps.<String, Integer>newHashMap();
    this.listeners = Lists.<ISoundEventListener>newArrayList();
    this.pausedChannels = Lists.<String>newArrayList();
    this.sndHandler = p_i45119_1_;
    this.options = p_i45119_2_;

    try
    {
        SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class);
        SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
    }
    catch (SoundSystemException soundsystemexception)
    {
        LOGGER.error(LOG_MARKER, (String)"Error linking with the LibraryJavaSound plug-in", (Throwable)soundsystemexception);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:23,代码来源:SoundManager.java

示例9: merge

import com.google.common.collect.HashMultimap; //导入依赖的package包/类
/**
 * merges this and other together into a new result object
 * @param other
 * @return the resulting merge
 */
public ScanResult merge(ScanResult other) {
  final Multimap<String, ChildClassDescriptor> newImpls = HashMultimap.create();
  for (Collection<ParentClassDescriptor> impls : asList(implementations, other.implementations)) {
    for (ParentClassDescriptor c : impls) {
      newImpls.putAll(c.getName(), c.getChildren());
    }
  }
  List<ParentClassDescriptor> newImplementations = new ArrayList<>();
  for (Entry<String, Collection<ChildClassDescriptor>> entry : newImpls.asMap().entrySet()) {
    newImplementations.add(new ParentClassDescriptor(entry.getKey(), new ArrayList<>(entry.getValue())));
  }

  return new ScanResult(
      merge(scannedPackages, other.scannedPackages),
      merge(scannedClasses, other.scannedClasses),
      merge(scannedAnnotations, other.scannedAnnotations),
      merge(annotatedClasses, other.annotatedClasses),
      newImplementations);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:25,代码来源:ScanResult.java

示例10: getAbiSoFiles

import com.google.common.collect.HashMultimap; //导入依赖的package包/类
/**
 * Verify the directory of the so file under the abi
 *
 * @param supportAbis
 * @param removeSoFiles
 * @param dirs
 * @return
 */
public static Map<String, Multimap<String, File>> getAbiSoFiles(Set<String> supportAbis, Set<String> removeSoFiles,
                                                                List<File> dirs) {
    Map<String, Multimap<String, File>> result = new HashMap<String, Multimap<String, File>>();
    IOFileFilter filter = new NativeSoFilter(supportAbis, removeSoFiles);
    for (File dir : dirs) {
        Collection<File> files = FileUtils.listFiles(dir, filter, TrueFileFilter.TRUE);
        for (File file : files) {
            File parentFolder = file.getParentFile();
            String parentName = parentFolder.getName();
            String shortName = getSoShortName(file);
            Multimap<String, File> maps = result.get(parentName);
            if (null == maps) {
                maps = HashMultimap.create(10, 3);
            }
            maps.put(shortName, file);
            result.put(parentName, maps);
        }

    }
    return result;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:30,代码来源:NativeSoUtils.java

示例11: SoundManager

import com.google.common.collect.HashMultimap; //导入依赖的package包/类
public SoundManager(SoundHandler p_i45119_1_, GameSettings p_i45119_2_)
{
    this.invPlayingSounds = ((BiMap)this.playingSounds).inverse();
    this.playingSoundPoolEntries = Maps.<ISound, SoundPoolEntry>newHashMap();
    this.categorySounds = HashMultimap.<SoundCategory, String>create();
    this.tickableSounds = Lists.<ITickableSound>newArrayList();
    this.delayedSounds = Maps.<ISound, Integer>newHashMap();
    this.playingSoundsStopTime = Maps.<String, Integer>newHashMap();
    this.sndHandler = p_i45119_1_;
    this.options = p_i45119_2_;

    try
    {
        SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class);
        SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
    }
    catch (SoundSystemException soundsystemexception)
    {
        logger.error(LOG_MARKER, (String)"Error linking with the LibraryJavaSound plug-in", (Throwable)soundsystemexception);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:22,代码来源:SoundManager.java

示例12: getAnnotationAsMap

import com.google.common.collect.HashMultimap; //导入依赖的package包/类
public static Multimap<String, String> getAnnotationAsMap(org.jboss.forge.roaster.model.Annotation<?> annotation,
                                                    Class<? extends Annotation> type) {

    if(annotation == null) return null;
    List<Method> methods = getAnnotationAttributes(type);
    Multimap<String, String> result = HashMultimap.create();
    for (Method method : methods) {
        String name = method.getName();
        boolean array = method.getReturnType().isArray();
        String value = annotation.getLiteralValue(name);
        if(StringUtils.isBlank(value)) continue;
        String [] values = array
                ? annotation.getStringArrayValue(name) : new String[]{annotation.getStringValue(name)};
        if(allElementsNull(values)) continue;
        result.putAll(name, Arrays.asList(values));
    }
    return result;
}
 
开发者ID:sdadas,项目名称:spring2ts,代码行数:19,代码来源:AnnotationUtils.java

示例13: deserialize

import com.google.common.collect.HashMultimap; //导入依赖的package包/类
@Override
public SetMultimap<String, String> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{
	SetMultimap<String, String> map = HashMultimap.create();

	JsonObject filters = json.getAsJsonObject();
	for (Map.Entry<String, JsonElement> filter : filters.entrySet())
	{
		String name = filter.getKey();
		JsonArray values = ((JsonArray)filter.getValue());
		for (JsonElement value : values)
		{
			map.put(name, value.getAsString());
		}
	}

	return map;
}
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:19,代码来源:SetMultimapDeserializer.java

示例14: SparseTensor

import com.google.common.collect.HashMultimap; //导入依赖的package包/类
/**
 * Construct a sparse tensor with indices and values
 * 
 * @param dims
 *            dimensions of a tensor
 * @param nds
 *            n-dimensional keys
 * @param vals
 *            entry values
 */
@SuppressWarnings("unchecked")
public SparseTensor(int[] dims, List<Integer>[] nds, List<Double> vals) {
	if (dims.length < 3)
		throw new Error("The dimension of a tensor cannot be smaller than 3!");

	numDimensions = dims.length;
	dimensions = new int[numDimensions];

	ndKeys = (List<Integer>[]) new List<?>[numDimensions];
	keyIndices = (Multimap<Integer, Integer>[]) new Multimap<?, ?>[numDimensions];

	for (int d = 0; d < numDimensions; d++) {
		dimensions[d] = dims[d];
		ndKeys[d] = nds == null ? new ArrayList<Integer>() : new ArrayList<Integer>(nds[d]);
		keyIndices[d] = HashMultimap.create();
	}

	values = vals == null ? new ArrayList<Double>() : new ArrayList<>(vals);
	indexedDimensions = new ArrayList<>(numDimensions);
}
 
开发者ID:xiaojieliu7,项目名称:MicroServiceProject,代码行数:31,代码来源:SparseTensor.java

示例15: rateMatrix

import com.google.common.collect.HashMultimap; //导入依赖的package包/类
/**
 * retrieve a rating matrix from the tensor. Warning: it assumes there is at most one entry for each (user, item)
 * pair.
 *
 * @return a sparse rating matrix
 */
public SparseMatrix rateMatrix() {

	Table<Integer, Integer, Double> dataTable = HashBasedTable.create();
	Multimap<Integer, Integer> colMap = HashMultimap.create();

	for (TensorEntry te : this) {
		int u = te.key(userDimension);
		int i = te.key(itemDimension);

		dataTable.put(u, i, te.get());
		colMap.put(i, u);
	}

	return new SparseMatrix(dimensions[userDimension], dimensions[itemDimension], dataTable, colMap);
}
 
开发者ID:xiaojieliu7,项目名称:MicroServiceProject,代码行数:22,代码来源:SparseTensor.java


注:本文中的com.google.common.collect.HashMultimap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。