项目:fpm
文件:SignPosts.java
private static Multimap<Long,SignPostPath> spFile(TomtomFolder folder) {
File file = new File(folder.getFile("sp.dbf"));
Multimap<Long,SignPostPath> result = TreeMultimap.create();
if (!file.exists()) {
return result;
}
log.info("Reading SP {}",file);
try (DbfReader reader = new DbfReader(file)) {
DbfRow row;
while ((row = reader.nextRow()) != null) {
SignPostPath path = SignPostPath.fromrow(row);
result.put(path.getId(),path);
}
}
log.info("Loaded {} sign paths",result.size());
return result;
}
/**
* 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 @R_176_4045@ion 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;
}
/**
* Generates a coverage multimap from split key to Regions that start with the
* split key.
*
* @return coverage multimap
*/
public Multimap<byte[],R> calcCoverage() {
// This needs to be sorted to force the use of the comparator on the values,// otherwise byte array comparison isn't used
Multimap<byte[],R> regions = TreeMultimap.create(BYTES_COMParaTOR,rangeCmp);
// march through all splits from the start points
for (Entry<byte[],Collection<R>> start : starts.asMap().entrySet()) {
byte[] key = start.getKey();
for (R r : start.getValue()) {
regions.put(key,r);
for (byte[] coveredSplit : splits.subSet(r.getStartKey(),specialEndKey(r))) {
regions.put(coveredSplit,r);
}
}
}
return regions;
}
/**
* Bouwt het MetaObject.
* @param parentObject het parent Meta object
* @return het MetaObject
*/
MetaObject build(final MetaObject parentObject) {
final MetaObject gebouwdobject = new MetaObject();
gebouwdobject.parentObject = parentObject;
gebouwdobject.objectsleutel = objectsleutel;
gebouwdobject.objectElement = objectElement;
final Multimap<ObjectElement,MetaObject> tempObjectenMap = HashMultimap.create();
for (final Builder builder : objectBuilderList) {
final MetaObject object = builder.build(gebouwdobject);
tempObjectenMap.put(object.getobjectElement(),object);
}
gebouwdobject.elementObjectMap = ImmutableMultimap.copyOf(tempObjectenMap);
gebouwdobject.objecten = ImmutableSet.copyOf(tempObjectenMap.values());
final Map<GroepElement,MetaGroep> tempGroepenMap = Maps.newHashMap();
for (final MetaGroep.Builder groepBuilder : groepBuilderList) {
final MetaGroep groep = groepBuilder.build(gebouwdobject);
tempGroepenMap.put(groep.getGroepElement(),groep);
}
gebouwdobject.elementGroepMap = ImmutableMap.copyOf(tempGroepenMap);
gebouwdobject.groepen = ImmutableSet.copyOf(tempGroepenMap.values());
return gebouwdobject;
}
项目:javaide
文件:Update.java
private static RemotePkgInfo findUpdate(@NonNull LocalPkgInfo local,@NonNull Multimap<PkgType,RemotePkgInfo> remotePkgs,@NonNull UpdateResult result) {
RemotePkgInfo currUpdatePkg = null;
IPkgDesc currUpdateDesc = null;
IPkgDesc localDesc = local.getDesc();
for (RemotePkgInfo remote: remotePkgs.get(localDesc.getType())) {
IPkgDesc remoteDesc = remote.getDesc();
if ((currUpdateDesc == null && remoteDesc.isUpdateFor(localDesc)) ||
(currUpdateDesc != null && remoteDesc.isUpdateFor(currUpdateDesc))) {
currUpdatePkg = remote;
currUpdateDesc = remoteDesc;
}
}
local.setUpdate(currUpdatePkg);
if (currUpdatePkg != null) {
result.addUpdatedPkgs(local);
}
return currUpdatePkg;
}
项目:guava-mock
文件:SubscriberRegistry.java
/**
* Registers all subscriber methods on the given listener object.
*/
void register(Object listener) {
Multimap<Class<?>,Subscriber> listenerMethods = findAllSubscribers(listener);
for (Map.Entry<Class<?>,Collection<Subscriber>> entry : listenerMethods.asMap().entrySet()) {
Class<?> eventType = entry.getKey();
Collection<Subscriber> eventMethodsInListener = entry.getValue();
copyOnWriteArraySet<Subscriber> eventSubscribers = subscribers.get(eventType);
if (eventSubscribers == null) {
copyOnWriteArraySet<Subscriber> newSet = new copyOnWriteArraySet<Subscriber>();
eventSubscribers =
MoreObjects.firstNonNull(subscribers.putIfAbsent(eventType,newSet),newSet);
}
eventSubscribers.addAll(eventMethodsInListener);
}
}
private void handleMisssingInstancesOnTransaction(final ConfigTransactionClient ta,final ConfigExecution execution)
throws DocumentedException {
for (Multimap<String,ModuleElementDeFinition> modulesToResolved : execution.getModulesDeFinition(ta)
.values()) {
for (Map.Entry<String,ModuleElementDeFinition> moduletoResolved : modulesToResolved.entries()) {
String moduleName = moduletoResolved.getKey();
ModuleElementDeFinition moduleElementDeFinition = moduletoResolved.getValue();
EditConfigStrategy strategy = moduleElementDeFinition.getEditStrategy();
strategy.executeConfiguration(moduleName,moduleElementDeFinition.getInstanceName(),null,ta,execution.getServiceRegistryWrapper(ta));
}
}
}
项目:atlas
文件:DependencyResolver.java
/**
* A recursive approach to dependency resolution
*
* @param parentDependency
* @param resolvedDependenciesMap
*/
private void addResolvedDependencyInfo(ResolvedDependencyInfo parentDependency,Multimap<ModuLeversionIdentifier,ResolvedDependencyInfo>
resolvedDependenciesMap) {
int indent = parentDependency.getIndent();
ModuLeversionIdentifier identifier = parentDependency.getModuLeversionIdentifier();
Collection<ResolvedDependencyInfo> childDependencies = resolvedDependenciesMap.get(identifier);
//Todo here
for (ResolvedDependencyInfo childDependency : childDependencies) {
if (childDependency.getIndent() > indent) {
// System.out.println(parentDependency + " indent " + indent + "->" + childDependency
// + " indent " + childDependency.getIndent());
parentDependency.getChildren().add(childDependency);
if (childDependency.getIndent() <= 1) {
addResolvedDependencyInfo(childDependency,resolvedDependenciesMap);
}
}
}
}
项目:dremio-oss
文件:ScanResult.java
/**
* 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);
}
项目:Equella
文件:FreeTextServiceImpl.java
@Override
public void institutionEvent(final InstitutionEvent event)
{
switch( event.getEventType() )
{
case AVAILABLE:
Multimap<Long,Institution> schema2inst = event.getChanges();
Set<Long> schemas = schema2inst.keySet();
for( Long schemaId : schemas )
{
backgroundindexers.getUnchecked(schemaId).synchronizefull(schema2inst.get(schemaId));
}
break;
default:
break;
}
}
项目:athena
文件:IntentPerfInstaller.java
private Intent createIntent(Key key,long mac,NodeId node,Multimap<NodeId,Device> devices) {
// choose a random device for which this node is master
List<Device> deviceList = devices.get(node).stream().collect(Collectors.toList());
Device device = deviceList.get(RandomUtils.nextInt(deviceList.size()));
//FIXME we currently ignore the path length and always use the same device
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthDst(MacAddress.valueOf(mac)).build();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
ConnectPoint ingress = new ConnectPoint(device.id(),PortNumber.portNumber(1));
ConnectPoint egress = new ConnectPoint(device.id(),PortNumber.portNumber(2));
return PointToPointIntent.builder()
.appId(appId)
.key(key)
.selector(selector)
.treatment(treatment)
.ingresspoint(ingress)
.egresspoint(egress)
.build();
}
项目:n4js
文件:N4HeadlessCompiler.java
/**
* Recursive part of {@link #computeBuildOrderDepthFirst(Map,Multimap,Collection)}. If all dependencies
* of the given project have already been processed,it is added to the build order. Then,all projects that depend
* on the given project are processed recursively.
*
* @param project
* the project to process
* @param markedProjects
* the marked projects
* @param pendencies
* maps projects to the projects that depend on them
* @param dependencies
* maps projects to the projects they depend on
* @param result
* the build order being computed
*/
private static void computeBuildOrderDepthFirst(IN4JSProject project,Map<IN4JSProject,MarkedProject> markedProjects,Multimap<IN4JSProject,IN4JSProject> pendencies,IN4JSProject> dependencies,List<MarkedProject> result) {
// once all dependencies of the current project have been processed,we can add it to the build and
// process its children.
if (dependencies.get(project).isEmpty()) {
// The current project is ready to be processed.
result.add(markedProjects.get(project));
// Remove this project from the dependencies of all pending projects.
for (IN4JSProject dependentProject : pendencies.get(project)) {
dependencies.get(dependentProject).remove(project);
// Now process the pending project itself.
computeBuildOrderDepthFirst(dependentProject,markedProjects,pendencies,dependencies,result);
}
}
}
项目:n4js
文件:ExternalProjectsCollector.java
/**
* Sugar for collecting {@link IWorkspace Eclipse workspace} projects that have any direct dependency to any
* external projects. Same as {@link #collectExternalProjectDependents()} but does not consider all the available
* projects but only those that are given as the argument.
*
* @param externalProjects
* the external projects that has to be considered as a possible dependency of an Eclipse workspace based
* project.
* @return a map where each entry maps an external project to the workspace projects that depend on it.
*/
public Map<IProject,Collection<IProject>> collectExternalProjectDependents(
final Iterable<? extends IProject> externalProjects) {
final Multimap<IProject,IProject> mapping = Multimaps2.newLinkedHashListMultimap();
if (Platform.isRunning()) {
final Map<String,IProject> externalsMapping = new HashMap<>();
externalProjects.forEach(p -> externalsMapping.put(p.getName(),p));
asList(getWorkspace().getRoot().getProjects()).forEach(p -> {
getDirectExternalDependencyIds(p).forEach(eID -> {
IProject externalDependency = externalsMapping.get(eID);
if (externalDependency != null) {
mapping.put(externalDependency,p);
}
});
});
}
return mapping.asMap();
}
/**
* Create SampleResult in XML format.
* @param context
* @param isError
* @param statusCode
* @param statusMessage
* @param columnsForEachsqlStatement
* @param valuesForEachColumn
* @param includeQueryResults
* @return
*/
private static SampleResult newResult(final Context context,final boolean isError,final String statusCode,final String statusMessage,final Multimap<String,String> columnsForEachsqlStatement,String> valuesForEachColumn,boolean includeQueryResults,final Optional<Long> duration) {
final SampleResult result = new SampleResult();
result.setStatusCode(statusCode);
result.setError(isError);
if(duration.isPresent())
result.setDuration(duration.get());
context.getLogger().debug("sql Action execution finished with status code: " + statusCode + " (" + statusMessage + ")");
final State state = isError ? State.ERROR : State.OK;
try {
result.setResponseContent(generateXMLOutput(state,statusMessage,columnsForEachsqlStatement,valuesForEachColumn,includeQueryResults));
} catch (TransformerException e) {
result.setError(true);
context.getLogger().error("An error occurred while creating XML output: " + e.toString());
}
return result;
}
项目:fpm
文件:TdDbf.java
private Multimap<Long,TimeDomains> loadTimeDomains(String filename) {
Multimap<Long,TimeDomains> times = TreeMultimap.create();
File file = new File(filename);
if (!file.exists()) {
log.info("File not found : {}",file.getAbsolutePath());
return times;
}
log.info("Reading TD {}",file);
processDbf(file,row -> {
TimeDomains restriction = new TimeDomains(((Double)row[0]).longValue(),new String((byte[]) row[3]).trim());
times.put(restriction.getId(),restriction);
});
log.info("Loaded {} times domains",times.size());
return times;
}
项目:MicroServiceProject
文件:SparseTensor.java
/**
* 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);
}
项目:apollo-custom
文件:WatchKeysUtil.java
/**
* Assemble watch keys for the given appId,cluster,namespaces,dataCenter combination
*
* @return a multimap with namespace as the key and watch keys as the value
*/
public Multimap<String,String> assembleAllWatchKeys(String appId,String clusterName,Set<String> namespaces,String dataCenter) {
Multimap<String,String> watchedKeysMap =
assembleWatchKeys(appId,clusterName,dataCenter);
//Every app has an 'application' namespace
if (!(namespaces.size() == 1 && namespaces.contains(ConfigConsts.NAMESPACE_APPLICATION))) {
Set<String> namespacesBelongToAppId = namespacesBelongToAppId(appId,namespaces);
Set<String> publicNamespaces = Sets.difference(namespaces,namespacesBelongToAppId);
//Listen on more namespaces if it's a public namespace
if (!publicNamespaces.isEmpty()) {
watchedKeysMap
.putAll(findPublicConfigWatchKeys(appId,publicNamespaces,dataCenter));
}
}
return watchedKeysMap;
}
/**
* Get a unique column label for variables and remove invalid XML characters.
* @param multimap
* @param label
* @return unique label
*/
static String uniqueColumnName(Multimap<String,String> multimap,String label) {
final String columnLabel = getValidXmlName(label);
if (!multimap.values().contains(columnLabel)) {
return columnLabel;
}
int index = columnLabel.length() - 1;
while (index >= 0 && Character.isDigit(columnLabel.charat(index))) {
index--;
}
String base = columnLabel;
if (index >= 0 && columnLabel.charat(index) == '_') {
base = columnLabel.substring(0,index);
}
int j = 1;
String newLabel = base + "_" + j;
while (multimap.values().contains(newLabel)) {
j++;
newLabel = base + "_" + j;
}
return newLabel;
}
private EventArgScoringalignment(final Symbol docID,final ArgumentOutput argumentOutput,final AnswerKey answerKey,final Iterable<EquivClasstype> truePositiveECs,final Iterable<EquivClasstype> falsePositiveECs,final Iterable<EquivClasstype> falseNegativeECs,final Iterable<EquivClasstype> unassessed,final Multimap<EquivClasstype,AssessedResponse> ecsToAnswerKey,Response> ecsToSystem) {
this.docID = checkNotNull(docID);
this.argumentOutput = checkNotNull(argumentOutput);
this.answerKey = checkNotNull(answerKey);
this.truePositiveECs = ImmutableSet.copyOf(truePositiveECs);
this.falsePositiveECs = ImmutableSet.copyOf(falsePositiveECs);
this.falseNegativeECs = ImmutableSet.copyOf(falseNegativeECs);
this.unassessed = ImmutableSet.copyOf(unassessed);
this.ecsToAnswerKey = ImmutableSetMultimap.copyOf(ecsToAnswerKey);
this.ecsToSystem = ImmutableSetMultimap.copyOf(ecsToSystem);
}
public static void loadData(ASMDataTable data)
{
FMLLog.fine("Loading @Config anotation data");
for (ASMData target : data.getAll(Config.class.getName()))
{
String modid = (String)target.getAnnotationInfo().get("modid");
Multimap<Config.Type,ASMData> map = asm_data.get(modid);
if (map == null)
{
map = ArrayListMultimap.create();
asm_data.put(modid,map);
}
EnumHolder tholder = (EnumHolder)target.getAnnotationInfo().get("type");
Config.Type type = tholder == null ? Config.Type.INSTANCE : Config.Type.valueOf(tholder.getValue());
map.put(type,target);
}
}
项目:tac-kbp-eal
文件:SameEventTypeLinker.java
private ResponseLinking linkResponses(final Symbol docId,final Iterable<Response> responses) {
final Predicate<Response> HasRelevantRealis =
compose(in(realisesWhichMustBeAligned),ResponseFunctions.realis());
final ImmutableSet<Response> systemResponsesAlignedRealis =
FluentIterable.from(responses).filter(HasRelevantRealis).toSet();
final Multimap<Symbol,Response> responsesByEventType =
Multimaps.index(systemResponsesAlignedRealis,ResponseFunctions.type());
final ImmutableSet.Builder<ResponseSet> ret = ImmutableSet.builder();
for (final Collection<Response> responseSet : responsesByEventType.asMap().values()) {
ret.add(ResponseSet.from(responseSet));
}
return ResponseLinking.builder().docID(docId).addAllResponseSets(ret.build()).build();
}
项目:apollo-custom
文件:DefaultRolePermissionService.java
/**
* 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();
}
项目:Equella
文件:CheckURLsScheduledTask.java
@Override
public void execute()
{
if( !httpService.canAccessInternet() )
{
// nothing we can do...
return;
}
Multimap<Long,Institution> schemaToInsts = institutionService.getAvailableMap();
for( final Map.Entry<Long,Collection<Institution>> entry : schemaToInsts.asMap().entrySet() )
{
schemaDataSourceService.executeWithSchema(entry.getKey(),new Callable<Object>()
{
@Override
public Object call() throws Exception
{
executeForInstitutions(entry.getValue());
return null;
}
});
}
}
项目:CustomWorldGen
文件:ASMDataTable.java
public SetMultimap<String,ASMData> getAnnotationsFor(ModContainer container)
{
if (containerAnnotationData == null)
{
ImmutableMap.Builder<ModContainer,SetMultimap<String,ASMData>> mapBuilder = ImmutableMap.builder();
for (ModContainer cont : containers)
{
Multimap<String,ASMData> values = Multimaps.filterValues(globalAnnotationData,new ModContainerPredicate(cont));
mapBuilder.put(cont,ImmutableSetMultimap.copyOf(values));
}
containerAnnotationData = mapBuilder.build();
}
return containerAnnotationData.get(container);
}
项目:MicroServiceProject
文件:DiagMatrix.java
public static DiagMatrix eye(int n) {
Table<Integer,Integer,Double> vals = HashBasedTable.create();
Multimap<Integer,Integer> colMap = HashMultimap.create();
for (int i = 0; i < n; i++) {
vals.put(i,i,1.0);
colMap.put(i,i);
}
return new DiagMatrix(n,n,vals,colMap);
}
项目:Loot-Slash-Conquer
文件:ItemLEAdvancedMelee.java
/**
* Replace a modifier in the {@link Multimap} with a copy that's had {@code multiplier} applied to its value.
*
* @param modifierMultimap The MultiMap
* @param attribute The attribute being modified
* @param id The ID of the modifier
* @param multiplier The multiplier to apply
*/
private void replaceModifier(Multimap<String,AttributeModifier> modifierMultimap,IAttribute attribute,UUID id,double multiplier)
{
// Get the modifiers for the specified attribute
final Collection<AttributeModifier> modifiers = modifierMultimap.get(attribute.getName());
// Find the modifier with the specified ID,if any
final Optional<AttributeModifier> modifierOptional = modifiers.stream().filter(attributeModifier -> attributeModifier.getID().equals(id)).findFirst();
if (modifierOptional.isPresent()) // If it exists,{
final AttributeModifier modifier = modifierOptional.get();
modifiers.remove(modifier); // Remove it
modifiers.add(new AttributeModifier(modifier.getID(),modifier.getName(),modifier.getAmount() * multiplier,modifier.getoperation())); // Add the new modifier
}
}
项目:graphouse
文件:MetricTreeTest.java
@Test
public void testGlob() {
Multimap<String,String> pattern2Candidates = generate();
for (Map.Entry<String,Collection<String>> pattern2CandidatesMap : pattern2Candidates.asMap().entrySet()) {
String glob = pattern2CandidatesMap.getKey();
Pattern pattern = createPattern(glob);
if (pattern == null) {
System.out.println("Wrong pattern " + glob);
continue;
}
for (String node : pattern2CandidatesMap.getValue()) {
System.out.println(String.format("%40s\t%40s\t%s",glob,node,pattern.matcher(node).matches()));
}
}
}
项目:Equella
文件:AbstractItemListEntry.java
@Override
protected UnmodifiableAttachments loadAttachments()
{
Multimap<Item,Attachment> attachmentsForItems = listSettings.getAttribute(KEY_ALLATTACHMENTS);
if( attachmentsForItems == null )
{
List<ItemListEntry> entries2 = (List<ItemListEntry>) listSettings.getEntries();
attachmentsForItems = itemService
.getAttachmentsForItems(AbstractItemlikeListEntry.<Item>getItems(entries2));
listSettings.setAttribute(KEY_ALLATTACHMENTS,attachmentsForItems);
}
return new UnmodifiableAttachments(Lists.<IAttachment>newArrayList(attachmentsForItems.get(getItem())));
}
项目:Backmemed
文件:ItemHoe.java
public Multimap<String,AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot)
{
Multimap<String,AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
if (equipmentSlot == EntityEquipmentSlot.MAINHAND)
{
multimap.put(SharedMonsterattributes.ATTACK_damAGE.getAttributeUnlocalizedname(),new AttributeModifier(ATTACK_damAGE_MODIFIER,"Weapon modifier",0.0D,0));
multimap.put(SharedMonsterattributes.ATTACK_SPEED.getAttributeUnlocalizedname(),new AttributeModifier(ATTACK_SPEED_MODIFIER,(double)(this.speed - 4.0F),0));
}
return multimap;
}
项目:creacoinj
文件:PaymentChannelV2ClientState.java
@Override
protected Multimap<State,State> getStateTransitions() {
Multimap<State,State> result = MultimapBuilder.enumKeys(State.class).arrayListValues().build();
result.put(State.UNINITIALISED,State.NEW);
result.put(State.UNINITIALISED,State.READY);
result.put(State.NEW,State.SAVE_STATE_IN_WALLET);
result.put(State.SAVE_STATE_IN_WALLET,State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER);
result.put(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER,State.READY);
result.put(State.READY,State.EXPIRED);
result.put(State.READY,State.CLOSED);
return result;
}
项目:grammaticus
文件:ComplexGrammaticalForm.java
/**
* If you have an article-supporting language,it makes sense to keep an enum map around.
*/
public static <A extends AdjectiveForm> EnumMap<LanguageArticle,ModifierFormMap<A>> getArticleSpecificMap(Collection<? extends A> forms) {
Multimap<LanguageArticle,A> mm = ArrayListMultimap.create();
for (A form : forms) {
mm.put(form.getArticle(),form);
}
EnumMap<LanguageArticle,ModifierFormMap<A>> result = new EnumMap<LanguageArticle,ModifierFormMap<A>>(LanguageArticle.class);
for (LanguageArticle article : LanguageArticle.values()) {
result.put(article,new ModifierFormMap<A>(mm.get(article)));
}
return result;
}
项目:Equella
文件:ItemIndex.java
/**
* A simplified implementation of matrixSearch() that only works on a single
* field,and currently only returns the count per term. It Could easily be
* extended to return a list of ItemIds per term,it simply wasn't necessary
* when I was writing it!
* <p>
* This simplified implementation was written to overcome the memory
* pressures that matrixSearch() creates when you have over half a million
* terms for a field. MatrixSearch() creates *many* BitSets that it holds on
* to to reuse as it recurse through a list of fields. Since we only care
* about a single field in this implementation,we can avoid generating and
* holding onto BitSets.
*/
public Multimap<String,Pair<String,Integer>> facetCount(@Nullable final Search searchreq,final Collection<String> fields)
{
return search(new Searcher<Multimap<String,Integer>>>()
{
@Override
public Multimap<String,Integer>> search(IndexSearcher searcher) throws IOException
{
final IndexReader reader = searcher.getIndexReader();
final OpenBitSet filteredBits = searchRequestToBitSet(searchreq,searcher,reader);
final Multimap<String,Integer>> rv = ArrayListMultimap.create();
for( String field : fields )
{
for( Term term : new XPathFieldIterator(reader,field,"") )
{
int count = 0;
TermDocs docs = reader.termDocs(term);
while( docs.next() )
{
if( filteredBits.get(docs.doc()) )
{
count++;
}
}
docs.close();
if( count > 0 )
{
rv.put(field,new Pair<String,Integer>(term.text(),count));
}
}
}
return rv;
}
});
}
项目:hashsdn-controller
文件:Runtime.java
public Element toXml(Set<ObjectName> instancesToMap,Set<ObjectName> configBeans,Document document,final EnumResolver enumResolver) {
Element root = XmlUtil.createElement(document,XmlMappingConstants.DATA_KEY,Optional.<String>absent());
Element modulesElement = XmlUtil.createElement(document,XmlMappingConstants.MODULES_KEY,Optional.of(XmlMappingConstants.URN_OPENDAYLIGHT_ParaMS_XML_NS_YANG_CONTROLLER_CONfig));
root.appendChild(modulesElement);
Map<String,Multimap<String,ObjectName>> moduletoRuntimeInstance = mapInstancesToModules(instancesToMap);
Map<String,Map<String,Collection<ObjectName>>> moduletoConfigInstance = Config.getMappedInstances(configBeans,moduleConfigs);
for (String localNamespace : moduleConfigs.keySet()) {
Map<String,Collection<ObjectName>> instancetoMbe = moduletoConfigInstance.get(localNamespace);
for (String moduleName : moduleConfigs.get(localNamespace).keySet()) {
Multimap<String,ObjectName> instancetoRbe = moduletoRuntimeInstance.get(moduleName);
for (ObjectName instanceON : instancetoMbe.get(moduleName)) {
String instanceName = ObjectNameUtil.getInstanceName(instanceON);
Element runtimeXml;
ModuleConfig moduleConfig = moduleConfigs.get(localNamespace).get(moduleName);
if (instancetoRbe == null || !instancetoRbe.containsKey(instanceName)) {
runtimeXml = moduleConfig.toXml(instanceON,document,localNamespace,enumResolver);
} else {
ModuleRuntime moduleRuntime = moduleRuntimes.get(localNamespace).get(moduleName);
runtimeXml = moduleRuntime.toXml(localNamespace,instancetoRbe.get(instanceName),moduleConfig,instanceON,enumResolver);
}
modulesElement.appendChild(runtimeXml);
}
}
}
return root;
}
项目:clearwsd
文件:VerbNetExperiment.java
private static List<NlpFocus<DepNode,DepTree>> filterpolysemous(
List<NlpFocus<DepNode,DepTree>> data) {
Multimap<String,String> labelMap = HashMultimap.create();
for (NlpFocus<DepNode,DepTree> instance : data) {
String predicate = instance.focus().feature(FeatureType.Predicate);
labelMap.put(predicate,instance.feature(FeatureType.Gold));
}
return data.stream()
.filter(instance -> labelMap.get(instance.focus().feature(FeatureType.Predicate)).size() > 1)
.collect(Collectors.toList());
}
项目:Reer
文件:DefaultTaskClassValidatorExtractor.java
private static Multimap<Class<? extends Annotation>,Class<? extends Annotation>> collectAnnotationOverrides(Iterable<PropertyAnnotationHandler> allAnnotationHandlers) {
ImmutableSetMultimap.Builder<Class<? extends Annotation>,Class<? extends Annotation>> builder = ImmutableSetMultimap.builder();
for (PropertyAnnotationHandler handler : allAnnotationHandlers) {
if (handler instanceof OverridingPropertyAnnotationHandler) {
builder.put(((OverridingPropertyAnnotationHandler) handler).getoverriddenAnnotationType(),handler.getAnnotationType());
}
}
return builder.build();
}
@Override
public boolean putAll(Multimap<? extends K,? extends V> multimap) {
for (Entry<? extends K,? extends V> e : multimap.entries()) {
value2key.put(e.getValue(),e.getKey());
}
return key2Value.putAll(multimap);
}
项目:fpm
文件:Splitter.java
public void run() {
File file = new File(filename);
Stopwatch stopwatch = Stopwatch.createStarted();
Multimap<Long,Long> wayByRelations = ArrayListMultimap.create();
Multimap<Long,Integer> borderNodeTargets = ArrayListMultimap.create();
firstPass(file,wayByRelations,borderNodeTargets);
finalPass(wayByRelations,borderNodeTargets,file);
kml.close();
log.info("time: {}s",stopwatch.elapsed(SECONDS));
}
项目:Equella
文件:LegacyMigrationInstitutionInfoInitialiser.java
private void add31Migrators(Multimap<String,String> xmlMigs)
{
xmlMigs.put("3.1","com.tle.core.institution.migration.RemoveDeprecatedFedSearches");
xmlMigs.put("3.1","com.tle.core.institution.migration.TleUserSuspendedRemover");
xmlMigs.put("3.1","com.tle.core.institution.migration.SetEmailTemplateUuidsChange");
xmlMigs.put("3.1","com.tle.core.institution.migration.RemoveDeprecatedItemDeFinitionParts");
xmlMigs.put("3.1","com.tle.core.institution.migration.LanguageBundleMigration");
}
项目:MicroServiceProject
文件:SparseTensor.java
/**
* Re-ordering entries of a tensor into a matrix
*
* @param n
* mode or dimension
* @return an unfolded or flatten matrix
*/
public SparseMatrix matricization(int n) {
int numRows = dimensions[n];
int numCols = 1;
for (int d = 0; d < numDimensions; d++) {
if (d != n)
numCols *= dimensions[d];
}
Table<Integer,Double> dataTable = HashBasedTable.create();
Multimap<Integer,Integer> colMap = HashMultimap.create();
for (TensorEntry te : this) {
int[] keys = te.keys();
int i = keys[n];
int j = 0;
for (int k = 0; k < numDimensions; k++) {
if (k == n)
continue;
int ik = keys[k];
int jk = 1;
for (int m = 0; m < k; m++) {
if (m == n)
continue;
jk *= dimensions[m];
}
j += ik * jk;
}
dataTable.put(i,j,te.get());
colMap.put(j,i);
}
return new SparseMatrix(numRows,numCols,dataTable,colMap);
}
项目:CustomWorldGen
文件:ItemHoe.java
public Multimap<String,0));
}
return multimap;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。