本文整理了Java中scala.collection.Map.apply()
方法的一些代码示例,展示了Map.apply()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Map.apply()
方法的具体详情如下:
包路径:scala.collection.Map
类名称:Map
方法名:apply
暂无
代码示例来源:origin: linkedin/kafka-monitor
for (int partition = 0; partition < partitionsToBeReassigned.size(); partition++) {
bldr.append(" {\"topic\":\"").append(topic).append("\",\"partition\":").append(partition).append(",\"replicas\":[");
scala.collection.Seq<Object> replicas = partitionsToBeReassigned.apply(partition);
for (int replicaIndex = 0; replicaIndex < replicas.size(); replicaIndex++) {
Object replica = replicas.apply(replicaIndex);
代码示例来源:origin: kframework/k
private int getArity(KLabel functionLabel) {
Set<Integer> arities = stream(mainModule.productionsFor().apply(functionLabel)).map(Production::arity).collect(Collectors.toSet());
if (arities.size() > 1) {
throw KEMException.compilerError("KLabel " + functionLabel + " has multiple productions with differing arities: " + mainModule.productionsFor().apply(functionLabel));
}
assert arities.size() == 1;
return arities.iterator().next();
}
代码示例来源:origin: kframework/k
private void applyVarRhs(String varOccurrance, StringBuilder sb, KLabel listVar) {
if (listVar != null) {
sb.append("(List (");
encodeStringToIdentifier(sb, mainModule.sortFor().apply(listVar));
sb.append(", ");
encodeStringToIdentifier(sb, listVar);
sb.append(", ");
sb.append(varOccurrance);
sb.append("))");
} else {
sb.append(varOccurrance);
}
}
代码示例来源:origin: kframework/k
public boolean collectionIsMap(KLabel collectionLabel) {
return m.attributesFor().apply(collectionLabel).contains(Attribute.COMMUTATIVE_KEY)
&& !m.attributesFor().apply(collectionLabel).contains(Attribute.IDEMPOTENT_KEY)
&& !m.attributesFor().apply(collectionLabel).contains(Att.bag());
}
代码示例来源:origin: kframework/k
public boolean collectionIsMap(KLabel collectionLabel) {
return m.attributesFor().apply(collectionLabel).contains(Attribute.COMMUTATIVE_KEY)
&& !m.attributesFor().apply(collectionLabel).contains(Attribute.IDEMPOTENT_KEY)
&& !m.attributesFor().apply(collectionLabel).contains(Att.bag());
}
代码示例来源:origin: kframework/k
public boolean collectionIsMap(KLabel collectionLabel) {
return mod.attributesFor().apply(collectionLabel).contains(Attribute.COMMUTATIVE_KEY)
&& !mod.attributesFor().apply(collectionLabel).contains(Attribute.IDEMPOTENT_KEY)
&& !mod.attributesFor().apply(collectionLabel).contains(Att.bag());
}
代码示例来源:origin: kframework/k
public boolean collectionIsBag(KLabel collectionLabel) {
return m.attributesFor().apply(collectionLabel).contains(Attribute.COMMUTATIVE_KEY)
&& !m.attributesFor().apply(collectionLabel).contains(Attribute.IDEMPOTENT_KEY)
&& m.attributesFor().apply(collectionLabel).contains(Att.bag());
}
代码示例来源:origin: kframework/k
private void applyVarLhs(KVariable k, StringBuilder sb, VarInfo vars) {
String varName = encodeStringToVariable(k.name());
vars.vars.put(k, varName);
Sort s = k.att().getOptional(Sort.class).orElse(Sort(""));
if (mainModule.sortAttributesFor().contains(s)) {
String hook = mainModule.sortAttributesFor().apply(s).<String>getOptional("hook").orElse("");
if (sortVarHooks.containsKey(hook)) {
sb.append("(");
sb.append(sortVarHooks.get(hook).apply(s));
sb.append(" as ").append(varName).append(")");
return;
}
}
sb.append(varName);
}
代码示例来源:origin: kframework/k
private void forEachKLabel(Consumer<Tuple2<KLabel, Long>> action) {
for (KLabel label : iterable(mainModule.definedKLabels())) {
if (ConvertDataStructureToLookup.isLookupKLabel(label) || label.name().equals("#KToken"))
continue;
stream(mainModule.productionsFor().apply(label)).map(p -> Tuple2.apply(p.klabel().get(), stream(p.items()).filter(pi -> pi instanceof NonTerminal).count())).distinct().forEach(action);
}
}
代码示例来源:origin: kframework/k
private KLabel getWrapElement(KLabel collectionLabel) {
return KLabel(m.attributesFor().apply(collectionLabel).get("wrapElement"));
}
代码示例来源:origin: kframework/k
private KLabel getWrapElement(KLabel collectionLabel) {
return KLabel(m.attributesFor().apply(collectionLabel).get("wrapElement"));
}
代码示例来源:origin: kframework/k
@Override
public Optional<KApply> apply(KApply k) {
if (k.klabel() instanceof KVariable) {
return super.apply(k);
}
if (m.attributesFor().apply(k.klabel()).contains("thread")) {
return Optional.of(k);
}
return super.apply(k);
}
代码示例来源:origin: kframework/k
private Either<Set<ParseFailedException>, Term> wrapTermWithCast(Constant c, Sort declared) {
Production cast;
if (addCast) {
cast = productions.apply(KLabel("#SemanticCastTo" + declared.toString())).head();
} else if (inferCasts && !hasCastAlready && productions.contains(KLabel("#SyntacticCast"))) {
cast = stream(productions.apply(KLabel("#SyntacticCast"))).filter(p -> p.sort().equals(declared)).findAny().get();
} else {
cast = null;
}
if (cast == null) {
return Right.apply(c);
} else {
return Right.apply(TermCons.apply(ConsPStack.singleton(c), cast, c.location(), c.source()));
}
}
代码示例来源:origin: kframework/k
private boolean isUnit(K item, boolean klist, boolean rhs, VarInfo vars, boolean anywhereRule) {
return isList(item, klist, rhs, vars, anywhereRule) && item instanceof KApply && !(((KApply)item).klabel() instanceof KVariable) && mainModule.attributesFor().apply(((KApply)item).klabel()).contains("returnsUnit");
}
代码示例来源:origin: kframework/k
private Production production(KApply term) {
scala.collection.Set<Production> prods = mod.productionsFor().apply(((KApply) term).klabel());
if (prods.size() != 1) {
throw KEMException.compilerError("Could not find production for KApply with label " + term.klabel(), term);
}
return prods.head();
}
代码示例来源:origin: kframework/k
@Override
public K apply(KApply k) {
if (m.attributesFor().apply(k.klabel()).contains("thread")) {
return KApply(k.klabel(), KApply(KLabel("#ThreadLocal")));
}
return super.apply(k);
}
}.apply(body);
代码示例来源:origin: kframework/k
private boolean isConstructorLike(KLabel klabel) {
String labelName = klabel.name();
if (isInjectionLabel(labelName) || isBuiltinModuloConstructor(klabel)) return true;
Set<Production> productionSet = module.productionsFor().apply(klabel);
assert productionSet.size() == 1 : "Should not have more than one production";
Production production = productionSet.head();
return !production.att().contains(Att.Function());
}
代码示例来源:origin: kframework/k
private Production production(KApply term) {
if (term.klabel().name().equals(KLabels.INJ))
return Production(INJ_PROD.klabel(), INJ_PROD.sort(), INJ_PROD.items(), Att.empty().add("originalPrd", Production.class, INJ_PROD));
scala.collection.Set<Production> prods = module.productionsFor().apply(((KApply) term).klabel());
assert(prods.size() == 1);
return computePolyProd(prods.head());
}
代码示例来源:origin: kframework/k
public static K flattenTerm(Module mod, KApply kapp) {
List<K> items = new ArrayList<>();
Att att = mod.attributesFor().apply(KLabel(kapp.klabel().name()));
if (att.contains("assoc") && att.contains("unit")) {
items = Assoc.flatten(kapp.klabel(), kapp.klist().items(), KLabel(att.get("unit")));
} else {
items = kapp.klist().items();
}
return KApply(kapp.klabel(), KList(items), kapp.att());
}
代码示例来源:origin: kframework/k
private static Sentence markRegularRules(Definition d, ConfigurationInfoFromModule configInfo, Sentence s, String att) {
if (s instanceof org.kframework.definition.Rule) {
org.kframework.definition.Rule r = (org.kframework.definition.Rule) s;
if (r.body() instanceof KApply) {
KLabel klabel = ((KApply) r.body()).klabel();
if (d.mainModule().sortFor().contains(klabel) //is false for rules in specification modules not part of semantics
&& d.mainModule().sortFor().apply(klabel).equals(configInfo.topCell())) {
return Rule.apply(r.body(), r.requires(), r.ensures(), r.att().add(att));
}
}
}
return s;
}
内容来源于网络,如有侵权,请联系作者删除!