本文整理汇总了Java中org.apache.giraph.edge.MultiRandomAccessOutEdges类的典型用法代码示例。如果您正苦于以下问题:Java MultiRandomAccessOutEdges类的具体用法?Java MultiRandomAccessOutEdges怎么用?Java MultiRandomAccessOutEdges使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MultiRandomAccessOutEdges类属于org.apache.giraph.edge包,在下文中一共展示了MultiRandomAccessOutEdges类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllEdgeValues
import org.apache.giraph.edge.MultiRandomAccessOutEdges; //导入依赖的package包/类
@Override
public Iterable<E> getAllEdgeValues(final I targetVertexId) {
// If the OutEdges implementation has a specialized random-access
// method, we use that; otherwise, we scan the edges.
if (edges instanceof MultiRandomAccessOutEdges) {
return ((MultiRandomAccessOutEdges<I, E>) edges)
.getAllEdgeValues(targetVertexId);
} else {
return new Iterable<E>() {
@Override
public Iterator<E> iterator() {
return new UnmodifiableIterator<E>() {
/** Iterator over all edges. */
private Iterator<Edge<I, E>> edgeIterator = edges.iterator();
/** Last matching edge found. */
private Edge<I, E> currentEdge;
@Override
public boolean hasNext() {
while (edgeIterator.hasNext()) {
currentEdge = edgeIterator.next();
if (currentEdge.getTargetVertexId().equals(targetVertexId)) {
return true;
}
}
return false;
}
@Override
public E next() {
return currentEdge.getValue();
}
};
}
};
}
}
示例2: getAllEdgeValues
import org.apache.giraph.edge.MultiRandomAccessOutEdges; //导入依赖的package包/类
/**
* Get an iterable over the values of all edges with the given target
* vertex id. This only makes sense for multigraphs (i.e. graphs with
* parallel edges).
* Note: edge value objects returned by this method may be invalidated as
* soon as the next element is requested. Thus, keeping a reference to an
* edge value almost always leads to undesired behavior.
*
* @param targetVertexId Target vertex id
* @return Iterable of edge values
*/
public Iterable<E> getAllEdgeValues(final I targetVertexId) {
// If the OutEdges implementation has a specialized random-access
// method, we use that; otherwise, we scan the edges.
if (edges instanceof MultiRandomAccessOutEdges) {
return ((MultiRandomAccessOutEdges<I, E>) edges)
.getAllEdgeValues(targetVertexId);
} else {
return new Iterable<E>() {
@Override
public Iterator<E> iterator() {
return new UnmodifiableIterator<E>() {
/** Iterator over all edges. */
private Iterator<Edge<I, E>> edgeIterator = edges.iterator();
/** Last matching edge found. */
private Edge<I, E> currentEdge;
@Override
public boolean hasNext() {
while (edgeIterator.hasNext()) {
currentEdge = edgeIterator.next();
if (currentEdge.getTargetVertexId().equals(targetVertexId)) {
return true;
}
}
return false;
}
@Override
public E next() {
return currentEdge.getValue();
}
};
}
};
}
}