本文整理了Java中org.apache.commons.rdf.api.Dataset.iterate()
方法的一些代码示例,展示了Dataset.iterate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dataset.iterate()
方法的具体详情如下:
包路径:org.apache.commons.rdf.api.Dataset
类名称:Dataset
方法名:iterate
[英]Get an Iterable for iterating over all quads in the dataset.
This method is meant to be used with a Java for-each loop, e.g.:
for (Quad t : dataset.iterate()) {
System.out.println(t);
}
The behaviour of the iterator is not specified if #add(Quad), #remove(Quad) or #clear(), are called on the Dataset before it terminates. It is undefined if the returned Iterator supports the Iterator#remove() method.
Implementations may throw ConcurrentModificationException from Iterator methods if they detect a concurrency conflict while the Iterator is active.
The Iterable#iterator() must only be called once, that is the Iterable must only be iterated over once. A IllegalStateExceptionmay be thrown on attempt to reuse the Iterable.
The default implementation of this method will call #stream() to return its Stream#iterator().
[中]获取迭代数据集中所有四边形的Iterable。
此方法用于每个循环的Java,例如:
for (Quad t : dataset.iterate()) {
System.out.println(t);
}
如果在数据集终止之前对其调用#add(Quad)、#remove(Quad)或#clear(),则不会指定迭代器的行为。如果返回的迭代器支持迭代器#remove()方法,则它是未定义的。
如果实现在迭代器处于活动状态时检测到并发冲突,则可能会从迭代器方法抛出ConcurrentModificationException。
Iterable#迭代器()只能调用一次,即Iterable只能迭代一次。试图重用Iterable时可能会抛出非法状态Exception。
此方法的默认实现将调用#stream()以返回其流#迭代器()。
代码示例来源:origin: org.trellisldp/trellis-api
@Override
public BinaryOperator<Dataset> combiner() {
return (left, right) -> {
right.iterate().forEach(left::add);
return left;
};
}
代码示例来源:origin: trellis-ldp/trellis
@Override
public BinaryOperator<Dataset> combiner() {
return (left, right) -> {
right.iterate().forEach(left::add);
return left;
};
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
@Test
public void iterateFilter() throws Exception {
final List<RDFTerm> friends = new ArrayList<>();
final IRI alice = factory.createIRI("http://example.com/alice");
final IRI knows = factory.createIRI("http://xmlns.com/foaf/0.1/knows");
for (final Quad t : dataset.iterate(null, alice, knows, null)) {
friends.add(t.getObject());
}
assertEquals(1, friends.size());
assertEquals(bob, friends.get(0));
// .. can we iterate over zero hits?
final Iterable<Quad> iterate = dataset.iterate(Optional.of(graph2), bob, knows, alice);
for (final Quad unexpected : iterate) {
fail("Unexpected quad " + unexpected);
}
// closeIterable(iterate);
}
代码示例来源:origin: org.apache.commons/commons-rdf-api
Assume.assumeTrue(dataset.size() > 0);
final List<Quad> quads = new ArrayList<>();
for (final Quad t : dataset.iterate()) {
quads.add(t);
final Iterable<Quad> iterate = dataset.iterate();
final Iterator<Quad> it = iterate.iterator();
final Iterable<Quad> iterable = dataset.iterate();
for (@SuppressWarnings("unused") final
Quad t : iterable) {
for (final Quad aliceQ : dataset.iterate(null, alice, null, null)) {
aliceQuads.add(aliceQ);
for (final Quad topic : dataset.iterate(null, null, isPrimaryTopicOf, null)) {
topics++;
内容来源于网络,如有侵权,请联系作者删除!