Search this API

y.util
Class Generics

java.lang.Object
  extended by y.util.Generics

public final class Generics
extends java.lang.Object

Utility class with static methods that can be used to conveniently iterate over a graph's structure using Java 5's enhanced for loop. E.g.:

  for (Node node : nodes(graph)) {
    for (Edge edge : outEdges(node)) {
      System.out.println(edge);
    }
  }
 
This can be achieved by statically importing the utility methods of this class into your source file.

 

Method Summary
static java.lang.Iterable<Edge> edges(Graph graph)
          Static utility method that can be used in enhanced for loops to conveniently iterate over a graph's Graph.edges().
static java.lang.Iterable<Edge> edges(Node node)
          Static utility method that can be used in enhanced for loops to conveniently iterate over a node's adjacent Node.edges().
static java.lang.Iterable<Edge> inEdges(Node node)
          Static utility method that can be used in enhanced for loops to conveniently iterate over a node's adjacent Node.inEdges().
static java.lang.Iterable<Node> nodes(Graph graph)
          Static utility method that can be used in enhanced for loops to conveniently iterate over a graph's Graph.nodes().
static java.lang.Iterable<Edge> outEdges(Node node)
          Static utility method that can be used in enhanced for loops to conveniently iterate over a node's adjacent Node.outEdges().
static java.lang.Iterable<Node> predecessors(Node node)
          Static utility method that can be used in enhanced for loops to conveniently iterate over a node's Node.predecessors().
static java.lang.Iterable<Node> successors(Node node)
          Static utility method that can be used in enhanced for loops to conveniently iterate over a node's Node.successors().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

nodes

public static java.lang.Iterable<Node> nodes(Graph graph)
Static utility method that can be used in enhanced for loops to conveniently iterate over a graph's Graph.nodes().

Parameters:
graph - the graph to provide an Iterable for.
Returns:
an Iterable over the graph's Graph.nodes()

edges

public static java.lang.Iterable<Edge> edges(Graph graph)
Static utility method that can be used in enhanced for loops to conveniently iterate over a graph's Graph.edges().

Parameters:
graph - the graph to provide an Iterable for.
Returns:
an Iterable over the graph's Graph.edges()

inEdges

public static java.lang.Iterable<Edge> inEdges(Node node)
Static utility method that can be used in enhanced for loops to conveniently iterate over a node's adjacent Node.inEdges().

Parameters:
node - the node to provide an Iterable for.
Returns:
an Iterable over the node's adjacent Node.inEdges()

outEdges

public static java.lang.Iterable<Edge> outEdges(Node node)
Static utility method that can be used in enhanced for loops to conveniently iterate over a node's adjacent Node.outEdges().

Parameters:
node - the node to provide an Iterable for.
Returns:
an Iterable over the node's adjacent Node.outEdges()

edges

public static java.lang.Iterable<Edge> edges(Node node)
Static utility method that can be used in enhanced for loops to conveniently iterate over a node's adjacent Node.edges().

Parameters:
node - the node to provide an Iterable for.
Returns:
an Iterable over the node's adjacent Node.edges()

successors

public static java.lang.Iterable<Node> successors(Node node)
Static utility method that can be used in enhanced for loops to conveniently iterate over a node's Node.successors().

Parameters:
node - the node to provide an Iterable for.
Returns:
an Iterable over the node's Node.successors()

predecessors

public static java.lang.Iterable<Node> predecessors(Node node)
Static utility method that can be used in enhanced for loops to conveniently iterate over a node's Node.predecessors().

Parameters:
node - the node to provide an Iterable for.
Returns:
an Iterable over the node's Node.predecessors()

© Copyright 2000-2019,
yWorks GmbH.
All rights reserved.