当前位置: 首页>>代码示例>>Java>>正文


Java MultiRandomAccessOutEdges类代码示例

本文整理汇总了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();
          }
        };
      }
    };
  }
}
 
开发者ID:MarcoLotz,项目名称:dynamicGraph,代码行数:38,代码来源:DefaultVertex.java

示例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();
          }
        };
      }
    };
  }
}
 
开发者ID:zfighter,项目名称:giraph-research,代码行数:48,代码来源:Vertex.java


注:本文中的org.apache.giraph.edge.MultiRandomAccessOutEdges类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。