當前位置: 首頁>>代碼示例>>Java>>正文


Java Iterator.hasNext方法代碼示例

本文整理匯總了Java中scala.collection.Iterator.hasNext方法的典型用法代碼示例。如果您正苦於以下問題:Java Iterator.hasNext方法的具體用法?Java Iterator.hasNext怎麽用?Java Iterator.hasNext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scala.collection.Iterator的用法示例。


在下文中一共展示了Iterator.hasNext方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convertPhrasesToTokens

import scala.collection.Iterator; //導入方法依賴的package包/類
private Seq<KoreanToken> convertPhrasesToTokens(Seq<KoreanPhrase> phrases) {
    KoreanToken[] tokens = new KoreanToken[phrases.length()];

    Iterator<KoreanPhrase> iterator = phrases.iterator();
    int i = 0;
    while (iterator.hasNext()) {
        KoreanPhrase phrase = iterator.next();
        tokens[i++] = new KoreanToken(phrase.text(), phrase.pos(), phrase.offset(), phrase.length(), scala.Option.apply(null), false);
    }

    Arrays.sort(tokens, (o1, o2) -> {
        if(o1.offset()== o2.offset())
            return 0;
        return o1.offset()< o2.offset()? -1 : 1;
    });

    return JavaConverters.asScalaBuffer(Arrays.asList(tokens)).toSeq();
}
 
開發者ID:open-korean-text,項目名稱:elasticsearch-analysis-openkoreantext,代碼行數:19,代碼來源:OpenKoreanTextPhraseExtractor.java

示例2: getStringElements

import scala.collection.Iterator; //導入方法依賴的package包/類
public String getStringElements() {
	String elementsString = "\n  ----------------ELEMENTS---------------- \n";
	for(Map.Entry<String, Tuple2<String, List<Tuple2<String, Object>>>> entry : mapInfos.entrySet()) {
		String name = entry.getKey();
		elementsString += "\n  Element "+name+" ";
		Tuple2<String, List<Tuple2<String, Object>>> typeAndInfos = entry.getValue();
		String type = (String) typeAndInfos._1;
		elementsString += "("+type+") : \n";
		List<Tuple2<String, Object>> listInfos = (List<Tuple2<String, Object>>) typeAndInfos._2;
		Iterator<Tuple2<String, Object>> itInfos = listInfos.iterator();
		while(itInfos.hasNext()) {
			Tuple2<String, Object> infos = itInfos.next();
			String attribute = infos._1;
			String value = String.valueOf(infos._2);
			elementsString += "  * "+attribute+" : "+value+" \n";
		}
		elementsString += "  ---------------------------------------- \n";
	}
	return elementsString;
}
 
開發者ID:cetic,項目名稱:SimQRI,代碼行數:21,代碼來源:OneShotTracer.java

示例3: setQueriesSamples

import scala.collection.Iterator; //導入方法依賴的package包/類
/**
 * 
 * @param sqlogger "Monte-Carlo" simulation results
 * @param model The instance of the SimQRi model
 * @deprecated
 * This method set simulation results to queries objects of the Sirius Metamodel instance. 
 * No longer used due to a too long time for setting results when there are a lot of queries
 */
@SuppressWarnings("unused")
private void setQueriesSamples(TraceLogger sqlogger, Model model) {
	Iterator<SamplingTuple> itProbes = sqlogger.logs().mcSamplings().probesSampling().iterator();
	while(itProbes.hasNext()) {
		SamplingTuple probes = itProbes.next();
		for(Query q : model.getQuery()) {
			if(q.getName().equals(probes.name())) {
				TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(q);
				domain.getCommandStack().execute(new RecordingCommand(domain) {
				   public void doExecute() {
					  // q.setResult("");
					  // q.setMax(String.format("%.2f", JsonFormat.jsonToDouble(probes.samplingStr(), "max")));
					  // q.setMin(String.format("%.2f", JsonFormat.jsonToDouble(probes.samplingStr(), "min")));
					  // q.setMean(String.format("%.2f", JsonFormat.jsonToDouble(probes.samplingStr(), "mean")));
					  // q.setVariance(String.valueOf(JsonFormat.jsonToDouble(probes.samplingStr(), "variance")));
				   }
				});
			}
		}
	}
}
 
開發者ID:cetic,項目名稱:SimQRI,代碼行數:30,代碼來源:Simulation.java

示例4: matchBlock

import scala.collection.Iterator; //導入方法依賴的package包/類
@Override
public boolean matchBlock(final int side2, final int x2, final int y2, final int z2) {
    if (this.isOpaque) {
        final TileEntity tile_base = this.blockAccess.getTileEntity(x2, y2, z2);
        if (tile_base != null && tile_base instanceof TileMultipart) {
            final TileMultipart tile = (TileMultipart)tile_base;
            final Iterator<TMultiPart> parts = (Iterator<TMultiPart>)tile.partList().toIterator();
            while (parts.hasNext()) {
                final TMultiPart part = (TMultiPart)parts.next();
                if ((part instanceof FaceMicroblockClient || part instanceof HollowMicroblockClient) && (side2 == -1 || this.getSideFromBounds(((Microblock)part).getBounds()) == side2)) {
                    final ItemStack t = MicroMaterialRegistry.getMaterial(((Microblock)part).getMaterial()).getItem();
                    if (t.getItem() instanceof ItemBlock && this.curBlock == ((ItemBlock)t.getItem()).field_150939_a && t.getItemDamage() == this.curMeta) {
                        return true;
                    }
                    continue;
                }
            }
        }
    }
    return super.matchBlock(side2, x2, y2, z2);
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:22,代碼來源:FakeRenderBlocksMultiPart.java

示例5: freeVariables

import scala.collection.Iterator; //導入方法依賴的package包/類
public ProverExpr[] freeVariables(ProverExpr expr) {
  final ArrayList<ProverExpr> res = new ArrayList<ProverExpr> ();
  
  final scala.Tuple3<scala.collection.Set<IVariable>,
                      scala.collection.Set<ConstantTerm>,
                      scala.collection.Set<Predicate>> symTriple;
  if (expr instanceof TermExpr)
    symTriple = SymbolCollector$.MODULE$.varsConstsPreds(((TermExpr)expr).term);
  else
    symTriple = SymbolCollector$.MODULE$.varsConstsPreds(((FormulaExpr)expr).formula);
  
  final Iterator<IVariable> it1 = symTriple._1().iterator();
  while (it1.hasNext())
    res.add(new TermExpr(it1.next(), getIntType()));
  
  final Iterator<ConstantTerm> it2 = symTriple._2().iterator();
  while (it2.hasNext())
    res.add(new TermExpr(IConstant$.MODULE$.apply(it2.next()), getIntType()));
  
  final Iterator<Predicate> it3 = symTriple._3().iterator();
  final List<ITerm> emptyArgs = (new ArrayBuffer<ITerm>()).toList();
  while (it3.hasNext())
    res.add(new FormulaExpr(IAtom$.MODULE$.apply(it3.next(), emptyArgs)));
  
  return res.toArray(new ProverExpr[0]);
}
 
開發者ID:SRI-CSL,項目名稱:bixie,代碼行數:27,代碼來源:PrincessProver.java

示例6: processQueryFunction

import scala.collection.Iterator; //導入方法依賴的package包/類
private void processQueryFunction(FilterOption option, String boolMethod) {
    BooleanMethodCallExpr methodCall = (BooleanMethodCallExpr) option.expression();
    assertThat(methodCall.methodName(), is(boolMethod));
    List<Expression> args = methodCall.args();
    Iterator iterator = args.iterator();
    while (iterator.hasNext()) {
        Object cursor = iterator.next();
        if (cursor instanceof EntityPathExpr) {
            EntityPathExpr pathExpr = (EntityPathExpr) cursor;
            PropertyPathExpr path = (PropertyPathExpr) pathExpr.subPath().get();
            assertThat(path.propertyName(), is("name"));
        } else if (cursor instanceof LiteralExpr) {
            LiteralExpr literalExpr = (LiteralExpr) cursor;
            StringLiteral stringLiteral = (StringLiteral) literalExpr.value();
            assertThat(stringLiteral.value(), is("John"));
        }
    }
}
 
開發者ID:sdl,項目名稱:odata,代碼行數:19,代碼來源:ParserLogicalTest.java

示例7: testQueryFunction

import scala.collection.Iterator; //導入方法依賴的package包/類
private void testQueryFunction(String operator) throws ODataException {
    EqExpr expr = getExprFromOperator(operator);
    MethodCallExpr call = (MethodCallExpr) expr.left();
    assertThat(call.methodName(), is(operator));
    List<Expression> args = call.args();
    Iterator iter = args.iterator();
    while (iter.hasNext()) {
        Object obj = iter.next();
        if (obj instanceof EntityPathExpr) {
            EntityPathExpr entityPathExpr = (EntityPathExpr) obj;
            PropertyPathExpr propertyPath = (PropertyPathExpr) entityPathExpr.subPath().get();
            assertThat(propertyPath.propertyName(), is("name"));
        }
    }
    LiteralExpr literal = (LiteralExpr) expr.right();
    NumberLiteral number = (NumberLiteral) literal.value();
    assertThat(number.value(), is(new BigDecimal(new java.math.BigDecimal(19))));
}
 
開發者ID:sdl,項目名稱:odata,代碼行數:19,代碼來源:ParserQueryFunctionsTest.java

示例8: modelToList

import scala.collection.Iterator; //導入方法依賴的package包/類
@Override
protected ImmutableList<ValueAssignment> modelToList() {
  scala.collection.Map<ModelLocation, ModelValue> interpretation = model.interpretation();

  // first get the addresses of arrays
  Map<IdealInt, ITerm> arrays = getArrayAddresses(interpretation);

  // then iterate over the model and generate the assignments
  Builder<ValueAssignment> assignments = ImmutableSet.builder();
  Iterator<Tuple2<ModelLocation, ModelValue>> it2 = interpretation.iterator();
  while (it2.hasNext()) {
    Tuple2<ModelLocation, ModelValue> entry = it2.next();
    ValueAssignment assignment = getAssignment(entry._1, entry._2, arrays);
    if (assignment != null) {
      assignments.add(assignment);
    }
  }

  return assignments.build().asList();
}
 
開發者ID:sosy-lab,項目名稱:java-smt,代碼行數:21,代碼來源:PrincessModel.java

示例9: getArrayAddresses

import scala.collection.Iterator; //導入方法依賴的package包/類
/**
 * Collect array-models, we need them to replace identifiers later. Princess models arrays as
 * plain numeric "memory-addresses", and the model for an array-access at one of the addresses is
 * the array-content. Example: "arr[5]=123" is modeled as "{arr=0, select(0,5)=123}" or "{arr=0,
 * store(0,5,123)=0}", where "0" is the memory-address. The returned mapping contains the mapping
 * of "0" (=address) to "arr" (=identifier).
 */
private Map<IdealInt, ITerm> getArrayAddresses(
    scala.collection.Map<ModelLocation, ModelValue> interpretation) {
  Map<IdealInt, ITerm> arrays = new HashMap<>();
  Iterator<Tuple2<ModelLocation, ModelValue>> it1 = interpretation.iterator();
  while (it1.hasNext()) {
    Tuple2<ModelLocation, ModelValue> entry = it1.next();
    if (entry._1 instanceof ConstantLoc) {
      ITerm maybeArray = IExpression.i(((ConstantLoc) entry._1).c());
      if (creator.getEnv().hasArrayType(maybeArray) && entry._2 instanceof IntValue) {
        arrays.put(((IntValue) entry._2).v(), maybeArray);
      }
    }
  }
  return arrays;
}
 
開發者ID:sosy-lab,項目名稱:java-smt,代碼行數:23,代碼來源:PrincessModel.java

示例10: read

import scala.collection.Iterator; //導入方法依賴的package包/類
@Override
public Option<Model> read(Class<?> modelClass, Map<String, String> typeMap) {
    final Option<Model> modelOption = super.read(modelClass, typeMap);

    // Look for public properties
    java.util.Map<String, ApiControllerUtilsServiceImpl.SerializationEntry> entries = ApiControllerUtilsServiceImpl.getSerializationEntries(modelClass,
            null);

    // Remove all properties which are not public
    if (!modelOption.isEmpty()) {
        Iterator<String> keysIterator = modelOption.get().properties().keysIterator();
        while (keysIterator.hasNext()) {
            String propertyName = keysIterator.next();
            if (!entries.containsKey(propertyName)) {
                modelOption.get().properties().remove(propertyName);
                if (log.isDebugEnabled()) {
                    log.debug("Successfully hidden API model property '" + propertyName + "'");
                }
            }
        }
    }

    return modelOption;
}
 
開發者ID:theAgileFactory,項目名稱:app-framework,代碼行數:25,代碼來源:ClassSchemaDocumentationConverter.java

示例11: apply

import scala.collection.Iterator; //導入方法依賴的package包/類
@Override
public BoxedUnit apply(Iterator<T> v1) {
    IExtractor<T, S> extractor;
    try {
        extractor = getExtractorInstance(config);
    } catch (DeepExtractorInitializationException e) {
        extractor = getExtractorClient();
    }

    extractor.initSave(config, first, queryBuilder);

    while (v1.hasNext()) {
        extractor.saveRDD(v1.next());
    }
    config.setPartitionId(config.getPartitionId() + 1);
    extractor.close();
    return null;
}
 
開發者ID:Stratio,項目名稱:deep-spark,代碼行數:19,代碼來源:PrepareSaveFunction.java

示例12: addAcls

import scala.collection.Iterator; //導入方法依賴的package包/類
public void addAcls(scala.collection.immutable.Set<Acl> acls, final Resource resource) {
    verifyAcls(acls);
    LOG.info("Adding Acl: acl->" + acls + " resource->" + resource);

    final Iterator<Acl> iterator = acls.iterator();
    while (iterator.hasNext()) {
        final Acl acl = iterator.next();
        final String role = getRole(acl);
        if (!roleExists(role)) {
            throw new KafkaException("Can not add Acl for non-existent Role: " + role);
        }
        execute(new Command<Void>() {
            @Override
            public Void run(SentryGenericServiceClient client) throws Exception {
                client.grantPrivilege(
                    requestorName, role, COMPONENT_NAME, toTSentryPrivilege(acl, resource));
                return null;
            }
        });
    }
}
 
開發者ID:apache,項目名稱:incubator-sentry,代碼行數:22,代碼來源:KafkaAuthBinding.java

示例13: removeAcls

import scala.collection.Iterator; //導入方法依賴的package包/類
public boolean removeAcls(scala.collection.immutable.Set<Acl> acls, final Resource resource) {
    verifyAcls(acls);
    LOG.info("Removing Acl: acl->" + acls + " resource->" + resource);
    final Iterator<Acl> iterator = acls.iterator();
    while (iterator.hasNext()) {
        final Acl acl = iterator.next();
        final String role = getRole(acl);
        try {
            execute(new Command<Void>() {
                @Override
                public Void run(SentryGenericServiceClient client) throws Exception {
                    client.dropPrivilege(
                            requestorName, role, toTSentryPrivilege(acl, resource));
                    return null;
                }
            });
        } catch (KafkaException kex) {
            LOG.error("Failed to remove acls.", kex);
            return false;
        }
    }

    return true;
}
 
開發者ID:apache,項目名稱:incubator-sentry,代碼行數:25,代碼來源:KafkaAuthBinding.java

示例14: meanOfEdges

import scala.collection.Iterator; //導入方法依賴的package包/類
@Override
public double meanOfEdges() {
	String current = "WHERE (m." + KEY_TIMESTAMP_DELETE + " = "
			+ InternalMetadata.METADATA_NOT_DELETED_TIMESTAMP + ")";

	String querie = ALL_IDENTIFIER + " MATCH (i)-[:Link]-(l)-[:Meta]-(m) "
			+ current + " RETURN count(l) / count(distinct i ) as result";

	ExecutionResult result = executeQuery(querie);

	Iterator<Double> nodes = result.columnAs("result");

	if (nodes.hasNext()) {
		return nodes.next();
	}

	log.error("Error occured while counting!");
	throw new RuntimeException("Error occured while counting!");
}
 
開發者ID:trustathsh,項目名稱:visitmeta,代碼行數:20,代碼來源:Neo4JExecutor.java

示例15: init

import scala.collection.Iterator; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
private void init(String swcPath) {
    File swcFile = new File(swcPath);
    TagContainer tagContainer = TagContainer.fromFile(swcFile);

    List<SwfTag> tagsScalaList = tagContainer.tags();
    Iterator tagsScalaIterator = tagsScalaList.iterator();

    while (tagsScalaIterator.hasNext()) {
        SwfTag tag = (SwfTag) tagsScalaIterator.next();
        if (tag instanceof DoABC) {
            DoABC doABC = (DoABC) tag;
            Abc abc = Abc.fromDoABC(doABC);

            AbcScript[] abcScripts = abc.scripts();
            for (AbcScript abcScript : abcScripts) {
                AbcTrait[] abcTraits = abcScript.traits();
                for (AbcTrait abcTrait : abcTraits) {
                    cacheTrait(abcTrait);
                }
            }
        }
    }
}
 
開發者ID:code-orchestra,項目名稱:colt-as,代碼行數:25,代碼來源:SWCDigest.java


注:本文中的scala.collection.Iterator.hasNext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。